If you're a developer working on a Mac, you've probably seen the dreaded "Your disk is almost full" notification. Between Xcode's DerivedData, scattered node_modules folders, Docker images, and various package manager caches, developer tools can silently consume 50 to 500 GB of your disk space.

This guide covers every major cache and build artifact location on macOS, with exact commands to check sizes and clean them safely. Whether you're on a 256GB MacBook Air or a 1TB MacBook Pro, these steps will help you reclaim significant space.

1. Xcode DerivedData (10-80 GB)

Xcode stores build artifacts, indexes, and logs in the DerivedData folder. If you work on multiple projects or switch branches frequently, this folder grows quickly.

Check the size

du -sh ~/Library/Developer/Xcode/DerivedData

It's common to see 20-80 GB here, especially if you've been developing for a while.

Clean it

# Delete all DerivedData (safe -- Xcode rebuilds what it needs)
rm -rf ~/Library/Developer/Xcode/DerivedData/*
Tip: This is completely safe. Xcode will rebuild DerivedData for any project you open. The only downside is a slightly longer first build after cleaning.

Also check Xcode caches

# Xcode cache folder
du -sh ~/Library/Caches/com.apple.dt.Xcode

# Clean it
rm -rf ~/Library/Caches/com.apple.dt.Xcode/*

2. node_modules Folders (5-100 GB)

node_modules is famously heavy. Each Node.js project has its own copy of all dependencies, and they add up fast. A single React project can have a 500MB+ node_modules folder.

Find all node_modules and their sizes

# Find all node_modules folders, sorted by size
find ~ -name "node_modules" -type d -prune 2>/dev/null | while read dir; do
    echo "$(du -sh "$dir" 2>/dev/null | cut -f1)\t$dir"
done | sort -hr | head -20

Clean old project node_modules

# Delete node_modules from projects you haven't touched in 30+ days
find ~/Projects -name "node_modules" -type d -prune \
    -newer <(date -v-30d +%Y%m%d) -exec rm -rf {} + 2>/dev/null
Note: After deleting node_modules, you'll need to run npm install or yarn install in that project directory before building again.

Also clean the npm/yarn global cache:

# npm cache
du -sh ~/.npm
npm cache clean --force

# yarn cache
du -sh ~/Library/Caches/Yarn
yarn cache clean

# pnpm cache
du -sh ~/Library/pnpm/store
pnpm store prune

3. Docker Images & Containers (10-50 GB)

Docker Desktop for Mac stores images, containers, volumes, and build cache in a single disk image. This can grow to enormous sizes.

Check Docker disk usage

docker system df

Clean up Docker

# Remove unused images, containers, networks, and build cache
docker system prune -a

# Also remove unused volumes (be careful -- this deletes data)
docker system prune -a --volumes

The Docker Desktop VM disk image is located at:

du -sh ~/Library/Containers/com.docker.docker/Data/vms/
Tip: Even after pruning, Docker's disk image might not shrink immediately. Restarting Docker Desktop can help reclaim space.

4. Homebrew Cache (1-10 GB)

Homebrew keeps downloaded packages and old versions in its cache directory.

# Check size
du -sh $(brew --cache)

# Clean all cached downloads
brew cleanup -s

# Remove all cached downloads (aggressive)
rm -rf $(brew --cache)/*

5. pip Cache (1-5 GB)

Python's pip stores downloaded packages in a cache directory.

# Check size
du -sh ~/Library/Caches/pip

# Clean pip cache
pip cache purge

# Or manually
rm -rf ~/Library/Caches/pip/*

If you use conda:

# Check conda package cache
du -sh ~/miniconda3/pkgs  # or ~/anaconda3/pkgs

# Clean conda
conda clean --all

6. CocoaPods Cache (1-10 GB)

CocoaPods caches pod specs and downloaded pods.

# Check size
du -sh ~/Library/Caches/CocoaPods

# Clean cache
pod cache clean --all

# Also clean specs repo
rm -rf ~/.cocoapods/repos/trunk

7. Rust/Cargo Target Directories (5-50 GB)

Rust compilation artifacts are stored in target/ directories within each project. Debug builds are especially large.

# Find all Cargo target directories
find ~ -name "target" -type d -path "*/target" 2>/dev/null | while read dir; do
    if [ -f "$dir/../Cargo.toml" ]; then
        echo "$(du -sh "$dir" 2>/dev/null | cut -f1)\t$dir"
    fi
