Skip to main content

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

Project description

cleard

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 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.0.tar.gz (37.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.0-py3-none-win_arm64.whl (773.1 kB view details)

Uploaded Python 3Windows ARM64

cleard-1.0.0-py3-none-win_amd64.whl (804.5 kB view details)

Uploaded Python 3Windows x86-64

cleard-1.0.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (891.0 kB view details)

Uploaded Python 3manylinux: glibc 2.17+ x86-64

cleard-1.0.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (855.2 kB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARM64

cleard-1.0.0-py3-none-macosx_11_0_arm64.whl (833.9 kB view details)

Uploaded Python 3macOS 11.0+ ARM64

cleard-1.0.0-py3-none-macosx_10_12_x86_64.whl (866.6 kB view details)

Uploaded Python 3macOS 10.12+ x86-64

File details

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

File metadata

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

File hashes

Hashes for cleard-1.0.0.tar.gz
Algorithm Hash digest
SHA256 f52f4fdfa84cd6ed62381fa4fbd2867562046e9740055bace68f33f0aedb1032
MD5 5053740e3ef5f8208940d4ff0e233d4a
BLAKE2b-256 47f7cf846fc8774bc71a595138bd9a2e07579eaac33b72e888288c020d78053a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cleard-1.0.0-py3-none-win_arm64.whl
  • Upload date:
  • Size: 773.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.0-py3-none-win_arm64.whl
Algorithm Hash digest
SHA256 5f297b847335ba328bae2834f1c4a0b048c658ab05d238a797a57db5b5e15757
MD5 6adeeccb2701e27efc9857d33526f29c
BLAKE2b-256 3c17fdafcda1ae54b6ccd9503d505c124c541d0a08f7ae515354e86daaf61c34

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cleard-1.0.0-py3-none-win_amd64.whl
  • Upload date:
  • Size: 804.5 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.0-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 fca0df69b28806410f0ac5dff5d7fc4cd88fda14bfa67eda0dd8c78e688dd964
MD5 d52dfa8d98a5607b77cf4f2922417de3
BLAKE2b-256 787512371091c6028caee76b4fb19f85c0a890b84ab3ae0f1ea4ed0ed3f162c8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cleard-1.0.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 26f6c8515b6b478874c73f5fc1765933336c068f9aaa95361d8be93eb29f46d7
MD5 ac184a0e347f411ef75627f84a2866ad
BLAKE2b-256 eb92dafc7356f7152ca4f1384dfb178d6985ff0434dee093d0b2ca35097e745b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cleard-1.0.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 340e443864f9ad9bb23e1485ee68488185a79bd2d95f2680f92923c745b75771
MD5 736dcec8e39b730da4d05a2c58337e0e
BLAKE2b-256 f688b6a4a76f79b193c22c09a15478b8ce991de9f7e232cfca60bdaa4330394a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cleard-1.0.0-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a08338b4d26dac8bf258975765df33e877481d6b90dcf86042f738b091f24c87
MD5 4221b8ba55cf40a3f641cf84318cd4e0
BLAKE2b-256 fc3f7f3edb003d33623a9f9a09386e175eba4e11a51911c66f9e60bcdef27108

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cleard-1.0.0-py3-none-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 56619224ca3b0bfdb74d75dd1ea3d8091059a5c1fa1e55e7b2698a31bad612d0
MD5 6fc5eb86f997c7d3e4d3a8a4d52e96fb
BLAKE2b-256 aef5c0d164b6912babeda42882feacabf4214f378caac19e09e960e927901ca7

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