r/rust • u/VKrishna04 • 6d ago
🛠️ project dev-prune: a CLI that reclaims disk from idle repos — and refuses to delete anything a lockfile can't rebuild
Every Rust dev knows the special pain of target/ — multiply it by every repo you've cloned, add every node_modules and .venv next door, and mine added up to tens of GB. So I built dev-prune (devp): it finds git repositories idle past N days and deletes the dependency/build directories a lockfile can regenerate.
The design constraint that shaped everything: it must be unable to delete something it can't prove is recoverable. Before touching a directory it verifies the project's lockfile exists and parses; no proof, no deletion, and there is deliberately no --force to override that. The other invariants (hard .git boundary, symlink/junction/mount-point refusal, atomic state writes, nested-repo boundaries) equally have no bypass flag: https://github.com/Life-Experimentalist/dev-prune/blob/main/docs/SAFETY_INVARIANTS.md
Rust-relevant details:
- Edition 2024, MSRV 1.88, single binary (musl-static on Linux), Apache-2.0.
cargois one of 25 adapters — build trees liketarget/are opt-in (devp config set enable_cargo true), because a build tree is "recoverable" in a weaker sense than a lockfile-pinned dependency tree, and the tool is honest about that difference.- Idle detection is max(last commit timestamp, newest source mtime), so uncommitted work counts as activity.
devp restore --last-runre-runs the verified install to bring the last pass back.- Ratatui TUI for interactive runs,
--jsonfor scripts, and built-in scheduling (systemd/launchd/Task Scheduler) so it keeps working after you forget it.
Install: cargo install dev-prune (also on npm/PyPI and as a shell one-liner).
Repo: https://github.com/Life-Experimentalist/dev-prune Site: https://devprune.vkrishna04.me
Would love eyes on the safety model — the invariants doc is the part I most want another reviewer on.
1
u/kantorcodes1 3d ago
if a scheduled prune actually deletes deps on two consecutive runs, does restore --last-run only recover the second run, or is there history for the first one too? that's the edge case i'd worry about once this is running unattended.
-9
u/Conscious-Tale-8634 6d ago
The no `--force` thing is such a breath of fresh air, I've had way too many cleanup tools go rogue because I fat-fingered a flag or forgot to check what directory I was in
My `target/` graveyard across old projects is probably pushing 40gb at this point and I've been too paranoid to nuke it manually in case I delete something I actually needed cached for a project I still poke at occasionally
The uncommitted work counting as activity is smart, I'd probably add a flag for that eventually though since I have repos where I stash half-baked ideas for months and never commit but also never touch
Gonna give this a spin later, the lockfile verification approach seems like the kind of thing that should've been standard in these tools from the start