disk-space-optimizer
Skill75 starsChanged 4 months agoMITView on GitHub
Purpose: Intelligently free disk space by removing build artifacts, caches, and stale repositories without affecting active development. Scope: Analyze disk usage, identify safe cleanup targets, preserve active projects, and report freed space. This skill helps manage constrained disk space by: 1. Diagnosing current usage hotspots 2. Identifying artifacts that can be safely removed (caches, builds, stale repos) 3. Preserving all active projects and development environments 4. Reporting what was freed and what remains Safe to use: Does NOT delete source…
- Reads credentials
- Deletes or force-pushes
In this repository59 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- skills/heygen-skills/CLAUDE.mdCLAUDE.md
- 1passwordSkill
- ask-curlSkill
- boardSkill
- cleanup-unused-filesSkill
- codeflow-maintainerSkill
- codex-session-managerSkill
- coven-astraSkill
- coven-board-entrySkill
- coven-charmSkill
- coven-cloud-maintainerSkill
- coven-codySkill
- coven-echoSkill
- coven-identity-canonSkill
- coven-kittySkill
- coven-parallel-workSkill
- coven-sageSkill
- coven-task-managerSkill
- daily-dev-agenticSkill
- discrawlSkill
- epubSkill
- familiar-board-stewardshipSkill
- heygen-avatarSkill
- heygen-videoSkill
- heygen-skillsSkill
- higgsfield-generateSkill
- higgsfieldSkill
- linear-issue-managementSkill
- lit-ui-designerSkill
- lobsterSkill
- maintainer-barSkill
- memory-recallSkill
- memory-timeline-managerSkill
- ml-engineerSkill
- nodriverSkill
- ocrSkill
- openclaw-devSkill
- openclaw-trustSkill
- opencoven-designSkill
- OpenCoven Role Creation ProcessSkill
- pr-agentSkill
- project-managerSkill
- prompt-engineerSkill
- prompt-vaultSkill
- research-ingestionSkill
- ritual-dapp-frontendSkill
- rollcallSkill
- security-agentSkill
- skill-scannerSkill
- slidev-deck-pipelineSkill
- tauri-apple-releaseSkill
- threejs-animationSkill
- tinyfish-agent-runSkill
- tinyfish-browserSkill
- tinyfish-fetchSkill
- tinyfish-searchSkill
- tinyfishSkill
The file
We split this skill into the rules it gives an agent
7 rules. About 0 are common, 4 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈4
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 14
Preserving: all active projects and development environments
- Very specific: line 17
Safe to use: Does NOT delete source code, .git history, or active project dependencies.
- Distinctive: line 99
>20 commits/month: Keep all artifacts (likely active)
- Distinctive: line 227
After cleanup, generate a report:
- Very specific: line 281
Run du -sh ~/Documents/GitHub/* — if all repos are <500 MB, cleanup is done
- Very specific: line 282
Check df -h ~ — if >80% of space is system files (outside home), not applicable here
- Distinctive: line 283
Run full diagnostic again to find new hotspots
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
SKILL.md: Disk Space Optimization
Purpose: Intelligently free disk space by removing build artifacts, caches, and stale repositories without affecting active development.
Scope: Analyze disk usage, identify safe cleanup targets, preserve active projects, and report freed space.
Overview
This skill helps manage constrained disk space by:
- Diagnosing current usage hotspots
- Identifying artifacts that can be safely removed (caches, builds, stale repos)
- Preserving all active projects and development environments
- Reporting what was freed and what remains
Safe to use: Does NOT delete source code, .git history, or active project dependencies.
Usage
# Full diagnosis and cleanup
openclaw skill disk-space-optimizer analyze --aggressive
openclaw skill disk-space-optimizer cleanup --exclude="active,important"
# Report only (no changes)
openclaw skill disk-space-optimizer report
# Verify what's safe to delete
openclaw skill disk-space-optimizer candidates --days=30Core Procedures
1. Diagnosis: Identify Hotspots
Goal: Find what's consuming space, categorized by age and type.
# Overall disk usage
df -h ~
# Largest directories by category
du -sh ~/.npm ~/.cache ~/.openclaw/workspace ~/Documents/GitHub 2>/dev/null | sort -rh
# Repository sizes
cd ~/Documents/GitHub && for dir in */; do
du -sh "$dir" 2>/dev/null
done | sort -rh
# Build artifacts (largest by far)
find ~/Documents/GitHub -maxdepth 3 -type d \( -name ".next" -o -name "target" -o -name "build" -o -name "dist" \) -exec du -sh {} \; 2>/dev/null | sort -rh
# Git repositories by activity
cd ~/Documents/GitHub && find . -maxdepth 2 -name ".git" -type d | while read d; do
repo=$(dirname "$d")
commits=$(git -C "$repo" log --oneline --since='7 days ago' 2>/dev/null | wc -l)
size=$(du -sh "$d" 2>/dev/null | cut -f1)
echo "$commits commits | $size | $repo"
done | sort -rn2. Categorize by Safety
Safe to Remove (auto-regenerate):
~/.npm/— npm cache~/.cache/zig,~/.cache/puppeteer,~/.cache/cmux, etc. — dev tool cachesrepo/.next/— Next.js build (in stale repos, <1 commit/7 days)repo/target/— Rust build (in stale repos)repo/build/,repo/dist/— Build artifacts (in inactive repos)repo/node_modules/— Dependencies (in stale repos only)
Dangerous (DO NOT REMOVE):
.git/directories (history loss)node_modules/in active repos- Source code files
.envor config files
3. Activity Check (Key Decision Point)
For each candidate, check:
# Last commit
git -C repo log --oneline --since='30 days ago' | wc -l
# Current status
git -C repo status
# Recent file modifications
find repo -type f -newer <7-day-marker> 2>/dev/null | wc -lDecision:
- >20 commits/month: Keep all artifacts (likely active)
- 1-20 commits/month: Safe to remove
.next,dist, but keepnode_modules - 0 commits/month: Safe to remove entirely or all build artifacts
4. Safe Cleanup Procedures
A. Clear npm Cache
# Size check
du -sh ~/.npm
# Clean
npm cache clean --force
# Or atomic remove
rm -rf ~/.npm && echo "✓ npm cache cleared"Impact: ~10-15 GB freed. Auto-recreates on next npm install.
B. Clear Dev Tool Caches
# List
du -sh ~/.cache/* | sort -rh
# Remove unpopular ones
rm -rf ~/.cache/zig ~/.cache/puppeteer ~/.cache/cmux ~/.cache/uv ~/.cache/pre-commit
# Keep high-use ones
# - ~/.cache/codex-runtimes (active, >500 MB)
# - ~/.cache/node (frequent)
# - ~/.cache/gh (CLI)Impact: ~2-3 GB freed. Caches regenerate on next use.
C. Remove Stale Build Artifacts
# Find candidates (no commits in 30 days)
cd ~/Documents/GitHub
for repo in */; do
commits=$(git -C "$repo" log --oneline --since='30 days ago' 2>/dev/null | wc -l)
if [ "$commits" -eq 0 ]; then
echo "STALE: $repo"
# Show size of build dirs
du -sh "$repo/.next" "$repo/target" "$repo/build" 2>/dev/null | sort -rh
fi
done
# Remove ONLY from confirmed stale repos
rm -rf repo-name/.next repo-name/target repo-name/buildImpact: Highly variable (50 MB - 10 GB depending on repo).
D. Remove Stale node_modules
# From inactive repos only (0 commits in 30 days)
cd ~/Documents/GitHub
for repo in */; do
commits=$(git -C "$repo" log --oneline --since='30 days ago' 2>/dev/null | wc -l)
if [ "$commits" -eq 0 ]; then
if [ -d "$repo/node_modules" ]; then
rm -rf "$repo/node_modules"
echo "✓ Removed $repo/node_modules"
fi
fi
doneImpact: 500 MB - 2 GB per repo. Regenerates with pnpm install.
E. Archive or Remove Entire Stale Repos
# Only if repo hasn't been touched in 60+ days AND is not in active roadmap
git -C repo log --oneline | head -1 # Last commit info
rm -rf repo # Only if truly obsolete
# Or keep but move to archive
mv repo ~/Archive/repo-nameImpact: Varies by repo size (10 MB - 100 MB typical).
Decision Matrix
| Scenario | Action | Impact |
| Disk >98%, urgent | Clear npm cache + dev caches | ~15 GB, immediate |
| Disk 95-97% | Remove stale .next / build artifacts | ~5-10 GB |
| Disk 90-95% | Remove stale node_modules | ~2-5 GB |
| Disk <90% | No action needed | — |
| Repo: 0 commits/60 days | Safe to archive/remove | ~50 MB - 5 GB |
| Repo: >5 commits/7 days | Keep all artifacts | — |
Verification Steps
After cleanup, verify:
# 1. Check disk space
df -h ~
# 2. Verify active repos still have node_modules
cd ~/Documents/GitHub/OpenCoven/coven-dashboard
[ -d node_modules ] && echo "✓ node_modules present" || echo "❌ Missing!"
# 3. Test a build
cd ~/Documents/GitHub/OpenCoven/coven-dashboard
pnpm build --dry-run # Or equivalent for the project
# 4. Confirm Git history is intact
git -C ~/Documents/GitHub/OpenCoven/coven-dashboard log --oneline | head -5Reporting
After cleanup, generate a report:
# Disk Cleanup Report — $(date +%Y-%m-%d)
## Before & After
- Disk usage: XXX GB (XX%) → YYY GB (YY%)
- Freed: ZZ GB
## Cleanups Performed
- npm cache: XX GB
- Dev caches: YY GB
- Build artifacts: ZZ GB
- Stale repos: AA GB
## What Was Preserved
- All active repos: ✓
- All .git history: ✓
- Active node_modules: ✓Configuration
Preserve List (always keep):
~/Documents/GitHub/OpenCoven/**(active ecosystem)~/Documents/GitHub/OpenClaw/**(core project)- Any repo with >1 commit in past 7 days
- All
.git/directories
Safe to Remove:
- Repos with 0 commits in 90+ days
.nextin repos with <1 commit/7 daystarget/in repos with <1 commit/7 days- Dev tool caches (auto-regenerate)
- npm cache (auto-regenerate)
Common Issues
"I need this build artifact back"
Solution: Rebuild. All .next, target, build, dist directories auto-regenerate on pnpm build, cargo build, etc.
"A cache was cleared but I need it"
Solution: Recreate. Next use of the tool (npm, zig, puppeteer, etc.) regenerates it.
"I accidentally removed a repo's source code"
Problem: You removed the entire repo directory (not just artifacts). This skill does NOT do that.
Solution: Restore from Git remote: git clone <repo-url>
"Cleanup didn't free much space"
Diagnosis:
- Run
du -sh ~/Documents/GitHub/*— if all repos are <500 MB, cleanup is done - Check
df -h ~— if >80% of space is system files (outside home), not applicable here - Run full diagnostic again to find new hotspots
Safety Principles
- Never delete source code — only build artifacts and caches
- Always check activity first — preserve anything recently touched
- Test after cleanup — verify active projects still build
- Keep history — all
.gitdirectories stay untouched - Report what you did — log every cleanup action for transparency
Advanced: Scheduled Cleanup
To run cleanup automatically:
# Via cron (monthly)
0 2 1 * * ~/bin/disk-cleanup.sh >> ~/logs/disk-cleanup.log 2>&1
# Via cron (on-demand with threshold)
*/30 * * * * if [ $(df ~ | tail -1 | awk '{print $5}' | sed 's/%//') -gt 95 ]; then ~/bin/disk-cleanup.sh; fiExit Codes
0— Success, cleanup performed1— Error (invalid input, permission denied, etc.)2— No action needed (disk <90%)3— User abort (cleanup requires confirmation)
Related Skills
git-maintenance— Optimize.gitdirectoriesnode-dependency-auditor— Identify unused node_modulesdocker-cleanup— Clean Docker images/containers (if applicable)
Last Updated: 2026-05-15 Tested On: macOS (MB Black) Contributed By: Nova
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

