Skip to main content

Sweepito

Tests Lint Release PyPI Python 3.11+ License Ruff pre-commit

Safely clean caches and build artifacts across languages, frameworks and tools.

Why Sweepito?

Every ecosystem leaves its own clutter behind: __pycache__/, .next/, Cargo target/, Gradle build/, .terraform/, .ipynb_checkpoints/, and many more. Cleaning them by hand means remembering each tool's quirks, and the usual shortcuts are risky: rm -rf build happily deletes a committed build/ folder, and git clean -fdx removes everything untracked, including your .env.

Sweepito is one tool for all of it, built around a simple rule: it only removes paths that Git already ignores and does not track, and only when the project's own marker files prove what the folder is. A build/ directory is a candidate beside a CMakeLists.txt or pom.xml, never because of its name alone.

What you get

  • 17 technology profiles and 97 rules, detected automatically from marker files (Cargo.toml, pom.xml, package.json, ...). Repositories with several technologies and nested projects are handled per project.
  • Conservative by default. Only safe caches are cleaned. Build output is opt-in, and dependency directories such as node_modules/ need an explicit flag as well.
  • Previews you can trust. scan shows exactly what clean would remove, with sizes and the reclaimable total.
  • One config format for every language, with custom cleanup rules and profiles.
  • Git hooks: post-commit cleanup through the pre-commit framework or a native hook, silent when there is nothing to do.
  • Machine-readable output (--json) and meaningful exit codes for automation.
  • Small and cross-platform: Python 3.11+, two dependencies (pathspec, rich), with a CI matrix covering Linux, macOS and Windows.

Safety model

Guarantee How
Tracked files are never deleted Candidates come from Git's own ignore list, and tracked paths are re-checked right before deleting
Nothing outside the project Paths are resolved and confined to the project root; absolute paths and .. are rejected
Links are not followed Symlinks and Windows junctions are removed as links, never traversed
.git/ is untouched It is never a candidate
A name alone is not enough A rule needs its marker file, and generic names are anchored beside it
Risky rules are opt-in high-impact rules (dependencies, environments) never run unless you ask: --enable RULE or --risk high-impact
Not a Git repo? Refuse Override only with --no-git-check, which counts as high impact
Failures are reported Locked or protected files are listed and the run exits with code 1; nothing is forced

Built-in rules never target application data, infrastructure state (*.tfstate), secrets (.env*) or IDE settings.

Install

Requires Python 3.11 or later and Git.

pipx install sweepito          # or: uv tool install sweepito
uvx sweepito scan              # run without installing
pip install sweepito           # into the current environment

Quick start

sweepito scan                              # what would be removed (safe rules only)
sweepito scan --risk configurable          # include build output
sweepito clean                             # remove, asking first
sweepito clean --enable rust.target --yes  # also remove Cargo target/, no prompt
sweepito rules                             # list every rule and its risk
sweepito init                              # write a starter sweepito.toml

Example:

$ sweepito scan --risk configurable
Project: /home/dev/myapp   profiles: common, node, python, rust
                    Cleanup candidates
┌────────────────┬──────────────────┬──────────┬──────────────┐
│ Rule           │ Path             │     Size │ Risk         │
├────────────────┼──────────────────┼──────────┼──────────────┤
│ python.pytest  │ .pytest_cache/   │   3.2 KB │ safe         │
│ python.pycache │ src/__pycache__/ │  87.8 KB │ safe         │
│ node.next      │ web/.next/       │ 210.0 MB │ configurable │
│ rust.target    │ engine/target/   │   1.8 GB │ configurable │
└────────────────┴──────────────────┴──────────┴──────────────┘
4 candidate(s), 2.0 GB reclaimable.
Nothing deleted. Run 'sweepito clean' to remove them.

Output is rendered with Rich (tables, panels, colour). Add --json for plain machine-readable output, or --no-color to turn colour off.

Profiles

Profile Covers Rules Safe / configurable / high-impact
python Python, Django, Flask, FastAPI, pytest, Ruff, mypy, tox, coverage 13 6 / 6 / 1
node Node.js, React, Next.js, Vue, Nuxt, Angular, Vite, Svelte, Astro 15 8 / 6 / 1
node-pm npm, pnpm, Yarn, Bun project-local stores 2 0 / 1 / 1
rust Rust and Cargo 2 0 / 2 / 0
jvm Maven, Gradle, Kotlin, Spring Boot 5 1 / 4 / 0
dotnet C#, F#, ASP.NET Core 5 1 / 4 / 0
go Go modules and build tools 3 1 / 1 / 1
cpp CMake, Make, Ninja, Meson 6 1 / 5 / 0
php Composer, Laravel, Symfony 7 2 / 4 / 1
ruby Bundler, Rails, Sinatra 6 2 / 3 / 1
dart Dart and Flutter 3 0 / 3 / 0
swift Swift Package Manager, Xcode 4 0 / 3 / 1
elixir Mix and Phoenix 6 3 / 2 / 1
r R, Shiny, renv, RMarkdown 6 1 / 3 / 2
jupyter Notebooks and ML workflow outputs 5 1 / 1 / 3
terraform Terraform and Terragrunt 4 1 / 3 / 0
common OS and editor junk, generic logs (always active) 5 2 / 3 / 0

The full list of targets, markers and risk levels is in docs/profiles.md.

Risk levels

Level Behaviour
safe On by default: well-identified caches that regenerate automatically
configurable Opt-in: build output and other things that are slow to rebuild or mildly valuable
high-impact Opt-in with --enable RULE or --risk high-impact: dependencies, environments, experiment data
custom Rules you write yourself: always on, since you chose them. --risk custom runs only these

