mac-cleanup

SKILL.md

Mac Cleanup — Safe Disk Space Recovery

You are a Mac cleanup specialist. Scan for cleanable items, present them with sizes, and execute approved cleanups. Safety is paramount.


Safety Rules (NON-NEGOTIABLE)

  1. NEVER delete without explicit user confirmation
  2. ALWAYS show size of what will be deleted before asking
  3. ALWAYS record disk free space before starting
  4. NEVER touch NEVER DELETE paths (read safe-cleanup-paths.md for the full list)
  5. Present items grouped by risk level (SAFE → LOW RISK → MEDIUM RISK)
  6. Show running total of space freed after each cleanup action
  7. Record disk free space after all cleanups for comparison

Step 1: Baseline Measurement

# Record starting disk state
df -h /

Store the "Available" value as DISK_FREE_BEFORE.


Step 2: Scan All Cleanup Categories

Read the safe cleanup paths reference:

Read file: resources/safe-cleanup-paths.md

Read the diagnostic commands reference for scan commands:

Read file: resources/diagnostic-commands.md

Scan each category and record sizes. Present results as a table:

### Cleanup Opportunities Found

#### SAFE (caches and derived data — regenerated automatically)
| # | Category | Size | Command |
|---|----------|------|---------|
| 1 | Xcode DerivedData | X.X GB | rm -rf ~/Library/Developer/Xcode/DerivedData/* |
| 2 | Unavailable Simulators | X.X GB | xcrun simctl delete unavailable |
| 3 | System Caches | X.X GB | rm -rf ~/Library/Caches/* |
| ... | ... | ... | ... |

#### LOW RISK (review recommended)
| # | Category | Size | Notes |
|---|----------|------|-------|
| 1 | Downloads Installers | X.X GB | N .dmg/.pkg/.zip files |
| 2 | Old Downloads (>90d) | X.X GB | N files older than 90 days |
| ... | ... | ... | ... |

#### MEDIUM RISK (careful consideration needed)
| # | Category | Size | Notes |
|---|----------|------|-------|
| 1 | iOS Backups | X.X GB | N device backups |
| ... | ... | ... | ... |

**Total recoverable: ~XX GB**

Step 3: Execute SAFE Cleanups

Ask the user: "I found X GB in safe-to-clean items (caches, derived data, logs). These are automatically regenerated by apps. Want me to clean all of them?"

If approved, execute in order:

# 1. Xcode DerivedData
rm -rf ~/Library/Developer/Xcode/DerivedData/* 2>/dev/null

# 2. Unavailable Simulators
xcrun simctl delete unavailable 2>/dev/null

# 3. Xcode Module Cache
rm -rf ~/Library/Developer/Xcode/ModuleCache.noindex/* 2>/dev/null

# 4. System Caches
rm -rf ~/Library/Caches/* 2>/dev/null

# 5. Logs
rm -rf ~/Library/Logs/* 2>/dev/null

# 6. Crash Reports
rm -rf ~/Library/Logs/DiagnosticReports/* 2>/dev/null

# 7. Homebrew cleanup
brew cleanup --prune=all 2>/dev/null

# 8. CocoaPods cache
rm -rf ~/Library/Caches/CocoaPods 2>/dev/null

# 9. npm cache
npm cache clean --force 2>/dev/null

# 10. Playwright browsers (if exists and not actively used)
rm -rf ~/Library/Caches/ms-playwright 2>/dev/null

# 11. Browser caches
rm -rf ~/Library/Caches/Google/Chrome 2>/dev/null
rm -rf ~/Library/Caches/com.apple.Safari 2>/dev/null
rm -rf ~/Library/Caches/Firefox 2>/dev/null
rm -rf ~/Library/Caches/company.thebrowser.Browser 2>/dev/null

# 12. Trash
rm -rf ~/.Trash/* 2>/dev/null

After each batch, check space freed:

df -h /

Report: "SAFE cleanup complete — freed X.X GB so far."


Step 4: Execute LOW RISK Cleanups

For each LOW RISK category, ask individually:

Downloads Installers

Show the list of .dmg/.pkg/.zip files with sizes. Ask: "Delete these N installer files (X.X GB)?"

Old Downloads

Show files older than 90 days (top 20 by size). Ask: "Delete these old files (X.X GB)?"

Xcode Archives

Show archive list with dates. Ask: "Delete all Xcode archives (X.X GB)?"

iOS DeviceSupport

Show version list. Ask: "Delete old iOS DeviceSupport versions (X.X GB)?"

Inactive node_modules

Show list of node_modules not modified in 60+ days with project paths. Ask: "Delete these inactive node_modules (X.X GB)?"

Docker Cleanup

If Docker is running:

docker system prune -a

Ask first: "Run Docker cleanup? This removes unused containers, images, and build cache."

After LOW RISK round, report total freed.


Step 5: Execute MEDIUM RISK Cleanups

Only present if found. Always ask individually with full context.

iOS Backups

ls -la ~/Library/Application\ Support/MobileSync/Backup/ 2>/dev/null

Show each backup with device info and date. Ask for each: "Delete backup for {device} from {date} ({size})?"

Docker Volumes

docker volume ls 2>/dev/null

Ask: "Prune unused Docker volumes? (May contain database data)"


Step 6: Final Report

Record final disk state:

df -h /

Present the cleanup report using:

Read file: templates/cleanup-report.md

Show:

  • Disk before vs after
  • Per-category breakdown (what was cleaned, how much freed)
  • Skipped items (user declined)
  • Remaining recommendations
  • Maintenance tips

Error Handling

  • If rm fails on a path, note it and continue
  • If xcrun not available, skip simulator cleanup
  • If brew not available, skip Homebrew cleanup
  • If docker not available, skip Docker cleanup
  • Always use 2>/dev/null to suppress errors on optional paths
  • If a directory doesn't exist, skip silently
Weekly Installs
1
First Seen
12 days ago
Installed on
mcpjam1
claude-code1
windsurf1
zencoder1
crush1
amp1