Overview
Thesweep command recursively scans for heavy dependency folders and deletes them. By default, it shows an interactive multi-select interface so you can choose exactly which folders to remove.
This is the primary cleanup command for freeing up disk space across multiple projects.
Usage
Flags
Root path to scan. Defaults to the current directory. Scans recursively through all subdirectories.
Reinstall packages after removing their folders. After deletion, shows another interactive selection to choose which projects to reinstall.
Skip interactive selection and delete/reinstall all found folders immediately. Use with caution.
Display help information for the sweep command.
Examples
Interactive Sweep (Default)
Scan and choose which folders to delete:enter, the selected folders are deleted:
Sweep with Reinstall
Delete folders and choose which to reinstall:Sweep Without Interactive Selection
Delete all found folders immediately (old behavior):Sweep Specific Directory
Scan and sweep a specific path:Sweep and Reinstall All (No Prompts)
Combine flags for full automation:Interactive Selection Shortcuts
When the interactive multi-select interface appears, use these keyboard shortcuts:| Key | Action |
|---|---|
↑ / k | Move cursor up |
↓ / j | Move cursor down |
g | Go to first item |
G | Go to last item |
space | Toggle selection of current item |
a | Select all items |
n | Deselect all items |
i | Invert selection |
enter | Confirm selection and proceed |
q / esc | Cancel and exit |
? | Toggle help display |
How Sweep Works
- Scans recursively - Walks through the directory tree looking for dependency folders
- Calculates sizes - Concurrently measures folder sizes using goroutines (max 20 concurrent operations)
- Shows selection UI - Presents an interactive list (unless
--no-selectis used) - Deletes concurrently - Removes selected folders in parallel for speed
- Reinstalls if requested - Shows another selection UI for which projects to reinstall
Common Use Cases
Clean Up Development Machine
Free up disk space across all your projects:Bulk Cleanup with Selective Reinstall
Clean everything but only reinstall active projects:Archive Old Projects
Before archiving projects, remove their dependencies:Clean Before Backup
Reduce backup size by removing dependency folders:CI/CD Cache Cleanup
In automated scripts, use--no-select for non-interactive cleanup:
Performance
- Concurrent deletion - Multiple folders are deleted simultaneously for speed
- Atomic operations - Thread-safe accumulation of deleted space using atomic operations
- Smart path skipping - Automatically ignores system folders and caches
- Error handling - Continues processing even if individual deletions fail
Safety Features
Sweep only removes known dependency folders (node_modules, target, .venv, etc.). Your source code and other files are never touched.
- Interactive selection by default - You choose what gets deleted
- Smart folder detection - Only removes recognized dependency/build folders
- Concurrent safe - Uses mutexes and atomic operations to prevent race conditions
- Graceful error handling - Shows errors but continues with remaining deletions
- Skips system paths - Automatically ignores
.git,.cache, system folders
Related Commands
list- Preview what sweep will find (dry-run)prune- Smart cleanup based on staleness scorerepair- Fix corrupted dependencies instead of deleting- Default mode - Refresh a single project directory