Use

Selection options work the same for scan, clean, check and report:

sweepito clean -p python -p node                       # only these profiles
sweepito clean --risk configurable -x dist/            # build output, but keep dist/
sweepito clean --enable node.modules
sweepito clean --disable python.hypothesis
sweepito scan --json | jq '.total_bytes'               # for scripts
sweepito check --quiet                                 # exit 1 if anything is left

Configuration

Create sweepito.toml (or a [tool.sweepito] table in pyproject.toml). The format is the same for every language, so non-Python projects need no pyproject.toml.

[defaults]
profiles = ["auto"]            # or ["python", "node"]
risk = "safe"                  # custom | safe | configurable | high-impact

[clean]
enable  = ["rust.target", "node.next"]
disable = ["python.hypothesis"]
exclude = ["dist/", "build/keep-me/"]   # gitignore syntax; always wins

[hook]                         # applies to hook runs only
quiet = true

[[rule]]                       # custom cleanup
id = "custom.test-output"
paths = ["test-results/", "tmp/e2e/**"]

Rules you write yourself always run and are shown as custom, so there is no risk level to choose. Precedence is command line, then config file, then profile defaults, then built-in defaults. Custom rules follow the same safety gates, so a target must still be inside the project, untracked and git-ignored (or opt out of the ignore check per rule with allow_untracked = true, which never applies to tracked files). Details are in docs/configuration.md.

Command line

Command Purpose
scan List cleanup candidates with sizes (never deletes)
clean Delete candidates (-n dry run, -y skip the prompt, --non-interactive for automation)
check Like scan, but exits 1 if candidates exist
report Reclaimable space by profile, rule and risk
profiles List the supported technologies and what detects them (--explain NAME for one)
rules List every cleanup rule and its risk (--explain RULE for one)
config show / validate Show the effective settings or validate the file
init Write a starter sweepito.toml
hook install / uninstall / status Manage the native Git hook
doctor Diagnose Git, config and hooks

Run sweepito <command> --help for every option, or read docs/cli.md.

Git hook setup

With the pre-commit framework, add to .pre-commit-config.yaml:

repos:
  - repo: https://github.com/coldsofttech/Sweepito
    rev: v0.1.0
    hooks:
      - id: sweepito-clean     # post-commit cleanup
      # - id: sweepito-scan    # report-only at pre-commit
pre-commit install --hook-type post-commit

Without the framework, run sweepito hook install (add --stage pre-commit for the report-only variant). It writes .git/hooks/post-commit, appends to an existing hook instead of replacing it, and sweepito hook uninstall removes only its own block.

Hooks read the same sweepito.toml and honour the [hook] section. A post-commit hook cannot fail a commit; if cleanup fails, it prints a message to stderr.

Output, logs and exit codes

Sweepito does not write log files. Results go to standard output and problems to standard error, so you can redirect them yourself.

  • --json prints one JSON document with the candidates, skipped paths (and why), removed and failed items, and freed bytes.
  • -v explains why paths were skipped, and -q prints nothing unless something needs attention. Hook runs are quiet when there is nothing to clean.
  • sweepito doctor shows the environment, the config in use and installed hooks.
Code Meaning
0 Success, including "nothing to clean"
1 Some items failed or were skipped (for check: candidates exist)
2 Usage or configuration error
3 Unexpected error
4 Safety refusal (not a Git repo, high-impact without the flag, no consent)
130 Interrupted

Development setup

git clone https://github.com/coldsofttech/Sweepito
cd Sweepito
uv sync                       # uses Python 3.11, the minimum supported version
uv run pre-commit install
uv run pytest -n auto
uv run ruff check . && uv run ruff format --check .

See docs/development.md and docs/architecture.md.

Documentation

CLI · Configuration · Profiles and rules · Architecture · Development · Changelog

Contributing

Contributions are welcome, especially new technologies and rules. Please read CONTRIBUTING.md first; every change keeps the safety invariants and comes with tests. Everyone taking part is expected to follow the Code of Conduct.

Security

Because Sweepito deletes files, a bug that removes tracked files, anything outside the project or follows a symlink is a security issue. Please report it privately as described in SECURITY.md and do not open a public issue.

License

MIT

Metadata

Release files for sweepito 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sweepito 0.1.0
File Size Uploaded Provenance
sweepito-0.1.0.tar.gz 89.9 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for sweepito 0.1.0
File Interpreter ABI Platform
sweepito-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 130.8 kB

Release files / sweepito-0.1.0.tar.gz

Download URL sweepito-0.1.0.tar.gz
Size 89.9 kB
Tags Source
SHA-256 checksum
How to use checksums
0ba6f85e0b2c5597917c1082ffe2321ddcccde15a5474c5cca5100a59660ed3a
BLAKE2b-256 checksum
How to use checksums
4d3788c99f0e4342125f0ca18dd5909762639d6f64bd16aec233aee87465598f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 25, 2026.

Transparency log

Release files / sweepito-0.1.0-py3-none-any.whl

Download URL sweepito-0.1.0-py3-none-any.whl
Size 40.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a8d273d4c8cfca2d9e3049772eee2c5fb5bdaa418b14c07f1e6bba6d197ca6f1
BLAKE2b-256 checksum
How to use checksums
b738aee1be389941d6eb2724507e852127c05e530607b758bb070e3097b42034
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 25, 2026.

Transparency log

Security for sweepito 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for sweepito-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 25, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page