A tool to clean up project dependency directories, Docker resources, and free up disk space.
- π Automatically scan various dependency directories (node_modules, venv, target, etc.)
- π Display size of each directory, sorted by size
- π Dry-run mode: Preview what will be deleted without actually deleting
- π Size threshold: Only process directories larger than specified size
- π Configurable depth: Adjust scan depth for deeply nested projects
- π³ Docker cleanup: Clean images, containers, volumes, and build cache
- π Safe confirmation: Interactive confirmation to prevent accidental deletion
- π Colorful output, clear and readable
- π» Cross-platform: Works on macOS and Linux
| Type | Directories |
|---|---|
| Node.js | node_modules, .next, .nuxt, .turbo, storybook-static, coverage |
| Python | .venv, venv, env, __pycache__, .pytest_cache, .mypy_cache, .ruff_cache, .tox |
| Rust | target |
| Tauri | src-tauri/target, src-tauri/gen, src-tauri/WixTools |
| Java/Kotlin | build, .gradle |
| Go | bin, vendor |
| .NET | bin, obj |
| General | dist, dist-ssr, out, .cache, .parcel-cache |
dclear --docker cleans the following Docker resources:
| Resource | Description | Safety |
|---|---|---|
| Dangling Images | Untagged intermediate images from builds | β Safe |
| Stopped Containers | Exited containers no longer running | β Safe |
| Unused Volumes | Volume data not attached to any container | |
| Build Cache | Docker build cache | β Safe |
curl -fsSL https://raw.githubusercontent.com/bingryan/dependencies-clear/main/install.sh | sudo bashOr with wget:
wget -qO- https://raw.githubusercontent.com/bingryan/dependencies-clear/main/install.sh | sudo bashClone the repository and run the install script:
git clone https://github.com/bingryan/dependencies-clear.git
cd dependencies-clear
./install.shThis will install both dclear and dclear-docker to /usr/local/bin or /usr/bin.
# Clean project dependencies
dclear # Scan current directory with interactive confirmation
dclear ~/projects # Scan specified directory
# Clean Docker resources only
dclear --only-docker # Skip directory scan, only clean Docker# Directory cleanup options
dclear -h # Show help
dclear -d # Dry-run mode (preview only)
dclear -s 100 # Only process directories > 100MB
dclear -y # Auto confirm without interaction
dclear -s 50 -y # Auto delete directories > 50MB
dclear ~/code -d -s 100 # Preview directories > 100MB in ~/code
dclear -m 7 ~/projects # Scan up to 7 levels deep (default: 5)
# Docker cleanup options
dclear --docker # Clean dependencies + Docker resources
dclear --docker -y # Auto-confirm all cleanups
dclear -d --docker # Preview Docker cleanup only
dclear --only-docker # Only clean Docker (skip directory scan)
dclear --only-docker -y # Clean Docker only, auto-confirm
dclear ~/projects --docker -y # Full cleanup with auto-confirm| Option | Description |
|---|---|
-h, --help |
Show help message |
-d, --dry-run |
Preview mode, only show what will be deleted |
-y, --yes |
Auto confirm without interaction |
-s N, --size N |
Only process directories larger than N MB |
-m N, --maxdepth N |
Maximum directory depth to scan (default: 5) |
--docker |
Also clean up Docker resources after directory cleanup |
--only-docker |
Only clean Docker resources, skip directory scanning |
--no-parallel |
Disable parallel size calculation |
Scan directory: /Users/xxx/projects
Size threshold: 0MB
Max depth: 5
π Scanning for dependency directories...
π Calculating directory sizes...
============================================
Directories to Clean
============================================
Size Path
--------------------------------------------
2.3GB /Users/xxx/projects/app1/node_modules
856.2MB /Users/xxx/projects/app2/target
324.5MB /Users/xxx/projects/app3/.venv
--------------------------------------------
3.5GB Total
============================================
Confirm deletion of all directories above? [y/N]: y
ποΈ Deleting...
β 2.3GB - /Users/xxx/projects/app1/node_modules
β 856.2MB - /Users/xxx/projects/app2/target
β 324.5MB - /Users/xxx/projects/app3/.venv
============================================
Space freed: 3.5GB
Successfully deleted: 3 directories
============================================
## Scan Depth Explained
The script uses `-maxdepth` to control how deep it scans. The default is **5 levels**.
Level 1: ~/work/ Level 2: ~/work/company-a/ Level 3: ~/work/company-a/project-1/ Level 4: ~/work/company-a/project-1/frontend/ Level 5: ~/work/company-a/project-1/frontend/node_modules/ β detected with default Level 6: (deeper nesting) Level 7: ~/work/company/team/product/web/app/node_modules/ β use -m 7
**When to increase depth:**
```shell
# Your projects are deeply nested
dclear -m 7 ~/work
# Only scan immediate subdirectories
dclear -m 2 ~/projects
-
Dangling Images - Intermediate build layers without tags
- Safe to remove
- Usually created during
docker build
-
Stopped Containers - Containers in "Exited" state
- Safe to remove
- Data in volumes is preserved
-
Unused Volumes - Not attached to any container
β οΈ Review before deleting- May contain important data
-
Build Cache - Docker builder cache
- Safe to remove
- Will slow down future builds slightly
Docker cleanup happens in this order (important for dependencies):
- Remove dangling images
- Remove stopped containers
- Remove unused volumes (after containers are gone)
- Remove build cache
Always use dry-run first to see what would be deleted:
dclear --only-docker -d # Preview Docker cleanup
dclear -d # Preview directory cleanup
dclear --docker -d # Preview both- Always use
-dfirst: Preview what will be deleted before actually deleting - Interactive confirmation: Required by default to prevent accidental deletion
- Nested directories skipped: Automatically skips nested dependency directories (e.g., node_modules inside node_modules)
- Size threshold: Use
-sto avoid deleting small directories - Docker volumes: Review the list before confirming - volumes may contain important data
- macOS: Fully supported (uses
du -skfor compatibility) - Linux: Fully supported
- bash 3.2+: Compatible with older bash versions
- Docker: Optional - only needed for
--dockerflag or--only-docker
For more granular Docker cleanup control, use the included dclear-docker script:
cp dclear-docker /usr/local/bin/# Clean specific resources
dclear-docker images # Remove dangling images (safe intermediate layers)
dclear-docker images -a # Remove all unused images (not just dangling)
dclear-docker containers # Remove stopped containers
dclear-docker volumes # Remove unused volumes (uses --all flag)
dclear-docker networks # Remove unused networks
dclear-docker cache # Clean build cache
dclear-docker all # Clean everything (images, containers, volumes, networks)
dclear-docker system # Docker system prune (comprehensive cleanup)
# Options
dclear-docker -d images # Preview what would be deleted
dclear-docker -y containers # Auto-confirm without prompting
dclear-docker -d -a images # Preview removing all unused images| Feature | dclear --docker |
dclear-docker |
|---|---|---|
| Scope | Part of dclear workflow | Standalone tool |
| Images cleaned | Dangling only | Dangling or all (with -a) |
| Volumes | Uses --all flag |
Uses --all flag |
| Interactive | Step-by-step prompts | Per-command confirmation |
# Preview first
dclear-docker -d all
# Actually clean
dclear-docker all -yMIT