A fast, parallel tool to clean Rust projects and remove unused dependencies
Rust projects can accumulate gigabytes of build artifacts in target/ directories. When you have multiple projects or workspaces, manually cleaning them is tedious and time-consuming. Plus, unused dependencies bloat your Cargo.toml and slow down builds.
deepclean solves this by:
- 🚀 Cleaning multiple projects in parallel - Save time with concurrent cleaning
- 🎯 Smart workspace detection - Automatically finds all Cargo projects
- 🧹 Removes unused dependencies - Keep your
Cargo.tomlclean - ⚡ Fast and efficient - Built in Rust for maximum performance
# Clone the repository
git clone https://github.com/yingkitw/deepclean.git
cd deepclean
# Install as a cargo plugin
cargo install --path .
# Now use it!
cargo deepcleanNote: Make sure ~/.cargo/bin is in your PATH.
# Clean current directory and all subdirectories
cargo deepclean
# Clean a specific directory
cargo deepclean /path/to/projects
# Preview what would be cleaned (dry run)
cargo deepclean --dry-run
# Only clean projects above 100MB
cargo deepclean --min-size 100MB
# Check for unused dependencies
cargo deepclean --clean-deps
# Remove unused dependencies (automatically checks first)
cargo deepclean --remove-deps- ✅ Parallel processing - Clean multiple projects simultaneously
- ✅ Smart detection - Uses cargo-metadata for accurate workspace detection
- ✅ Dependency cleaning - Find and remove unused dependencies (built-in detection)
- ✅ Size filtering - Only clean projects above a certain size
- ✅ Progress bars - See what's being cleaned in real-time
- ✅ Dry-run mode - Preview changes before applying them
- ✅ Exclude patterns - Skip specific directories
- ✅ JSON output - Machine-readable output for automation
| Option | Description |
|---|---|
-j, --jobs <N> |
Number of parallel jobs (default: CPU count) |
-e, --exclude <PATTERN> |
Exclude directories matching pattern (can use multiple times) |
--dry-run |
Preview mode (doesn't actually clean) |
--min-size <SIZE> |
Only clean projects above this size (e.g., "100MB", "1GB") |
--clean-deps |
Check for unused dependencies |
--remove-deps |
Remove unused dependencies (requires cargo-remove) |
-v, --verbose |
Verbose output |
--json |
Output results as JSON |
- Rust toolchain
- Cargo
To remove unused dependencies, install cargo-edit:
cargo install cargo-editNote: Dependency detection is built-in and doesn't require external tools! The tool parses Cargo.toml and searches your source code to find unused dependencies.
cargo deepcleancargo deepclean --min-size 500MBcargo deepclean --clean-depscargo deepclean --remove-depscargo deepclean --exclude "**/target/debug" --exclude "**/node_modules"cargo deepclean -j 8- Discovery: Recursively finds all Cargo projects using
cargo-metadata - Filtering: Optionally filters by size or exclude patterns
- Cleaning: Removes
target/directories in parallel - Dependency Analysis: Parses
Cargo.tomland searches source code for unused dependencies - Removal: Uses
cargo-removeto clean up unused dependencies
deepclean is built in Rust for maximum performance:
- Parallel execution across all CPU cores
- Efficient directory traversal
- Minimal memory footprint
Contributions are welcome! Feel free to open issues or submit pull requests.
Apache-2.0