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.3.tar.gz (39.1 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.3-py3-none-win_arm64.whl (774.1 kB view details)

Uploaded Python 3Windows ARM64

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

Uploaded Python 3Windows x86-64

cleard-1.0.3-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (891.8 kB view details)

Uploaded Python 3manylinux: glibc 2.17+ x86-64

cleard-1.0.3-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (856.4 kB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARM64

cleard-1.0.3-py3-none-macosx_11_0_arm64.whl (834.8 kB view details)

Uploaded Python 3macOS 11.0+ ARM64

cleard-1.0.3-py3-none-macosx_10_12_x86_64.whl (867.7 kB view details)

Uploaded Python 3macOS 10.12+ x86-64

File details

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

File metadata

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

File hashes

Hashes for cleard-1.0.3.tar.gz
Algorithm Hash digest
SHA256 68ab109cd739065c93d8489fa0f78ccdfe422b34824dce985a6c90014d474895
MD5 938d93c4ec82560e8c156acdf8ffc86a
BLAKE2b-256 0bd476946cb576764acd87dd83dc2a5ac56a5de33e146d92be9829ba7d958e91

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for cleard-1.0.3-py3-none-win_arm64.whl
Algorithm Hash digest
SHA256 cd6bf9931f0a1c81c987b1adb4fec71a1c6adfb3f4795255bf6e393b8ee45aa2
MD5 441aa76aeb9504d1fedd74b1bdb14b25
BLAKE2b-256 fd537f073074523c3c571231b6985e83af4cf6c689661c5fa448cff3e95daf12

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cleard-1.0.3-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.3-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 b75c7e9cbb24983660381ca3c2026233ada84e618df1d2fe24c844b8ac7e3e50
MD5 0e3bb5fe92fdb3f45b075ae977dc5c7b
BLAKE2b-256 27941479aaa1d20dab0953c6e94c743c673f320ad2578f3609b1c5c94995be52

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cleard-1.0.3-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 efc14b8430742cb6c724a743cbcca59135d0cab7dadd5db2ec3d732613a94f7c
MD5 4bc3707618e39bd317efcda5085d5824
BLAKE2b-256 d509d5bb13690ea897b7dc272596f54667922e3e7e9f2e7345c397ea0bc485b0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cleard-1.0.3-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 1fb189ac1fe0cf1763028a5aaf8a2d7b1018f8dfad44eec6ba5d17451e4e119a
MD5 2004673296a8ce781ba083d572c503a3
BLAKE2b-256 47fada860de0f29e892be21192600ddaf80022ff945c4a4b51206382d4b97c65

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cleard-1.0.3-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b3941f914af78053d9945a1018c01f71eb224460dd7fe6c1d2dd94efbedbcb5f
MD5 2fce0ac9eefaa3378066a435911a90cb
BLAKE2b-256 25d5071f8f90913670eeaafbbe2dcef818a8e1eee6a6b759fd5f4942c6478802

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cleard-1.0.3-py3-none-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 c8c24ac4c8113de5136b1eebd8296d14060ef85354eb185a8dd00c4ddc6f89a6
MD5 11aada4595ca1f7a4d0fd5a36733b663
BLAKE2b-256 cd7182e4148458f79b5a82640e92b76d9098b9312b8b275ecdb7b4854b961df3

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