Skip to main content

A command-line tool for safely cleaning files and directories using customizable rules and dry-run preview

Project description

CLI_Cleaner

A command-line tool for safely cleaning files and directories in your project. By default, it runs in dry-run mode (preview only, nothing deleted). Add --delete to actually remove files.

  • Beautiful output powered by rich
  • Options: --dirs, --files, --globs
  • Built-in presets for popular stacks (Python, Node, Rust, Go, Java, …)
  • Custom presets from pyproject.toml or cleanerconfig.toml
  • Simple command cleaner presets to preview all available presets

Installation

# Recommended (isolated CLI)
pipx install cli-cleaner

# Or via pip
pip install cli-cleaner

Requires Python ≥ 3.12.


Quick start

Dry run (no files deleted, only preview):

cleaner -d __pycache__ -d .pytest_cache -g "build/**" -f "notes.temp.txt"

Real deletion (⚠ irreversible):

cleaner -d __pycache__ -d .pytest_cache -g "build/**" -f "notes.temp.txt" --delete

Examples:

# delete *.pyc and __pycache__ directories (dry-run)
cleaner -g "**/*.pyc" -d __pycache__

# delete build artifacts in all subfolders
cleaner -g "build/**" -g "dist/**" --delete

# delete specific files but ignore some dirs/files
cleaner -f stray.log -f notes.temp.txt --ignore-dirs ".venv" --ignore-files stray.log --delete

Presets

List all presets (built-in + from configs):

cleaner presets

Use a preset:

# built-in Python preset
cleaner --use python

# with real deletion
cleaner --use python --delete

# combine preset + extra options
cleaner --use node -g "*.log" --ignore-dirs ".vscode" --delete

Built-in presets

Located in src/cli_cleaner/presets.toml. Available out of the box:

  • python__pycache__, .pytest_cache, *.pyc, *.pyo, *$py.class, **/*.egg-info/**, htmlcov, build, dist, etc. (ignores: .git, .hg, .svn, .idea, .vscode, venv, .venv)
  • nodenode_modules, .next, .nuxt, .svelte-kit, .vite, dist, build, logs, etc.
  • rusttarget, coverage
  • gobin, build, dist, coverage, coverage.out
  • javatarget, build, out, .gradle, compiled .class/.jar/.war/.ear
  • dotnetbin, obj, .vs, TestResults, artifacts, coverage
  • phpvendor, var/cache, var/log, bootstrap/cache, *.log
  • rubyvendor/bundle, .bundle, coverage, tmp, pkg, log/*.log
  • swiftDerivedData, .build, .swiftpm, *.xcworkspace/xcuserdata/**
  • androidbuild, .gradle, app/build, .cxx, captures
  • latex — all common intermediate files (*.aux, *.log, *.toc, …)
  • haskelldist, dist-newstyle, .stack-work, coverage
  • elixir_build, deps, cover
  • ansible*.retry
  • c_cppbuild, bin, obj, CMakeFiles, Debug, Release, .o/.so/.dll/.exe artifacts
  • unityLibrary, Temp, Build, Logs, Obj
  • unrealBinaries, DerivedDataCache, Intermediate, Saved/Logs
  • os.DS_Store, Thumbs.db, desktop.ini

Project configuration

CLI_Cleaner searches for configs upwards from the current directory in:

  1. pyproject.toml
  2. cleanerconfig.toml

Merge order (lowest → highest priority):

  1. Built-in presets
  2. pyproject.toml
  3. cleanerconfig.toml
  4. Custom file passed via --config

The last definition wins if names collide.

Example: pyproject.toml

[tool.cleaner.presets.my_python]
dirs = ["__pycache__", ".pytest_cache", "build", "dist"]
files = [".coverage", "coverage.xml"]
globs = ["**/*.pyc", "**/*.pyo", "**/*.egg-info/**"]
ignored_dirs = [".git", ".idea", ".vscode", ".venv"]
ignored_files = []

Example: cleanerconfig.toml

[tool.cleaner.presets.frontend]
dirs = ["node_modules", ".next", ".turbo", "dist", "build"]
files = [".eslintcache"]
globs = ["*.log", "*.tsbuildinfo"]
ignored_dirs = [".git", ".idea", ".vscode"]
ignored_files = []

Explicit config path

cleaner --use frontend --config "./ops/cleanerconfig.toml"

Behavior

  • Default = dry-run (safe). Use --delete to actually remove files.
  • If no --dirs, --files, --globs, and no --use preset → error:
    You must provide at least one of --dirs, --files, or --globs
    
  • Manual flags override preset values.
  • Many presets include ignored_dirs (like .git, .idea, .venv) for safety.

Typical scenarios

# Clean a Python project (dry-run)
cleaner --use python

# Clean a Python project (real deletion)
cleaner --use python --delete

# Node project + extra cleanup
cleaner --use node -g "*.log" --delete

# Custom: clean build artifacts but keep .venv
cleaner -g "build/**" -g "*.temp.*" --ignore-dirs ".venv" --delete

# Use custom preset from cleanerconfig.toml
cleaner --use frontend --delete

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

cli_cleaner-1.2.tar.gz (24.2 kB view details)

Uploaded Source

Built Distribution

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

cli_cleaner-1.2-py3-none-any.whl (9.7 kB view details)

Uploaded Python 3

File details

Details for the file cli_cleaner-1.2.tar.gz.

File metadata

  • Download URL: cli_cleaner-1.2.tar.gz
  • Upload date:
  • Size: 24.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.9

File hashes

Hashes for cli_cleaner-1.2.tar.gz
Algorithm Hash digest
SHA256 c40de8a71fe29e3f0941ccd21fdbef8de992aaa0763515936b9dfad94b1f69a4
MD5 8597a625a3bf936d38cf587705b04eae
BLAKE2b-256 3e1c1e12b6250dcfd13620c57174ee6f9d00b9058fc71fc49df4db186dde1dfb

See more details on using hashes here.

File details

Details for the file cli_cleaner-1.2-py3-none-any.whl.

File metadata

  • Download URL: cli_cleaner-1.2-py3-none-any.whl
  • Upload date:
  • Size: 9.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.9

File hashes

Hashes for cli_cleaner-1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 023897a037c0fb66fa652cafe16061dd9e385597859fc092819522a932db61dc
MD5 dd8043dfb191638fc96ca1a3ca30816f
BLAKE2b-256 1a94989f5a2b7073259fd014f42b93d66adb6a9e2f6b6fcdfd4d5bf1a6e73cca

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