My laptop ran out of space again. Not from photos or videos. From build output.
A target/ in every Rust crate. A node_modules/ in every web project. A build/ and .dart_tool/ in every Flutter app. None of it matters, and all of it comes back the next time I build. One scan of my code folder found 21.5 GB across 8 projects.
The bash script that missed half of it
For a while I used a small script. Walk the code folder, find a project marker (Cargo.toml, pubspec.yaml, package.json), run the clean command, move on.
The problem was "move on". The script stopped at the first marker it found. My Flutter apps have a Rust crate inside them (rust/, for native code). The script ran flutter clean on the app and never looked inside. The crate's target/ folder sat there, often bigger than the whole app.
That is not Flutter's fault. flutter clean should not touch a folder it does not own. The gap was in my script.
Why not just rm -rf?
Because guessing is how people lose work.
- Some repos commit their
build/folder. Delete it and a rebuild will not bring it back. - A folder called
targetis not always Cargo's. - A symlink can point somewhere you really did not mean to delete.
cargo clean knows which files are Cargo's. A shell glob does not.
What I built
So I wrote Kruftle, a small open source desktop app (Windows, macOS, Linux). It:
- Scans a folder and finds every project, including projects nested inside other projects.
- Works out what each one is built with (50 toolchains: cargo, flutter, gradle, maven, go, dotnet, swift, mix and more) and whether that SDK is installed.
- Shows a dry run with a real measurement of what would be freed.
- Runs each toolchain's own clean command, in parallel, and reports what was actually freed.
It only deletes a folder outright when the SDK is not installed, the folder name is on a per-toolchain allow list, and you tick a box for that run. It skips anything git tracks, never follows symlinks, and refuses to run on / or your home folder.
On that first scan it got back 18.4 GB of the 21.5 GB. The rest was in projects whose SDK I did not have, so it asked first.
What I learned
- The big folders are rarely where you expect. The nested ones were the worst.
- "Dry run, then measure what really happened" builds more trust than any warning dialog.
- Users of a cleanup tool give you one chance. Every safety rule above came from thinking about the one time it goes wrong.
Code and downloads: https://github.com/dizitart/kruftle?utm_source=devto&utm_medium=community
How do you clean old build folders today: a script, a tool, or just wait for the disk full warning?