done | sort -hr | head -20
# Clean a specific project's build artifacts
cd your-rust-project
cargo clean

# Cargo's global registry cache
du -sh ~/.cargo/registry
du -sh ~/.cargo/git

8. Gradle Cache (2-20 GB)

If you do Android development or use Gradle-based Java/Kotlin projects:

# Check Gradle cache size
du -sh ~/.gradle/caches

# Clean Gradle caches
rm -rf ~/.gradle/caches/*

# Android build caches
du -sh ~/.android/cache
rm -rf ~/.android/cache/*

9. Xcode Archives & Simulators (5-50 GB)

Xcode archives (from Product > Archive) and iOS Simulators can consume massive space.

# Check archives
du -sh ~/Library/Developer/Xcode/Archives

# Check iOS Simulator data
du -sh ~/Library/Developer/CoreSimulator

# Delete old simulators
xcrun simctl delete unavailable

# Delete ALL simulator data (aggressive)
rm -rf ~/Library/Developer/CoreSimulator/Devices/*

10. Other Hidden Space Eaters

Composer (PHP)

du -sh ~/.composer/cache
rm -rf ~/.composer/cache/*

Maven (Java)

du -sh ~/.m2/repository
# Be selective -- delete specific old versions

Go modules

du -sh ~/go/pkg/mod
go clean -modcache

Ruby gems

du -sh ~/.gem
gem cleanup

Swift Package Manager

du -sh ~/Library/Developer/Xcode/DerivedData/*/SourcePackages
du -sh ~/Library/org.swift.swiftpm

VS Code extensions cache

du -sh ~/.vscode/extensions

Trash

# Don't forget to empty the Trash!
du -sh ~/.Trash
# Empty it from terminal
rm -rf ~/.Trash/*

Quick Reference: All Locations

Cache Type Location Typical Size
Xcode DerivedData ~/Library/Developer/Xcode/DerivedData 10-80 GB
node_modules Each project directory 5-100 GB total
Docker ~/Library/Containers/com.docker.docker 10-50 GB
Homebrew $(brew --cache) 1-10 GB
pip ~/Library/Caches/pip 1-5 GB
CocoaPods ~/Library/Caches/CocoaPods 1-10 GB
Cargo targets */target/ in Rust projects 5-50 GB
Gradle ~/.gradle/caches 2-20 GB
Xcode Archives ~/Library/Developer/Xcode/Archives 2-30 GB
iOS Simulators ~/Library/Developer/CoreSimulator 5-40 GB
Go modules ~/go/pkg/mod 1-10 GB
npm/yarn cache ~/.npm / ~/Library/Caches/Yarn 1-5 GB

The Automated Approach

Running all these commands manually is tedious and error-prone. You need to remember paths, check sizes, and be careful not to delete the wrong things.

ClearDisk -- Clean All Caches Automatically

Free, open-source macOS menu bar app that finds and visualizes all your developer caches in one place. One-click cleanup for Xcode, npm, Docker, pip, CocoaPods, Cargo, Homebrew, and more.

Get ClearDisk (Free)

ClearDisk is a free, open-source macOS menu bar app built with SwiftUI that handles all of the above automatically:

Install via Homebrew

brew tap bysiber/cleardisk
brew install --cask cleardisk

Or download the latest .dmg from the releases page.

How Often Should You Clean?

It depends on your workflow, but here's a general guideline:

Pro tip: Having ClearDisk in your menu bar makes it easy to check cache sizes at a glance and clean when needed -- no commands to remember.

Summary

Developer caches are the #1 hidden space consumer on a developer's Mac. Between Xcode, npm, Docker, and other tools, it's common to have 50-200 GB of reclaimable space without even realizing it.

The key locations to monitor are:

  1. ~/Library/Developer/Xcode/DerivedData -- usually the biggest offender
  2. Scattered node_modules folders -- they add up fast across projects
  3. Docker images and build cache -- grows silently in the background
  4. Package manager caches (Homebrew, pip, CocoaPods, Cargo)

Whether you clean manually with the commands above or use a tool like ClearDisk to automate it, regular cache maintenance keeps your Mac fast and your disk healthy.