ClearCache is a high-performance cache clearing system designed specifically for development environments. Built in Rust, it provides safe, efficient, and comprehensive cache management across multiple development ecosystems including Node.js, Rust, Go, Python, Docker, and general build artifacts.
Important: ClearCache ignores .gitignore files by default since cache directories (like target/, node_modules/, __pycache__/) are often in .gitignore but should still be cleaned. Use --respect-gitignore if you want to honor .gitignore patterns.
Development environments accumulate substantial cache data over time. Node.js projects can generate gigabytes in node_modules, Rust projects create large target directories, and various build tools leave behind temporary files. Manual cleanup is time-consuming and error-prone. ClearCache solves this by providing automated, safe, and extremely fast cache management.
The system was architected to address performance limitations found in existing solutions. Through comprehensive benchmarking against Python, Go, and shell-based alternatives, ClearCache demonstrates 2-5x performance improvements while maintaining strict safety guarantees.
High-Performance Architecture: Rust-based implementation with parallel processing that scales across CPU cores. Efficient memory management and optimized file system operations deliver superior performance compared to interpreted alternatives.
Comprehensive Ecosystem Support: Native support for Node.js, Rust, Go, Python, Docker, and general development caches. Extensible pattern matching system allows for precise targeting of cache artifacts without affecting source code or configuration files.
Safety-First Design: Multiple validation layers prevent accidental deletion of critical system files or important project artifacts. Intelligent path analysis and content validation ensure only genuine cache data is targeted.
Flexible Operation Modes: Dry-run capabilities for safe preview, selective cache type targeting, recursive directory processing, and detailed reporting provide complete operational control.
Zero-Dependency Deployment: Single binary distribution with automatic symbolic link installation for global accessibility across development environments.
node_modules- Dependencies.npm- NPM cache.next- Next.js build cache.nuxt- Nuxt.js build cache.output- Nuxt.js output.yarn/cache- Yarn cache.pnpm-store- PNPM cache.turbo- Turbo build cache.parcel-cache- Parcel build cache
target- Cargo build artifactsCargo.lock- Lock files (with safety checks)
go-build- Go build cachepkg/mod- Go module cache
__pycache__- Python bytecode cache*.pyc,*.pyo- Python bytecode files.pytest_cache- Pytest cache.mypy_cache- MyPy cache.pip- Pip cache
- System cache (containers, images, volumes)
- Build cache
.cache,cache,@cache- General cache directories.temp,temp,@temp,.tmp,tmp- Temporary directoriesbuild,dist,out,.build- Build output directories*.log,logs,.log- Log files and directories
- Rust 1.70+ (install from rustup.rs)
git clone <repository-url>
cd clearcache
./install.shThe installation script will:
- Build the project in release mode
- Create a symbolic link in your PATH
- Make the
clearcachecommand available globally
cargo build --release
cp target/release/clearcache ~/.local/bin/
# or
cp target/release/clearcache /usr/local/bin/# Clean current directory (safe caches only)
clearcache
# Clean specific directory (safe caches only)
clearcache /path/to/project
# Clean recursively (all subdirectories)
clearcache --recursive
# Dry run (show what would be deleted)
clearcache --dry-run
# Include libraries/dependencies (requires reinstallation)
clearcache --include-librariesSafe Mode (Default): Cleans temporary caches that don't require reinstallation:
- Python:
__pycache__,.pytest_cache,.mypy_cache, bytecode files - Node.js:
.npm,.next,.nuxt,.turbo,.parcel-cache - Rust:
Cargo.lock(in some cases) - Go:
go-buildcache - General: build outputs, temp files, logs
Library Mode (--include-libraries): Additionally cleans dependencies requiring reinstallation:
- Node.js:
node_modules - Rust:
targetdirectories - Go:
pkg/modmodule cache
# Clean only specific cache types (safe mode)
clearcache --types node,rust
clearcache --types python,docker
# Clean with libraries included
clearcache --include-libraries --types node,rust
# Clean with verbose output
clearcache --verbose
# Clean with custom thread count
clearcache --parallel 16
# Combine options
clearcache --recursive --dry-run --verbose --types node,rust --include-librariesAvailable cache types:
node(ornodejs,npm,yarn,pnpm)rust(orcargo)go(orgolang)python(orpy,pip)dockergeneral(orcache)all(default - includes everything)
USAGE:
clearcache [OPTIONS] [DIRECTORY]
ARGS:
<DIRECTORY> Directory to clean (default: current directory)
OPTIONS:
-n, --dry-run Show what would be deleted without actually deleting
-r, --recursive Recursively clean all subdirectories
-t, --types <TYPES> Comma-separated list of cache types to clean [default: all]
-l, --include-libraries Include libraries/dependencies that require reinstallation
-p, --parallel <NUM> Number of parallel threads (default: CPU count)
-v, --verbose Verbose output
-f, --force Force deletion without confirmation
--respect-gitignore Respect .gitignore files (by default, .gitignore is ignored)
--no-ignore Ignore .clearcacheignore files
-h, --help Print help information
-V, --version Print version information
Based on comprehensive benchmarks, this Rust implementation significantly outperforms alternatives:
- 2-3x faster than Go implementations
- 4-5x faster than Python implementations
- Comparable to C implementations while being memory-safe
- Parallel processing scales with CPU cores
- Efficient memory usage with minimal allocations
- System Path Protection: Prevents deletion of critical system directories
- Important File Detection: Skips directories containing important project files
- Intelligent Git Integration: By default ignores
.gitignorefiles since cache directories are often excluded from version control but should still be cleaned. Use--respect-gitignoreto honor.gitignorepatterns. - Path Validation: Multiple checks to ensure safe deletion
- Dry Run Mode: Always test before actual deletion
- Depth Limiting: Prevents infinite recursion
π§Ή ClearCache - Extremely Efficient Cache Cleaner
Directory: /Users/dev/projects
Cache types: Node, Rust, Go, Python, Docker, General
Threads: 16
π SAFE MODE - Only cleaning temporary caches (use --include-libraries for full clean)
β Scanning directories...
Found 15 cache items to clean
Deleted: /Users/dev/project1/.next (234 files, 15.2 MB)
Deleted: /Users/dev/project2/__pycache__ (12 files, 2.1 MB)
Deleted: /Users/dev/project3/.pytest_cache (45 files, 8.3 MB)
π Summary
Files processed: 291
Space freed: 25.6 MB
Directories cleaned: 15
β
All operations completed successfully!
π§Ή ClearCache - Extremely Efficient Cache Cleaner
Directory: /Users/dev/projects
Cache types: Node, Rust, Go, Python, Docker, General
Threads: 16
π¦ LIBRARY MODE - Including dependencies that require reinstallation
β Scanning directories...
Found 23 cache items to clean
Deleted: /Users/dev/project1/node_modules [LIBRARY] (1,234 files, 45.2 MB)
Deleted: /Users/dev/project2/target [LIBRARY] (567 files, 123.4 MB)
Deleted: /Users/dev/project3/__pycache__ (12 files, 2.1 MB)
π Summary
Files processed: 1,813
Space freed: 170.7 MB
Directories cleaned: 23
β
All operations completed successfully!
The system includes comprehensive error handling:
- Permission Errors: Gracefully handles insufficient permissions
- Path Errors: Validates all paths before operations
- Concurrent Access: Handles files being modified during cleaning
- Partial Failures: Continues cleaning even if some operations fail
- Detailed Reporting: Shows exactly what succeeded and what failed
Contributions are welcome! Please feel free to submit a Pull Request.
git clone <repository-url>
cd clearcache
cargo build
cargo test- Add patterns to
src/cache_types.rs - Update the documentation
- Add tests
- Submit a PR
This project is licensed under the Griffin License - see the LICENSE file for details.
- Inspired by various cache cleaning tools in the community
- Built with the amazing Rust ecosystem
- Performance insights from benchmarking research
- cargo-cache - Rust-specific cache cleaning
- npkill - Node.js specific cleaning
- clean-cache - Go implementation
For detailed technical documentation, architecture details, and implementation notes, see the docs/ directory.
Built with Rust for Performance and Safety