Skip to main content

Interactive, multi-ecosystem build-artifact disk reclaimer (npkill, but for everything)

Project description

cleard

crates.io npm PyPI GitHub release CI License: MIT

npkill, but for everything — an interactive terminal tool that finds regenerable build / dependency / cache directories across many ecosystems and lets you delete them to reclaim disk space.

It recursively scans a directory, streams matches into a live list sorted by size, and deletes the ones you pick — with a running total of space reclaimed.

Why it's safe

Unlike a plain name match, cleard is marker-aware: an ambiguous directory is only flagged when its project marker is a sibling. target/ is only a candidate when a Cargo.toml (or pom.xml) sits next to it; a hand-written build/ source folder with no build-system marker is left untouched. Unambiguous names (node_modules, __pycache__, .terraform, …) need no marker.

Deletion is bounded to the scan root and always asks for confirmation.

Supported out of the box

Node (node_modules, .next, .nuxt, .svelte-kit, .turbo), Rust (target), Java/Gradle/Maven (build, .gradle, target), Python (.venv, venv, __pycache__, .pytest_cache, .mypy_cache, .ruff_cache, *.egg-info), Go & PHP (vendor), .NET (bin, obj), CocoaPods (Pods), Terraform (.terraform), Elixir (_build, deps), Elm (elm-stuff), Dart/Flutter (.dart_tool). Extendable via config.

Install

cleard ships one binary through whichever ecosystem you already use — npm, PyPI, and the curl script all deliver the same prebuilt binary; Cargo and Nix build from source.

cargo install cleard                       # crates.io (compiles from source)
npm install -g @ervan0707/cleard           # prebuilt binary via npm
pip install cleard                         # prebuilt binary in a Python wheel
curl -fsSL https://raw.githubusercontent.com/ervan0707/cleard/main/install.sh | bash
nix profile install github:ervan0707/cleard

Run

With Nix flakes, run it straight from GitHub (nothing to clone, no Rust needed):

# run once against a directory
nix run github:ervan0707/cleard -- ~/code

# run the current directory
nix run github:ervan0707/cleard

# pin a tag/branch/commit
nix run github:ervan0707/cleard/v0.1.0 -- ~/code

Install it into your profile:

nix profile install github:ervan0707/cleard
cleard ~/code

Binary cache (skip the build)

CI publishes prebuilt outputs to Cachix, so you can download the binary instead of compiling Rust. The flake advertises the cache via nixConfig, which Nix uses automatically if you're a trusted user. Otherwise, opt in once:

cachix use skinnyvans

Or add it to your Nix config by hand:

substituters = https://skinnyvans.cachix.org
trusted-public-keys = skinnyvans.cachix.org-1:sgaZPgRhzsU4YScjc2U5Imc+4E3y9Ov/G/q8p/csX+o=

Or add it to your own flake:

{
  inputs.cleard.url = "github:ervan0707/cleard";
  # then use cleard.packages.${system}.default in your outputs
}

Don't have Nix? Build from source with Cargo:

git clone https://github.com/ervan0707/cleard
cd cleard
cargo build --release   # binary at ./target/release/cleard

Usage

cleard                 # scan the current directory
cleard ~/code          # scan a specific directory
cleard --dry-run       # show what would be reclaimed, delete nothing
cleard --min-size 100M # hide candidates smaller than 100 MiB
cleard -x .git -x dist # skip directories by name

Keys

Key Action
/k, /j move cursor
g / G top / bottom
space toggle selection
a / c select all / clear selection
d / Del delete selected (or focused)
Enter delete focused
s cycle sort (size / age / path)
/ filter by path or ecosystem
? help
q quit

Config

Optional, at ~/.config/cleard/config.toml (or pass --config <path>). Use it to add your own detection rules, or to replace the built-in catalog entirely. If the file doesn't exist, the built-in rules are used.

Each rule has:

  • ecosystem — the label shown in the list.
  • dir_names — directory names to match.
  • markers — sibling files that must exist for a match. With markers, the dir is only flagged when one sits next to it (so a hand-written zig-out/ with no build.zig is left alone). Omit markers to match the name anywhere ("safe by name") — only do that for unambiguous names.

dir_names and markers accept a single * glob (e.g. *.csproj, *.egg-info). Your rules are checked before the built-ins, so they win on overlapping names.

Add a few ecosystems on top of the built-ins:

# use_default_rules = true   # default; keep the built-in catalog

[[rules]]
ecosystem = "Zig"
dir_names = ["zig-cache", "zig-out"]
markers = ["build.zig"]

[[rules]]
ecosystem = "Bazel"
dir_names = ["bazel-bin", "bazel-out", "bazel-testlogs"]
markers = ["WORKSPACE", "WORKSPACE.bazel", "MODULE.bazel"]

[[rules]]
ecosystem = "CMake"
dir_names = ["CMakeFiles"]   # unambiguous name, no marker needed

Or replace the built-ins entirely and clean only what you list:

use_default_rules = false

