Easily find and reclaim the gigabytes that Rust target/ directories eat up.
Like npkill, but for Cargo. A blazing-fast,
parallel filesystem scanner wrapped in a friendly terminal UI — list every target/
directory on your machine, see how much space each one is wasting, and wipe the ones
you don't need.
💡 The bar at the top animates while scanning, then fills in as each directory's size is computed. Sizes appear live — you don't wait for the whole scan to finish.
- ⚡ Fast — parallel, multi-threaded directory walk powered by
jwalk; target dirs are pruned mid-walk so their huge contents are never traversed. - 🎯 Accurate — only real Cargo targets (a
target/with a siblingCargo.toml) are listed. A random folder namedtargetis never touched. - 📊 Live sizing — every directory is measured the moment it's found, concurrently with the rest of the scan, with a running "reclaimable" total.
- 🖥️ Interactive TUI — built on
ratatui; navigate, multi-select, sort, and delete without leaving the terminal. - 🧵 Tunable — pick the worker-thread count with
-j/--threads. - 💽 Whole-system or scoped — scan every drive at once, or point it at a specific folder.
- 🛡️ Safe by default — deletions ask for a
y/Nconfirmation and run in the background so the UI never freezes. - 📜 Scriptable —
--listprints results as plain text for piping into other tools. - 🪟 Cross-platform — Linux, macOS, and Windows.
cargo install targkillGrab a binary for your platform from the latest release,
unpack it, and put cargo-targkill somewhere on your PATH.
cargo install --git https://github.com/M4cs/targkill
# or, from a local clone:
git clone https://github.com/M4cs/targkill && cd targkill
cargo install --path .All of these install a cargo-targkill binary, which Cargo exposes as a subcommand.
You can run it either way:
cargo targkill # via Cargo
cargo-targkill # directly (it's on your PATH)cargo targkill # no path: every drive (Windows) / your home dir (macOS, Linux)
cargo targkill ~/dev # scan a specific folder, recursively
cargo targkill ~/dev /work # scan multiple roots
cargo targkill -j 8 ~/dev # use 8 worker threads (default: one per core)
cargo targkill --list ~/dev # print results and exit (no TUI)| Option | Description |
|---|---|
[PATH...] |
Roots to scan recursively. Defaults to every drive on Windows, or your home directory on macOS/Linux. |
-j, --threads <N> |
Worker threads for scanning & sizing. 0/omitted = auto (one per core). |
-l, --list |
Print discovered dirs and sizes to stdout, then exit. Great for scripts. |
-h, --help |
Show help. |
| Key | Action |
|---|---|
↑ / ↓, j / k |
Move the cursor |
g / G |
Jump to top / bottom |
space |
Toggle selection of the current row |
a / n |
Select all / select none |
s |
Cycle sort order — size → name → age |
d / Del |
Delete the selection (or current row), after a y/N confirm |
q / Esc |
Quit |
Directories ≥ 1 GiB are highlighted so the big wins jump out.
- Discover. A parallel
jwalktraversal visits the tree. Whenever a directory contains aCargo.toml, itstarget/child is recorded as a candidate and the walker is told not to descend into it — so the (potentially massive) build artifacts are never walked..gitdirectories are skipped entirely for speed. - Size. The instant a candidate is found, a sizing task is dispatched onto a separate thread pool. Sizes stream back into the UI as they complete, independent of the ongoing discovery walk.
- Delete. Selected directories are removed with
std::fs::remove_dir_allon a background thread, so even multi-gigabyte deletes keep the interface responsive.
Discovery and sizing run on independent multi-threaded pools, so a slow size computation never stalls discovery, and vice-versa.
⚠️ targkillperforms a permanent delete — there is no recycle bin / trash. Deleting atarget/is harmless (Cargo regenerates it on the next build), but double-check the path before confirming.
git clone https://github.com/M4cs/targkill
cd targkill
cargo build --release # binary at target/release/cargo-targkillRequires a recent stable Rust toolchain (rustup recommended).
Issues and pull requests are welcome! CI runs rustfmt, clippy -D warnings, and the
test suite across Linux, macOS, and Windows — please run cargo fmt and
cargo clippy --all-targets -- -D warnings before opening a PR.
