| Crates.io | clean-dev-dirs |
| lib.rs | clean-dev-dirs |
| version | 2.2.0 |
| created_at | 2025-05-30 18:21:45.463129+00 |
| updated_at | 2025-10-30 21:00:35.143277+00 |
| description | A fast CLI tool for recursively cleaning Rust target/ and Node.js node_modules/ directories to reclaim disk space |
| homepage | https://github.com/TomPlanche/clean-dev-dirs |
| repository | https://github.com/TomPlanche/clean-dev-dirs |
| max_upload_size | |
| id | 1695497 |
| size | 180,134 |
A fast and efficient CLI tool for recursively cleaning Rust
target/, Node.jsnode_modules/, Python cache, and Govendor/directories to reclaim disk space.
# Install from crates.io
cargo install clean-dev-dirs
# Clean all development directories in current directory
clean-dev-dirs
# Preview what would be cleaned (dry run)
clean-dev-dirs --dry-run
# Interactive mode - choose which projects to clean
clean-dev-dirs --interactive
target/), Node.js (node_modules/), Python (cache dirs), and Go (vendor/) build artifactsThis project is inspired by cargo-clean-all, a Rust-specific tool for cleaning cargo projects. We've improved upon the original concept with:
cargo install clean-dev-dirs
git clone https://github.com/TomPlanche/clean-dev-dirs.git
cd clean-dev-dirs
cargo install --path .
# Clean all development directories in the current directory
clean-dev-dirs
# Clean a specific directory
clean-dev-dirs ~/Projects
# Preview what would be cleaned (dry run)
clean-dev-dirs --dry-run
# Interactive mode - choose which projects to clean
clean-dev-dirs --interactive
# Clean only Rust projects
clean-dev-dirs --project-type rust
# or use short flag
clean-dev-dirs -p rust
# Clean only Node.js projects
clean-dev-dirs -p node
# Clean only Python projects
clean-dev-dirs -p python
# Clean only Go projects
clean-dev-dirs -p go
# Clean all project types (default)
clean-dev-dirs -p all
# Only clean projects with build dirs larger than 100MB
clean-dev-dirs --keep-size 100MB
# Only clean projects not modified in the last 30 days
clean-dev-dirs --keep-days 30
# Combine size and time filters
clean-dev-dirs --keep-size 50MB --keep-days 7
# Use 8 threads for faster scanning
clean-dev-dirs --threads 8
# Show verbose output including scan errors
clean-dev-dirs --verbose
# Skip specific directories during scanning
clean-dev-dirs --skip node_modules --skip .git
# Non-interactive mode (auto-confirm)
clean-dev-dirs --yes
# Keep compiled executables (preserves binaries while cleaning build artifacts)
clean-dev-dirs --keep-executables
# Combine multiple options
clean-dev-dirs ~/Projects -p rust --keep-size 100MB --keep-days 30 --dry-run
1. Clean old Rust projects:
clean-dev-dirs ~/Projects -p rust --keep-days 90
2. Preview large Python cache directories:
clean-dev-dirs ~/workspace -p python --keep-size 50MB --dry-run
3. Interactive cleaning of all Node.js projects:
clean-dev-dirs ~/dev -p node --interactive
4. Quick cleanup with confirmation:
clean-dev-dirs ~/code --keep-size 100MB --keep-days 60
5. Fast scan with multiple threads:
clean-dev-dirs /large/directory --threads 16 --verbose
6. Clean while preserving executables:
clean-dev-dirs ~/rust-projects -p rust --keep-executables
| Argument | Description |
|---|---|
[DIR] |
Directory to search for projects (default: current directory) |
| Option | Short | Values | Description |
|---|---|---|---|
--project-type |
-p |
all, rust, node, python, go |
Filter by project type (default: all) |
| Option | Short | Description |
|---|---|---|
--keep-size |
-s |
Ignore projects with build dir smaller than specified size |
--keep-days |
-d |
Ignore projects modified in the last N days |
| Option | Short | Description |
|---|---|---|
--yes |
-y |
Don't ask for confirmation; clean all detected projects |
--dry-run |
List cleanable projects without actually cleaning | |
--interactive |
-i |
Use interactive project selection |
--keep-executables |
-k |
Preserve compiled binaries while removing build artifacts |
| Option | Short | Description |
|---|---|---|
--threads |
-t |
Number of threads for directory scanning (default: CPU cores) |
--verbose |
-v |
Show access errors during scanning |
--skip |
Directories to skip during scanning (can be specified multiple times) |
The --keep-size option supports various size formats:
| Format | Example | Description |
|---|---|---|
| Decimal | 100KB, 1.5MB, 2GB |
Base 1000 |
| Binary | 100KiB, 1.5MiB, 2GiB |
Base 1024 |
| Bytes | 1000000 |
Raw byte count |
clean-dev-dirs --keep-size 100KB # 100 kilobytes
clean-dev-dirs --keep-size 1.5MB # 1.5 megabytes
clean-dev-dirs --keep-size 2GiB # 2 gibibytes
clean-dev-dirs --keep-size 500000 # 500,000 bytes
The tool automatically detects development projects by looking for characteristic files and directories:
Cargo.toml and target/ directory must existtarget/ directory[package] name in Cargo.tomlpackage.json and node_modules/ directory must existnode_modules/ directoryname field in package.jsonrequirements.txt, setup.py, pyproject.toml, setup.cfg, Pipfile, pipenv.lock, poetry.lock__pycache__.pytest_cachevenv / .venvbuild / dist.eggs / .tox / .coveragepyproject.toml (project name or tool.poetry name) or setup.pygo.mod and vendor/ directory must existvendor/ directorygo.modThe --keep-executables flag allows you to reclaim disk space from build artifacts while preserving your compiled binaries. This is particularly useful when:
For Rust Projects:
target/debug/ and target/release/ for executable filestarget/ directorytarget/release/my-app but removes all dependencies and intermediate artifactsFor Go Projects:
vendor/bin/ directoryFor Node.js and Python Projects:
# Clean Rust projects but keep release binaries
clean-dev-dirs ~/rust-workspace -p rust --keep-executables
# Interactive cleaning with executable preservation
clean-dev-dirs --interactive --keep-executables
# Combine with other filters
clean-dev-dirs --keep-executables --keep-days 30 --keep-size 100MB
--dry-run--interactive--keep-days and --keep-size--keep-executablesThe tool provides beautiful, colored output including:
| Icon | Project Type |
|---|---|
| ๐ฆ | Rust projects |
| ๐ฆ | Node.js projects |
| ๐ | Python projects |
| ๐น | Go projects |
Found 15 projects
๐ Found projects:
๐ฆ my-rust-app (/home/user/projects/rust-app)
Size: 2.3 GB
๐ฆ web-frontend (/home/user/projects/web-app)
Size: 856 MB
๐ ml-project (/home/user/projects/python-ml)
Size: 1.2 GB
Total space that can be reclaimed: 4.4 GB
Contributions are welcome! Please feel free to submit a Pull Request.
Want to add support for a new programming language? Here's how to extend clean-dev-dirs:
First, add your language to the ProjectType enum in src/project/project.rs:
#[derive(Clone, PartialEq, Debug)]
pub enum ProjectType {
Rust,
Node,
Python,
Go,
YourLanguage, // Add your language here
}
Don't forget to update the Display implementation to include an appropriate emoji and name.
Update src/config/filter.rs to add your language to the ProjectFilter enum:
#[derive(Clone, Copy, PartialEq, Debug, ValueEnum, Default)]
pub enum ProjectFilter {
All,
Rust,
Node,
Python,
Go,
YourLanguage, // Add here
}
Add detection logic in src/scanner.rs by implementing:
detect_your_language_project() - identifies projects by looking for characteristic filesextract_your_language_project_name() - parses project configuration files to get the namedetect_project() to call your detection methodExample detection criteria:
fn detect_your_language_project(&self, path: &Path, errors: &Arc<Mutex<Vec<String>>>) -> Option<Project> {
let config_file = path.join("your_config.conf"); // Language-specific config file
let build_dir = path.join("build"); // Build/cache directory to clean
if config_file.exists() && build_dir.exists() {
let name = self.extract_your_language_project_name(&config_file, errors);
let build_arts = BuildArtifacts {
path: build_dir,
size: 0, // Will be calculated later
};
return Some(Project::new(
ProjectType::YourLanguage,
path.to_path_buf(),
build_arts,
name,
));
}
None
}
Add any language-specific directories that should be skipped during scanning to the should_scan_entry() method in src/scanner.rs.
Consider these when testing your implementation:
Some languages that would be great additions:
CMakeLists.txt/Makefile + build/ or cmake-build-*/pom.xml/build.gradle + target/ or build/*.csproj/*.sln + bin//obj/composer.json + vendor/Gemfile + vendor/bundle/Package.swift + .build/When submitting your language support:
This project is dual-licensed under either:
You may choose either license at your option.
Built with excellent open-source libraries: