Clean my Mac as a Web & App Developer
If you are a full-stack web and mobile developer using a 256 GB (228 GiB usable) MacBook, you already know the pain: one day you're running a build, and suddenly macOS hits you with "Your disk is almost full."
When you look at macOS Settings → General → Storage, the massive gray bar labeled "System Data" or "Developer" doesn't tell you much. GUI cleaning apps often miss the real culprits because developer bloat hides inside dot-folders (~/.npm, ~/.bun, ~/.gradle, ~/.expo) and deep inside ~/Library.
Recently, my Mac hit 95% capacity with 196 GB used and only 11 GB of free space left. In less than 15 minutes using the terminal, I reclaimed 87 GB, dropping my disk usage to 53% (98 GB free) without deleting a single project or breaking my development setup.
Here is the end-to-end breakdown of how I diagnosed the bloat, what was secretly eating my SSD, and the exact copy-pasteable commands and script you can run whenever your Mac fills up.
1. The Diagnosis: Finding Where the Gigabytes Hide#
Before deleting anything, always establish a baseline and find the heaviest directories.
Step 1.1: Check your overall disk usage#
df -h / /System/Volumes/DataMy initial output looked like this:
Filesystem Size Used Avail Capacity Mounted on
/dev/disk3s5 228Gi 196Gi 11Gi 95% /System/Volumes/DataStep 1.2: Scan top-level folders & hidden dot-folders in $HOME#
Most developer tools store caches in hidden dot-directories in your home folder (~). Run this command to rank every visible and hidden folder in your home directory by size:
du -sh ~/* ~/.[!.]* 2>/dev/null | sort -hr | head -n 30Here is what came back on my machine:
54G /Users/gopalverma/Library
23G /Users/gopalverma/.npm
14G /Users/gopalverma/.bun
7.5G /Users/gopalverma/.gradle
3.6G /Users/gopalverma/.expo
3.4G /Users/gopalverma/.local
2.5G /Users/gopalverma/.meteor
2.3G /Users/gopalverma/.yarn
2.2G /Users/gopalverma/.rustup
1.8G /Users/gopalverma/.nvm
1.5G /Users/gopalverma/.pub-cache
1.2G /Users/gopalverma/.cache
1.1G /Users/gopalverma/.cursorRight away, over 60 GB was sitting in hidden dot-folders alone (~/.npm, ~/.bun, ~/.gradle, ~/.expo, ~/.yarn, ~/.pub-cache), plus another 54 GB inside ~/Library.
Step 1.3: Drill down into ~/Library and system directories#
Next, I scanned ~/Library (where Xcode, Android SDK, and desktop apps store their data) and /opt/homebrew:
du -sh ~/Library/* ~/Library/Application\ Support/* ~/Library/Developer/* /opt/homebrew/* 2>/dev/null | sort -hr | head -n 25Output highlights:
22G /Users/gopalverma/Library/Application Support
19G /Users/gopalverma/Library/Developer/CoreSimulator
11G /Users/gopalverma/Library/Android/sdk
9.8G /Users/gopalverma/Library/Application Support/Claude
8.9G /Users/gopalverma/Library/Application Support/Cursor2. The Cleanup: Step-by-Step Commands by Category#
Safety Note: Everything below targets download caches, build caches, simulator caches, and redundant backups. None of these commands touch your source code or active
node_modules. At worst, a tool will re-download a package the next time you build an active project.
Category 1: JavaScript, Dart, Rust & Go Package Caches (~42 GB Freed)#
Every time you run npm install, bun install, yarn, or flutter pub get, the package manager keeps a compressed copy of that version in a global cache directory forever. Over a year or two of building web and mobile apps, this quietly balloons to tens of gigabytes.
.npm/_cacache: 23 GB.bun/install/cache: 14 GB.yarn/berry/cache: 2.3 GB.pub-cache(Flutter/Dart), Cargo, Go module cache: ~2.7 GB
Commands to clean package manager caches:
# 1. Clean npm download & npx caches
npm cache clean --force 2>/dev/null
chmod -R u+w ~/.npm 2>/dev/null
rm -rf ~/.npm/_cacache ~/.npm/_npx ~/.npm/_logs
# 2. Clean Bun global install cache
rm -rf ~/.bun/install/cache
# 3. Clean Yarn (v1 and Berry) caches
rm -rf ~/.yarn/berry/cache ~/Library/Caches/Yarn
# 4. Clean Flutter / Dart pub cache & analysis server cache
rm -rf ~/.pub-cache ~/.dartServer ~/.pkg-cache
# 5. Clean Rust Cargo & Go module download caches
# (Note: Go marks cached modules read-only, so chmod u+w is needed first)
chmod -R u+w ~/go/pkg/mod/cache 2>/dev/null
rm -rf ~/go/pkg/mod/cache ~/.cargo/registry/cache ~/.cargo/git/dbCategory 2: Mobile Build & Simulator Caches (~23 GB Freed)#
If you build with React Native, Expo, Flutter, iOS (Xcode), or Android, your build caches and simulator data grow rapidly:
- Xcode
CoreSimulator: 19 GB (Devicestook 8.8 GB andCaches3.5 GB — 12.3 GB freed while keeping the 6.7 GB activeImagesruntime) - Gradle (
~/.gradle): 7.5 GB - Expo (
~/.expo): 3.6 GB (cached iOS simulator builds, Expo Go tarballs, and Android APKs)
Commands to clean mobile & build caches:
# 1. Clean Gradle build caches, daemon logs, and old wrapper distributions
rm -rf ~/.gradle/caches ~/.gradle/daemon ~/.gradle/wrapper/dists
# 2. Clean Expo cached APKs and iOS Simulator app caches
rm -rf ~/.expo/ios-simulator-app-cache ~/.expo/expo-go ~/.expo/android-apk-cache
# 3. Delete unavailable Xcode Simulators, erase simulator app data, and clear simulator caches
xcrun simctl delete unavailable 2>/dev/null
xcrun simctl erase all 2>/dev/null
rm -rf ~/Library/Developer/CoreSimulator/Caches
# 4. Optional: Clean Xcode DerivedData and Archives (if you use Xcode directly)
rm -rf ~/Library/Developer/Xcode/DerivedData/*Category 3: AI Desktop Apps, IDE Caches & Local ML Models (~13.5 GB Freed)#
Modern AI tools and IDEs store surprisingly huge files inside ~/Library/Application Support and ~/.cache:
- Claude Desktop (
vm_bundles) - 9.3 GB: Claude's desktop app downloads local VM bundles inside~/Library/Application Support/Claude/vm_bundles. - Cursor IDE (
state.vscdb.backup&CachedExtensionVSIXs) - 3.1 GB: Cursor keeps a massive backup of its global SQLite state (state.vscdb.backupwas 2.3 GB alone!) alongside cached extension.vsixinstallers and V8CachedData. - Local ML & CLI Caches (
~/.cache) - 1.2 GB: HuggingFace (~/.cache/huggingface), PyTorch (~/.cache/torch), Prisma engines (~/.cache/prisma), and Neovim cache (~/.cache/nvim).
Commands to clean AI, IDE & ~/.cache bloat:
# 1. Clean Claude Desktop VM bundles and cache
rm -rf ~/Library/Application\ Support/Claude/vm_bundles
rm -rf ~/Library/Application\ Support/Claude/Cache
# 2. Clean Cursor IDE redundant database backup and extension/V8 caches
# (Leaves your active settings, chats, and workspace storage intact!)
rm -rf ~/Library/Application\ Support/Cursor/CachedData
rm -rf ~/Library/Application\ Support/Cursor/CachedExtensionVSIXs
rm -rf ~/Library/Application\ Support/Cursor/Cache
rm -f ~/Library/Application\ Support/Cursor/User/globalStorage/state.vscdb.backup
# 3. Clean HuggingFace, PyTorch, Prisma, and Neovim caches
rm -rf ~/.cache/huggingface ~/.cache/torch ~/.cache/prisma ~/.cache/nvimCategory 4: Homebrew & Unused Toolchains (~8.5 GB Freed)#
Over time, Homebrew keeps outdated versions of formulas and incomplete cellar downloads. Furthermore, if you experimented with frameworks or languages in the past (like Meteor, RVM Ruby, Rustup, or old Android Emulator system images), they stay on disk forever.
Commands to clean Homebrew & unused toolchains:
# 1. Clean old Homebrew package versions and scrub download cache
brew cleanup -s
brew autoremove
# 2. Optional: Remove Android Emulator system images (only run if you test on physical devices or want to re-download a single emulator image later)
rm -rf ~/Library/Android/sdk/system-images
# 3. Optional: Remove unused language managers/toolchains (ONLY run for tools you no longer use!)
# Note: .rustup and .rvm contain read-only files, so chmod -R u+w is required first
chmod -R u+w ~/.rustup ~/.rvm 2>/dev/null
rm -rf ~/.meteor ~/.rustup ~/.rvm3. The All-in-One Reusable Cleanup Script (clean-dev-mac.sh)#
So you never have to remember these commands again, save the script below as clean-dev-mac.sh and run it whenever your storage starts getting tight. It prints your disk space before and after and safely cleans all developer caches without removing active toolchains unless you ask it to.
#!/usr/bin/env bash
set -u
echo "=================================================="
echo "🧹 Starting Mac Developer Storage Cleanup..."
echo "=================================================="
echo ""
echo "📊 Disk Space BEFORE:"
df -h /System/Volumes/Data 2>/dev/null || df -h /
echo ""
echo "1/6 📦 Cleaning JS/TS package manager caches (npm, Bun, Yarn, pnpm)..."
npm cache clean --force 2>/dev/null || true
chmod -R u+w ~/.npm 2>/dev/null || true
rm -rf ~/.npm/_cacache ~/.npm/_npx ~/.npm/_logs
rm -rf ~/.bun/install/cache
rm -rf ~/.yarn/berry/cache ~/Library/Caches/Yarn
rm -rf ~/Library/pnpm/store 2>/dev/null || true
echo "2/6 🎯 Cleaning Dart/Flutter, Go, and Rust Cargo caches..."
rm -rf ~/.pub-cache ~/.dartServer ~/.pkg-cache
chmod -R u+w ~/go/pkg/mod/cache 2>/dev/null || true
rm -rf ~/go/pkg/mod/cache
rm -rf ~/.cargo/registry/cache ~/.cargo/git/db
echo "3/6 📱 Cleaning Mobile & Build caches (Gradle, Expo, Xcode Simulators)..."
rm -rf ~/.gradle/caches ~/.gradle/daemon ~/.gradle/wrapper/dists
rm -rf ~/.expo/ios-simulator-app-cache ~/.expo/expo-go ~/.expo/android-apk-cache
xcrun simctl delete unavailable 2>/dev/null || true
xcrun simctl erase all 2>/dev/null || true
rm -rf ~/Library/Developer/CoreSimulator/Caches
rm -rf ~/Library/Developer/Xcode/DerivedData/* 2>/dev/null || true
echo "4/6 🤖 Cleaning AI Desktop, IDE & ML caches (Claude, Cursor, VS Code, ~/.cache)..."
rm -rf ~/Library/Application\ Support/Claude/vm_bundles
rm -rf ~/Library/Application\ Support/Claude/Cache
rm -rf ~/Library/Application\ Support/Cursor/CachedData
rm -rf ~/Library/Application\ Support/Cursor/CachedExtensionVSIXs
rm -rf ~/Library/Application\ Support/Cursor/Cache
rm -f ~/Library/Application\ Support/Cursor/User/globalStorage/state.vscdb.backup
rm -rf ~/Library/Application\ Support/Code/CachedData
rm -rf ~/Library/Application\ Support/Code/CachedExtensionVSIXs
rm -rf ~/Library/Application\ Support/Code/Cache
rm -rf ~/.cache/huggingface ~/.cache/torch ~/.cache/prisma ~/.cache/nvim
echo "5/6 🍺 Running Homebrew cleanup..."
if command -v brew >/dev/null 2>&1; then
brew cleanup -s 2>/dev/null || true
brew autoremove 2>/dev/null || true
fi
echo "6/6 ✅ Cleanup finished!"
echo ""
echo "📊 Disk Space AFTER:"
df -h /System/Volumes/Data 2>/dev/null || df -h /
echo "=================================================="4. Final Results: Before vs. After#
| Metric | Before Cleanup | After Cleanup | Net Change |
|---|---|---|---|
Used Space (/System/Volumes/Data) | 196 GB (95% full) | 109 GB (53% full) | -87 GB |
| Available Free Space | 11 GB | 98 GB | +87 GB |
Directory Size Comparison#
| Directory | Before | After |
|---|---|---|
~/.npm | 23 GB | 275 MB |
~/.bun | 14 GB | 282 MB |
~/Library/Developer/CoreSimulator (Devices + Caches) | 12.3 GB | 192 MB |
~/Library/Application Support/Claude/vm_bundles | 9.3 GB | 0 B |
~/.gradle | 7.5 GB | 54 MB |
~/.expo | 3.6 GB | 6.5 MB |
Cursor (state.vscdb.backup + Caches) | 3.1 GB | 0 B |
~/.yarn | 2.3 GB | ~15 MB |
~/.pub-cache & ~/.dartServer | 2.0 GB | 0 B |
Bonus Tip: Dealing with Old node_modules in Old Projects#
If you also want to find and wipe node_modules folders across old project directories you haven't touched in months, you can run:
# Preview all node_modules folders and their sizes
find ~/Projects ~/Desktop -name "node_modules" -type d -prune -exec du -sh '{}' + 2>/dev/null | sort -hr
# Or interactively delete them using npkill
npx npkill