Free up disk space on a developer’s Mac
Short answer: on a developer’s Mac the space usually goes to build caches (Xcode DerivedData, Rust target), dependencies (node_modules, package caches), simulators, Docker images and local AI models. Clear each with its own tool where one exists, and move the rest to the Trash once you know what it is.
Every command below only removes caches or data its tool can recreate or re-download. Read what each one does before running it, and close the related app first.
See where it’s going first
A scan beats guessing. DiskTree colours folders by kind, with separate colours for code, toolchains, caches, git data and AI-agent scratch space, so a 30 GB DerivedData or a forgotten node_modules stands out. Exploring is free.
See exactly what’s using your space
DiskTree is free to download and explore. For Apple silicon Macs, macOS 11 or later.
Or, in Terminal: du -h -d 1 ~/Library/Developer 2>/dev/null | sort -h
Xcode and simulators
- DerivedData (
~/Library/Developer/Xcode/DerivedData) is a build cache. For one project use Product → Clean Build Folder; to clear it all, quit Xcode and move the DerivedData folder to the Trash. Xcode rebuilds it. - Simulators (
~/Library/Developer/CoreSimulator). Remove simulators for runtimes you no longer have withxcrun simctl delete unavailable. List installed simulator runtimes withxcrun simctl runtime listand remove old ones in Xcode’s settings. - Device support files (
~/Library/Developer/Xcode/iOS DeviceSupport) hold symbols for each OS version of devices you’ve connected. Old versions are safe to remove; Xcode recreates them when you connect a device again. - Archives (
~/Library/Developer/Xcode/Archives). Keep the ones you might need to read crash reports from shipped builds.
JavaScript
node_modules: delete it in projects you’re not working on;npm install(or your package manager) restores it.- npm cache:
npm cache clean --force - pnpm store:
pnpm store pruneremoves packages no project uses. - Yarn cache:
yarn cache clean - Build output such as
.next,.turboanddistfolders is regenerated by your next build.
Rust, Python, Java and Homebrew
- Rust:
cargo cleanin a project removes itstargetfolder. - Python:
pip cache purge; with conda,conda clean --all. - Gradle:
~/.gradle/cachesis re-downloaded as needed. Remove it only when no builds are running. - Homebrew:
brew cleanupremoves old versions and old downloads;brew cleanup --prune=allclears the whole download cache.
Docker
Docker Desktop keeps every image, container and volume in one large disk image, so it doesn’t shrink when you delete files inside containers. See what’s using space with docker system df, then remove stopped containers, unused networks, dangling images and build cache with docker system prune. Add --volumes only if you’re sure you don’t need the data in unused volumes. docker builder prune clears just the build cache.
Local AI models and coding agents
- Ollama:
ollama listshows downloaded models and their sizes;ollama rm <model>removes one. - LM Studio: remove models from its model manager.
- Agent worktrees and scratch space: coding agents can leave git worktrees and experiments behind, often in folders such as
.claude,.codexor.cursoror a project’sworktreesfolder.git worktree listshows a repository’s worktrees,git worktree remove <path>removes one cleanly, andgit worktree prunetidies records of ones already deleted.
Before you clear anything
- Commit or push work in progress; a worktree or project folder may hold changes that exist nowhere else.
- Check that a package or model can be downloaded again, especially on slow or metered connections.
- Prefer each tool’s own cleanup command to deleting its folders by hand.