01The rule before any cleanup
A folder such as node_modules or target rebuilds itself, provided it really is the tool’s output and not a folder you worked in. Check that Git ignores it and that your work is saved:
git check-ignore -v node_modulesgit status --shortIf git check-ignore prints nothing, the folder is not ignored: do not delete it without looking at what it contains.
02JavaScript: node_modules, npm, pnpm, Yarn
To find the heaviest node_modules in a projects folder:
find ~/Projects -name node_modules -type d -prune -exec du -sh {} +Delete those of inactive projects; an npm install (or pnpm install) rebuilds them. Global caches are cleared with:
npm cache clean --forcepnpm store pruneyarn cache clean03Rust, Python, Java
- Rust: a project’s
targetfolder quickly exceeds several GB.cargo cleandeletes it, the next build recreates it. - Python: a virtual environment (
.venv) is rebuilt fromrequirements.txtorpyproject.toml; pip’s cache is cleared withpip cache purge. - Java and Android:
~/.gradle/cachesand~/.m2/repositorydownload again on the next build, at the cost of a slower first build.
04Xcode and simulators
~/Library/Developer/Xcode/DerivedData holds intermediate builds: delete its contents with Xcode closed, it is rebuilt on the next build. Simulators for old iOS versions and device symbols are often the largest:
xcrun simctl delete unavailableFolders in ~/Library/Developer/Xcode/iOS DeviceSupport for iOS versions you no longer use can go too; they are rebuilt when a device is connected.
05Docker
Start by seeing what takes up space, then clean up step by step:
docker system dfdocker image prunedocker builder prunedocker image prune removes unnamed images with no container, docker builder prune the build cache. Avoid docker system prune -a --volumes without thinking: --volumes also erases the data of your local databases.