[[rules]]
ecosystem = "Node"
dir_names = ["node_modules"]

[[rules]]
ecosystem = "Rust"
dir_names = ["target"]
markers = ["Cargo.toml"]

Develop (Nix)

nix develop          # dev shell with the pinned Rust toolchain + rust-analyzer
cargo run -- ./path
cargo test

nix build            # build the release binary -> ./result/bin/cleard
nix run . -- ~/code  # build and run

(With direnv, direnv allow loads the dev shell automatically.)

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cleard-1.0.2.tar.gz (39.0 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

cleard-1.0.2-py3-none-win_arm64.whl (774.4 kB view details)

Uploaded Python 3Windows ARM64

cleard-1.0.2-py3-none-win_amd64.whl (805.6 kB view details)

Uploaded Python 3Windows x86-64

cleard-1.0.2-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (891.7 kB view details)

Uploaded Python 3manylinux: glibc 2.17+ x86-64

cleard-1.0.2-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (856.3 kB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARM64

cleard-1.0.2-py3-none-macosx_11_0_arm64.whl (834.9 kB view details)

Uploaded Python 3macOS 11.0+ ARM64

cleard-1.0.2-py3-none-macosx_10_12_x86_64.whl (867.9 kB view details)

Uploaded Python 3macOS 10.12+ x86-64

File details

Details for the file cleard-1.0.2.tar.gz.

File metadata

  • Download URL: cleard-1.0.2.tar.gz
  • Upload date:
  • Size: 39.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.14.1

File hashes

Hashes for cleard-1.0.2.tar.gz
Algorithm Hash digest
SHA256 2db8a89ea7f014a28201a92447bf199353a6a48aaa5a10bdee8aece011e9d5dd
MD5 17f2a13cdd748e054054d983da3cbc00
BLAKE2b-256 4347cb2a8377a1f9182078be106fe82f972d53b2809708642c1e2b3e0cf3fa00

See more details on using hashes here.

File details

Details for the file cleard-1.0.2-py3-none-win_arm64.whl.

File metadata

  • Download URL: cleard-1.0.2-py3-none-win_arm64.whl
  • Upload date:
  • Size: 774.4 kB
  • Tags: Python 3, Windows ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.14.1

File hashes

Hashes for cleard-1.0.2-py3-none-win_arm64.whl
Algorithm Hash digest
SHA256 e2736f9cc2d7621b926f2578b348dca72a411199859a09c97cca7bd09c7ef194
MD5 aaafab526c05e16340b6870a3c96c1fa
BLAKE2b-256 f98d93ad3cc1b5a0a94a02baffc204f2cd7971a3b2bd841d0468292a3f81c584

See more details on using hashes here.

File details

Details for the file cleard-1.0.2-py3-none-win_amd64.whl.

File metadata

  • Download URL: cleard-1.0.2-py3-none-win_amd64.whl
  • Upload date:
  • Size: 805.6 kB
  • Tags: Python 3, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.14.1

File hashes

Hashes for cleard-1.0.2-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 307e37eb808cc066fa2534d8354b87f312985dbbd1bf517cbb45a50af2c16cab
MD5 603a0480b8aaa513df5b3e1c2261a7ed
BLAKE2b-256 22a11b360bcf714b6975e991f916f13f4cbbf5e612e90b09c3ff0970dd05cd7c

See more details on using hashes here.

File details

Details for the file cleard-1.0.2-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for cleard-1.0.2-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 3653ec53c67a3e730a32c3b77620e1508b82b4102a13035604c8f08c3b1a2a15
MD5 7e2c114ab8cfb8c399e76dd1989ce6e6
BLAKE2b-256 4c97b7e9c599156e6f9e6d555c501e25e706c850668580447d2c20cc6eb6e44d

See more details on using hashes here.

File details

Details for the file cleard-1.0.2-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for cleard-1.0.2-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 7c0c476dfcf3464cefaf2275ae454a041c485d0752ed2e0514ecc5cde8588d24
MD5 a328b5c94604bdeb8d40c04dc87bae4f
BLAKE2b-256 0c5beba15a05881d57e7bb3423e0ffeb856d0bfb73e2b51a1aad59a021820ed7

See more details on using hashes here.

File details

Details for the file cleard-1.0.2-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for cleard-1.0.2-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d66e31ec0576e3c0c7ae8a33bd38d6942abb017cf5c830cd34f0012d9dcfae67
MD5 7c46c184b4be42c1df88aecce9648a22
BLAKE2b-256 9e6dcbcf60ee20cddc0679f29b6ba341c01173d243a3d11abe215a81c7883da0

See more details on using hashes here.

File details

Details for the file cleard-1.0.2-py3-none-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for cleard-1.0.2-py3-none-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 694f683d5967d1c1c2f0a773b8f367c0f452cb05106a43ac616c32ae1b26fdc5
MD5 6128b28e8ed98bc7215127ac9758b32e
BLAKE2b-256 25eafb4b58d533272044bc0a94bcd3f585e4436389f35268bc234d2e26590272

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page