Loading page...Загружаем страницу...正在加载页面...
AtlasRepo

Why your disk cleanup tool shouldn't use rm -rf

Description and use

Switching from blind rm -rf to tool‑specific clean commands prevents data loss, preserves git history, and efficiently frees disk space.

Problem

Deleting build output by name with rm -rf can accidentally remove important files, git‑tracked artifacts, or shared resources, leading to data loss and wasted rebuilds.

Outcome

Switching from blind rm -rf to tool‑specific clean commands prevents accidental data loss, preserves git history, and maintains shared caches, while still reclaiming disk space efficiently.

Workflow

  • Identify the project type and its build output directories.
  • Run the appropriate tool‑specific clean command (e.g., cargo clean, flutter clean, ./gradlew clean).
  • If the SDK is not installed, confirm the directory name is on a safe allow‑list and that deletion is intentional.
  • Execute rm -rf only after confirmation and when no git‑tracked files or shared symlinks are present.
  • Verify the directory is removed and the project rebuilds correctly.
  • Optionally use Kruftle to automate the process across nested projects.
  • Report the actual freed space after cleanup.

Evidence

This is the one that actually cost me something. Some repositories commit their build output deliberately…

Source

Running cargo clean instead of deleting target/ by hand doesn't require any cleverness on your part.

Source

  • Record date: 2026-09-10T16:04:05.493Z