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

Uploaded Python 3Windows ARM64

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

Uploaded Python 3Windows x86-64

cleard-1.0.1-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (892.1 kB view details)

Uploaded Python 3manylinux: glibc 2.17+ x86-64

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

Uploaded Python 3manylinux: glibc 2.17+ ARM64

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

Uploaded Python 3macOS 11.0+ ARM64

cleard-1.0.1-py3-none-macosx_10_12_x86_64.whl (867.8 kB view details)

Uploaded Python 3macOS 10.12+ x86-64

File details

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

File metadata

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

File hashes

Hashes for cleard-1.0.1.tar.gz
Algorithm Hash digest
SHA256 c27c9c5be5698fd36e3b5e80fc53dd895583a2a1b76070ed78e449a8bb525239
MD5 51f7d6a3a4f6eeeaac934ccb8dbe0d95
BLAKE2b-256 ab3b31bdecb21bebb9fb92087acf8f1f1bd9f02f3cc4d4f8ba9cf3f4dbc3a1b6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cleard-1.0.1-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.1-py3-none-win_arm64.whl
Algorithm Hash digest
SHA256 81fb7f5ac5c4c5fda0e49b9eaabac2b24f2faad31c3e7689eeac979fbbf2c128
MD5 6aa137f34659185689b7911dd7f19e9e
BLAKE2b-256 6685d1ac958aa42ed18673fdb12b53bf1787dda669087d9512c33ecf570cc004

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cleard-1.0.1-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.1-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 fbf2015a23b9e1805d1a513e870d138cf6a0cb98e9ab444bf048f231342a1317
MD5 1df6f50f8685994c1f3f579876b57c46
BLAKE2b-256 08114d914ae9f682bc6555bb3782236db6706b202b7c05c9183c545d052597d3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cleard-1.0.1-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5d52d77f94b65aa401a494ae4f7004804f8582fc86994686b5d6b38e857bb71f
MD5 c7c47c71aa70249af8404e949c8da8e1
BLAKE2b-256 9c7d324c8668cc703664b4bc79934a63bfead7ca58da1299af5e3c8187d70251

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cleard-1.0.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 17431c0d8ffafd16a9ecc0ecf6efd89b7fdfee9e8e43fb4c9c2826e5066f9a24
MD5 40f569101fa3e79e520c0d49b5b0fd0d
BLAKE2b-256 14f858cb9369637e1b9d0361743c97e1976b61a5d4bd7f1e6e890b462bbd5d29

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cleard-1.0.1-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 404c8041adf24dd62f64ed80be690716c77fe52f525b2fbf38954fbc1815b69d
MD5 b03dc6b67eeaac409137643f9439b4e3
BLAKE2b-256 627554e33f6107a869d7c4ad143eb6dd5fca0e6b954e08b5db239af96e3dc019

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cleard-1.0.1-py3-none-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 e98a5104e55a7fb47fcdaabff354d0632385d48f0830eed2589a9ef4a0782e37
MD5 9afea5862d34446015d4028fcffec8cb
BLAKE2b-256 f3cbbc88f1d34f9238648cb06ea892e8a8aff2f742e8903c775fd0ad7851f318

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