Which developer folders are safe to delete? A cheat sheet
Developer project folders fall into three classes. Safe folders are build output that the next build recreates. Caution folders are dependencies or environments that come back with a reinstall, which takes time and a network connection. Forbidden files — source, secrets, keys and lockfiles — cannot be recreated and should never be deleted to save space. This cheat sheet lists the common ones by stack.
Safe: rebuilds on the next compile
| Folder | Stack | Recreated by |
|---|---|---|
build | Flutter, Android, iOS, many others | The next build |
.dart_tool | Flutter / Dart | flutter pub get or the next build |
.next | Next.js | next build or next dev |
.nuxt | Nuxt | nuxt build or nuxt dev |
dist | JavaScript bundlers, Python packaging | The project's build script |
target | Rust (Cargo) | cargo build |
__pycache__ | Python | Running the code again |
android/build, android/app/build | Android, Flutter, React Native | The next Gradle build |
ios/build | Flutter, React Native | The next Xcode build |
Caution: needs a reinstall
| Folder | Stack | How to restore |
|---|---|---|
node_modules | Node / JavaScript | npm ci, pnpm install or yarn install |
Pods, ios/Pods | iOS (CocoaPods) | pod install |
.venv, venv | Python | python3 -m venv .venv, then pip install -r requirements.txt |
vendor | PHP (Composer), Go | composer install or go mod vendor |
.gradle | Android / Gradle | The next Gradle build (re-downloads and re-indexes) |
Before deleting a Python virtual environment, make sure the project has a requirements.txt, pyproject.toml or similar listing its packages. Packages installed into a venv by hand are not recorded anywhere else. Similarly, check that a vendor folder is not committed to the repository on purpose.
Forbidden: never delete to save space
- Source code and anything not in version control.
- Secrets:
.envfiles, API keys, credentials. - Signing material: Android keystores (
.jks,.keystore), Apple certificates and provisioning profiles. Losing an upload keystore can lock you out of updating an app. - Lockfiles:
package-lock.json,pnpm-lock.yaml,yarn.lock,Podfile.lock,Cargo.lock,pubspec.lock,composer.lock. They are small, and they are what makes a reinstall give you the same versions.
Global caches
Outside your projects, tool caches are shared by everything you build. They are safe to clear in the sense that they are re-downloaded, but every project pays the cost the next time it builds:
- Xcode DerivedData —
~/Library/Developer/Xcode/DerivedData(details) - Gradle caches —
~/.gradle/caches - Dart pub cache —
~/.pub-cache - npm cache —
~/.npm; pnpm store —~/Library/pnpm - CocoaPods cache —
~/Library/Caches/CocoaPods - Homebrew cache —
~/Library/Caches/Homebrew; pip cache —~/Library/Caches/pip
A safer way to delete
Moving folders to Trash rather than running rm -rf gives you a window to undo a mistake: select the folder in Trash and choose File → Put Back. And clean idle projects first; removing dependencies from the project you are working on today only means waiting for a reinstall. For the commands to find these folders across your whole disk, see how to free up disk space on a developer Mac.