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

FolderStackRecreated by
buildFlutter, Android, iOS, many othersThe next build
.dart_toolFlutter / Dartflutter pub get or the next build
.nextNext.jsnext build or next dev
.nuxtNuxtnuxt build or nuxt dev
distJavaScript bundlers, Python packagingThe project's build script
targetRust (Cargo)cargo build
__pycache__PythonRunning the code again
android/build, android/app/buildAndroid, Flutter, React NativeThe next Gradle build
ios/buildFlutter, React NativeThe next Xcode build

Caution: needs a reinstall

FolderStackHow to restore
node_modulesNode / JavaScriptnpm ci, pnpm install or yarn install
Pods, ios/PodsiOS (CocoaPods)pod install
.venv, venvPythonpython3 -m venv .venv, then pip install -r requirements.txt
vendorPHP (Composer), Gocomposer install or go mod vendor
.gradleAndroid / GradleThe 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: .env files, 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.

More guides