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.tomlorcleanerconfig.toml - Simple command
cleaner presetsto 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)node—node_modules,.next,.nuxt,.svelte-kit,.vite,dist,build, logs, etc.rust—target,coveragego—bin,build,dist,coverage,coverage.outjava—target,build,out,.gradle, compiled.class/.jar/.war/.eardotnet—bin,obj,.vs,TestResults,artifacts,coveragephp—vendor,var/cache,var/log,bootstrap/cache,*.logruby—vendor/bundle,.bundle,coverage,tmp,pkg,log/*.logswift—DerivedData,.build,.swiftpm,*.xcworkspace/xcuserdata/**android—build,.gradle,app/build,.cxx,captureslatex— all common intermediate files (*.aux,*.log,*.toc, …)haskell—dist,dist-newstyle,.stack-work,coverageelixir—_build,deps,coveransible—*.retryc_cpp—build,bin,obj,CMakeFiles,Debug,Release,.o/.so/.dll/.exeartifactsunity—Library,Temp,Build,Logs,Objunreal—Binaries,DerivedDataCache,Intermediate,Saved/Logsos—.DS_Store,Thumbs.db,desktop.ini
Project configuration
CLI_Cleaner searches for configs upwards from the current directory in:
pyproject.tomlcleanerconfig.toml
Merge order (lowest → highest priority):
- Built-in presets
pyproject.tomlcleanerconfig.toml- 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
--deleteto actually remove files. - If no
--dirs,--files,--globs, and no--usepreset → 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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c40de8a71fe29e3f0941ccd21fdbef8de992aaa0763515936b9dfad94b1f69a4
|
|
| MD5 |
8597a625a3bf936d38cf587705b04eae
|
|
| BLAKE2b-256 |
3e1c1e12b6250dcfd13620c57174ee6f9d00b9058fc71fc49df4db186dde1dfb
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
023897a037c0fb66fa652cafe16061dd9e385597859fc092819522a932db61dc
|
|
| MD5 |
dd8043dfb191638fc96ca1a3ca30816f
|
|
| BLAKE2b-256 |
1a94989f5a2b7073259fd014f42b93d66adb6a9e2f6b6fcdfd4d5bf1a6e73cca
|