Author: Shaswat Raj (SH20RAJ) Script URL: View on Gist Compatible with: macOS (Intel + M1/M2/M3) Purpose: Free up space, clean developer junk, and keep your Mac lightning fast ⚡
✅ Deletes heavy development folders:
node_modules,.next,.nuxt,.expo,dist,build,.vercel,.parcel-cache, etc.
✅ Clears all major caches:
- npm, yarn, pnpm, Homebrew, CocoaPods, Docker, Xcode, system & user caches
✅ Removes junk safely:
- Logs, temporary files, Trash, Downloads, screenshots, and app caches (Chrome, VSCode, Discord, etc.)
✅ Optional cleanup for:
- iOS DerivedData, Docker images, large cached files (>1GB)
✅ Displays disk usage before and after cleanup
You can either clone or directly download the gist:
curl -o ~/Desktop/cleanmac.sh https://gist.githubusercontent.com/SH20RAJ/5db2a9ed50625ec07158c635831ac772/raw/cleanmac.sh💡 Tip: You can replace
~/Desktop/with any folder you prefer.
Give the script permission to run:
chmod +x ~/Desktop/cleanmac.shNow execute the cleanup:
./Desktop/cleanmac.sh🧠 You may be asked for your password (for system-level cleanups).
If you want to run this by double-clicking:
-
Open Automator → select Application
-
Choose Run Shell Script
-
Paste:
bash ~/Desktop/cleanmac.sh -
Save as 🧹 Clean My Mac (Dev).app
-
Now double-click anytime to clean your system instantly.
You can easily edit the script to:
-
Target only specific folders
find ~/Projects -type d -name "node_modules" -prune -exec rm -rf {} +
-
Skip certain cleanups → just comment out lines using
# -
Add your own paths (e.g., Flutter cache, PyCache, or JetBrains IDEs)
Example:
# rm -rf ~/Library/Caches/com.jetbrains.ideaIf you want to see what will be deleted first:
find ~ -type d \( -name "node_modules" -o -name ".next" \)You can run it automatically once a week using crontab:
crontab -eThen add:
0 12 * * 0 bash ~/Desktop/cleanmac.sh >> ~/cleanmac.log 2>&1
Runs every Sunday at 12 PM and logs results to
~/cleanmac.log.
- It’s safe for developers using Node.js, React, Next.js, Flutter, iOS, or Docker.
- It won’t touch system-critical files or personal data like documents/photos.
- Requires
sudofor system logs cleanup. - Recommended to run once every 1–2 weeks.
Run with
sudoor give Full Disk Access to Terminal: System Settings → Privacy & Security → Full Disk Access → + Terminal
Very rare — ensure you’re using the default
bashorzshshell (macOS ships with both).
If you want to:
- Add new cleanup targets (e.g.,
flutter,.venv,.pytest_cache) - Make it smarter (auto-detect developer tools)
- Add GUI prompts or disk usage visualization
👉 Comment directly on the Gist Discussion or open a GitHub issue once this moves to a repo!
🧩 Deleting node_modules, .next, dist...
📦 Cleaning npm, yarn, pnpm caches...
🍺 Cleaning Homebrew cache...
🧰 Removing Xcode DerivedData...
🧠 Cleaning system caches...
🚀 Cleanup completed successfully!
📊 Disk usage before cleanup: 240 GB used
📊 Disk usage after cleanup: 180 GB used
✨ Done! Your Mac is now lighter and faster.
MIT License © Shaswat Raj