| name | onezion-workspace-cleanup |
| description | Scan and clean up bloated WorkBuddy workspaces. Uses dust/dua CLI for fast disk analysis. Identifies large files (videos, node_modules, .venv, build artifacts), generates a report, and optionally removes them with user confirmation. Trigger on: "清理工作区", "磁盘不够了", "workspace cleanup", "free up space", "工作区膨胀", "node_modules 太大". |
Workspace Cleanup Skill
Scan WorkBuddy workspaces for bloated directories and large files, generate a report, and optionally clean them up.
CLI Tools (pre-installed)
| Tool | Purpose | Install |
|---|
dust | Tree map view of disk usage, top-N biggest items | brew install dust |
dua | Fast parallel disk usage analyzer, supports batch delete | brew install dua-cli |
du | macOS built-in, fallback | built-in |
df | Filesystem-level space check | built-in |
Step 1: Disk overview
df -h /
du -sh ~/WorkBuddy/ 2>/dev/null
du -sh ~/WorkBuddy/*/ 2>/dev/null | sort -rh | head -20
Step 2: Visual scan with dust
dust -n 20 ~/WorkBuddy/
dust -n 15 ~/WorkBuddy/<workspace-id>/
Step 3: Deep scan — find the usual suspects
find ~/WorkBuddy -type f -size +50M -exec ls -lh {} \; 2>/dev/null | sort -k5 -rh
find ~/WorkBuddy -name "node_modules" -type d -exec du -sh {} \; 2>/dev/null | sort -rh
find ~/WorkBuddy -name ".venv" -type d -exec du -sh {} \; 2>/dev/null | sort -rh
find ~/WorkBuddy \( -name ".next" -o -name "dist" -o -name "build" -o -name "__pycache__" -o -name ".pytest_cache" \) -type d -exec du -sh {} \; 2>/dev/null | sort -rh
find ~/WorkBuddy \( -name "*.mov" -o -name "*.mp4" -o -name "*.avi" -o -name "*.mkv" \) -exec ls -lh {} \; 2>/dev/null | sort -k5 -rh
Step 4: Generate report
Present findings to the user in a clear table:
- File path (relative to ~/WorkBuddy)
- Size
- Type (video / node_modules / venv / build artifact / other)
- Recommended action (delete / move to external SSD / keep)
Step 5: Confirm before any cleanup
NEVER delete without user confirmation. Use AskUserQuestion to let the user select which items to clean.
For each confirmed item:
- Videos (.mov, .mp4): Move to trash via
osascript -e 'tell application "Finder" to delete POSIX file "PATH"'
- node_modules:
rm -rf (can always be regenerated with npm install or pnpm install)
- .venv:
rm -rf (can be regenerated with python3 -m venv .venv)
- Build artifacts (.next, dist, build, pycache):
rm -rf (regenerated on next build)
- Entire completed workspaces:
tar czf to external SSD first, then trash
Step 6: Post-cleanup verification
df -h /
du -sh ~/WorkBuddy/
dust -n 10 ~/WorkBuddy/
Automation suggestion
If the user wants ongoing management, suggest creating an automation that runs this scan weekly:
- Schedule: weekly on Sunday
- Action: scan and report only (never auto-delete)
Key rules
- Always scan first, act second. Never skip the report.
- Always confirm before deletion. List every file path.
- Prefer trash over rm. Use
osascript Finder delete for user files.
- node_modules and .venv are safe to delete — they're reproducible.
- Videos are the #1 space killer. Always check for .mov and .mp4 files first.
- Never touch project source code, configs, or .git directories without explicit approval.
- Use
dust for quick visual scans, dua for detailed per-directory analysis, du as fallback.