RESOURCES chevron_right DEVELOPER TOOLS

Clean 50GB+ of Developer Caches on macOS in 60 Seconds

person

The Dusty Team

Mac storage guides

calendar_today October 14, 2026
schedule 7 min read
bolt Quick Answer (Clean Developer Caches on Mac)

To clean 50GB+ of developer caches on Mac in 60 seconds: Run rm -rf ~/Library/Developer/Xcode/DerivedData/* to clear Xcode, docker system prune -a --volumes --force for Docker, brew cleanup -s && rm -rf $(brew --cache) for Homebrew, and use find ~/Projects -name 'node_modules' -type d -prune -mtime +60 -exec rm -rf {} + to purge stale node_modules.

If you develop software on a Mac, your solid-state drive is constantly under attack. You start with 150 GB of free space on Monday; by Thursday, you're greeted by a system alert warning that your startup disk is almost full.

Modern developer toolchains—Node.js, Docker, Xcode, Homebrew, and CocoaPods—are aggressive hoarders. They download thousands of tarballs, compile megabytes of intermediate object code, and cache virtual machine snapshots. Worse, none of these tools clean up after themselves.

In this speed-run tutorial, we will walk through a step-by-step checklist to clean node_modules mac directories and purge developer caches—reclaiming 50GB to 80GB of storage in under 60 seconds.

speed 1. The 60-Second Storage Reclamation Benchmark

Here is what typical disk reclamation looks like on an active developer MacBook after running the five cleanup steps outlined below:

Cleanup Step Cache Target Size Before Size After Reclaimed Execution Time
Step 1 Stale node_modules (>60 days old) 38.4 GB 0 GB +38.4 GB ~15 sec
Step 2 Xcode DerivedData & Simulators 24.1 GB 0.2 GB +23.9 GB ~6 sec
Step 3 Docker Containers & BuildKit Cache 18.5 GB 1.8 GB +16.7 GB ~18 sec
Step 4 Homebrew Downloaded Bottles 8.2 GB 0 GB +8.2 GB ~5 sec
Step 5 CocoaPods, NPM, & Yarn Caches 6.7 GB 0.4 GB +6.3 GB ~8 sec
TOTAL All Toolchains Combined 95.9 GB 2.4 GB +93.5 GB ~52 sec

Let's break down each step with the exact Terminal commands.

folder_delete 2. Step 1: Purge Orphaned node_modules (~30GB)

JavaScript dependency trees are notorious for consuming immense disk capacity. A single React or Next.js project's node_modules folder frequently weighs between 600MB and 2.5GB, containing over 50,000 loose files. If you have 25 legacy client projects, tutorials, or abandoned feature branches sitting in your ~/Projects directory, you are wasting 30GB to 50GB on duplicated code. (Read our deep dive: What is node_modules? Safe to Delete?)

1. Audit your largest node_modules folders

Before deleting anything, inspect where your heaviest JavaScript dependencies live:

find ~/Projects -name "node_modules" -type d -prune -exec du -sh {} + 2>/dev/null | sort -hr | head -n 10

2. Safely purge stale node_modules

To safely clean node_modules mac dependencies without disrupting projects you're actively working on, target folders whose parent directories have not been modified in the last 60 days:

find ~/Projects -name "node_modules" -type d -prune -mtime +60 -exec rm -rf {} +

💡 Tip: Deleting node_modules is non-destructive. If you return to an older project in the future, running npm install, pnpm install, or yarn will faithfully restore all dependencies in seconds based on your lockfile.

developer_mode 3. Step 2: Flush Xcode DerivedData (~20GB)

Whenever you compile an iOS, macOS, watchOS, or cross-platform Flutter/React Native application, Xcode writes intermediate compilation objects, index stores, and module maps into DerivedData. (See our complete guide on how to clear Xcode DerivedData.)

Xcode never purges old projects. If you compiled a test build six months ago, its 8GB compilation cache is still taking up space.

1. Wipe DerivedData

Run this one-liner to instantly clear all intermediate build artifacts:

rm -rf ~/Library/Developer/Xcode/DerivedData/*

2. Delete unavailable iOS simulators

When Xcode updates, old simulator runtimes and orphaned cache references linger:

xcrun simctl delete unavailable

Xcode will cleanly regenerate whatever indexes and symbols it needs when you next open your active workspace.

layers 4. Step 3: Prune Docker Containers (~15GB)

On macOS, Docker runs inside an APFS virtual disk image (Docker.raw). As you pull base images (such as Ubuntu, Node, Golang, or Postgres) and build multi-stage Dockerfiles, Docker Desktop's build cache and dangling layers expand rapidly. Learn more in our guide to clean Docker disk space on Mac.

1. Check Docker disk consumption

docker system df

2. Execute a full prune

Reclaim stopped containers, unused networks, untagged images, and build caches:

docker system prune -a --volumes --force

3. Clear BuildKit cache

Docker BuildKit preserves intermediate compilation layers for fast rebuilds:

docker builder prune -a --force

This immediately frees gigabytes within the Docker storage engine.

auto_awesome Reclaimed 50GB? Check What Else Is Silently Eating Your Mac

Deleting developer caches is only step one. macOS quietly hoards another 20GB–50GB across hidden system logs, messaging archives (WhatsApp media), and uninstalled application leftovers.

Unlike legacy cleaner subscriptions, Dusty is a native, privacy-first Swift utility that uses connected AI to explain every single file before you delete it. Pay once ($7.99 lifetime), own it forever.

local_cafe 5. Step 4: Clear Homebrew Caches (~8GB)

Every time you execute brew install or brew upgrade, Homebrew downloads pre-compiled binary packages called "bottles" and stores them in your user cache: ~/Library/Caches/Homebrew. (Read our complete walkthrough: Clean Homebrew Cache on Mac.)

Unless you manually trigger cleanup, Homebrew keeps stale formula versions and outdated tarballs.

1. Clear stale packages and source downloads

brew cleanup -s

The -s flag strips download caches for all installed formulae and casks.

2. Flush raw Homebrew cache directory

rm -rf $(brew --cache)

Homebrew continues working flawlessly, and your local package cache is reset to zero bytes.

cached 6. Step 5: Flush CocoaPods/NPM/Yarn (~6GB)

Package managers keep local download caches so repeated installs don't hit remote registries. Over time, these global stores become bloated with outdated package tarballs.

1. Clean CocoaPods cache (iOS / React Native / Flutter)

pod cache clean --all

2. Clean NPM global cache

npm cache clean --force

3. Clean Yarn and PNPM global stores

# If using Yarn classic or Yarn Berry
yarn cache clean

# If using PNPM
pnpm store prune

terminal 7. The 60-Second Speed-Run Script

For developers who want to execute this maintenance routine in one shot, here is a combined shell script:

#!/usr/bin/env bash
echo "⚡ Cleaning developer caches..."

# 1. Clean Xcode DerivedData
rm -rf ~/Library/Developer/Xcode/DerivedData/*
xcrun simctl delete unavailable 2>/dev/null

# 2. Prune Docker (if running)
if command -v docker &> /dev/null && docker info &> /dev/null; then
  docker system prune -a --volumes --force
  docker builder prune -a --force
fi

# 3. Clean Homebrew
if command -v brew &> /dev/null; then
  brew cleanup -s
  rm -rf $(brew --cache)
fi

# 4. Clean Package Managers
command -v pod &> /dev/null && pod cache clean --all
command -v npm &> /dev/null && npm cache clean --force
command -v yarn &> /dev/null && yarn cache clean --all 2>/dev/null
command -v pnpm &> /dev/null && pnpm store prune 2>/dev/null

echo "✅ Dev caches flushed successfully!"
warning The Hidden Danger of Running Raw Shell Scripts

While terminal one-liners are fast, maintaining your machine with raw rm -rf scripts carries real risks:

  • Zero Undo Safety: A misplaced path in a recursive script can wipe active worktrees, uncommitted Git branches, or critical .env files.
  • Missing Visibility: Terminal scripts are blind. They don't tell you what an obscure 15GB folder in ~/Library/Caches does before wiping it.
  • No Coverage for App Bloat: Terminal scripts leave behind WhatsApp video caches, Electron caches, and leftover application support files from uninstalled apps.

auto_awesome 8. Automate Developer Cache Cleanup with Dusty

Running out of SSD space disrupts your development flow, halts Docker builds, and degrades macOS swap memory performance. If you want the speed of terminal cleanups without the risk of breaking your dev environment, use Dusty for Mac.

Dusty is a native macOS storage management utility built specifically for developers using Swift and SwiftUI. It automatically discovers stale node_modules, Xcode DerivedData, Docker overlays, and CocoaPods caches across all your internal and external drives. Powered by connected Gemini AI, Dusty explains the exact purpose and deletion safety of every cache folder, routing all cleanups safely to the macOS Trash so you can restore any file instantly with ⌘Z.