agentleFS
andalabxandalabx/skills/clean/SKILL.md

clean

Skill2 starsChanged 3 months agoMITView on GitHub

Free up disk space by removing dev environment junk — Claude temp, OS temp, browser caches, node_modules, npm/pnpm/yarn caches, .next builds, Python caches, pip, and VS Code cache. Works on Windows, macOS, and Linux. Use "super" argument for interactive deep-clean mode that discovers hidden space hogs and asks before deleting anything.

  • Deletes or force-pushes

7 other projects use a version of this.

Adopted by

Most recently taken up by

The file

Show its rules and text

We split this skill into the rules it gives an agent

19 rules. 0 are common, 15 are distinctive, and 4 are very specific to this project.

  • 0

    Common

    Most of the 7 edited versions we read keep these.

  • 15

    Distinctive

    This author's own choices. Worth a look.

  • 4

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    If no argument is given, ask the user before doing anything:

    line 22
  2. Distinctive:

    Wait for their answer, then proceed to the matching mode below.

    line 36
  3. Distinctive:

    Run these two commands and record the values for use in every step below:

    line 48
  4. Very specific:

    Use the du result as the reported size — do not try to read output after deletion, the file may be gone.

    line 82
  5. Distinctive:

    If a browser cache path returns 0 or does not exist, note it as "not installed / not found" — do not silently skip.

    line 143
  6. Distinctive:

    Run a single combined find for all three targets.

    line 151
  7. Very specific:

    Delete all found paths: rm -rf

    line 162
  8. Distinctive:

    Do not re-run this find a second time.

    line 165
  9. Very specific:

    Add all individual du results together for the reported total.

    line 215
  10. Distinctive:

    Only print the summary after ALL steps above have completed and all results are in hand.

    line 221
  11. Very specific:

    Use the du measurements collected before each deletion as the source of truth — not disk delta, which is unreliable when operations overlap.

    line 247
  12. Distinctive:

    Run all discovery silently first.

    line 259
  13. Distinctive:

    After scanning, present a numbered list sorted by size (largest first).

    line 357
  14. Distinctive:

    Wait for the user's response before proceeding.

    line 406
  15. Distinctive:

    If the user approves items marked "Review first" for deletion, ask a follow-up before acting:

    line 412
  16. Distinctive:

    Never skip this step for "Review first" items.

    line 418
  17. Distinctive:

    Before deleting anything, show exactly what will be removed:

    line 424
  18. Distinctive:

    Wait for "yes" before deleting anything.

    line 443
  19. Distinctive:

    Delete only approved items.

    line 449

“Common” is measured: kept by at least 6 in 10 of the 7 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

/clean — Dev Environment Cleanup

Frees disk space across your dev environment. Works on Windows, macOS, and Linux.

Arguments: $ARGUMENTS

  • (none) — ask the user whether they want Quick or Super mode
  • quick — full standard cleanup, no questions asked
  • super — interactive deep-clean: discovers everything, user approves before anything is deleted

No Argument — Ask First

If no argument is given, ask the user before doing anything:

How would you like to clean?

  quick — fast cleanup of known junk (caches, temp, node_modules, builds)
          no questions, runs immediately

  super — deep scan of everything on your system, ranked by size
          you decide what goes and what stays before anything is deleted

Type "quick" or "super":

Wait for their answer, then proceed to the matching mode below.


Quick Mode (/clean quick)

Rule: always measure size BEFORE deleting. Never delete first and report after — sizes will be wrong or unavailable.


Step 0 — Detect environment

Run these two commands and record the values for use in every step below:

uname -s 2>/dev/null || echo "Windows"
echo $HOME

Resolve OS-specific variables:

  • Windows: HOME=$USERPROFILE, TMPDIR=$LOCALAPPDATA/Temp, APPDATA, LOCALAPPDATA
  • macOS: HOME=$HOME, TMPDIR=$TMPDIR
  • Linux: HOME=$HOME, TMPDIR=/tmp

Project roots to scan (use whichever exist): $HOME/Documents, $HOME/Projects, $HOME/code, $HOME/dev, current directory

Record baseline disk free now — use this exact command, once, and store the result:

df -h / 2>/dev/null || df -h "$HOME"

Step 1 — Claude temp dir

Measure size first using du, then delete contents:

# measure
du -sh "$TMPDIR/claude" 2>/dev/null || echo "0"

# delete contents only, not the directory itself
rm -rf "$TMPDIR/claude/"* 2>/dev/null

Use the du result as the reported size — do not try to read output after deletion, the file may be gone.


Step 2 — OS temp (files > 10 MB)

Measure before deleting:

# Windows — find .tmp files > 10 MB, measure total, then delete
find "$LOCALAPPDATA/Temp" -maxdepth 1 \( -name "*.tmp" -size +10M \) 2>/dev/null | xargs du -sh 2>/dev/null
find "$LOCALAPPDATA/Temp" -maxdepth 1 \( -name "*.tmp" -size +10M \) -exec rm -rf {} + 2>/dev/null

# macOS / Linux — files > 10 MB older than 7 days
find "$TMPDIR" -maxdepth 1 -size +10M -atime +7 -type f 2>/dev/null | xargs du -ch 2>/dev/null | tail -1
find "$TMPDIR" -maxdepth 1 -size +10M -atime +7 -type f -delete 2>/dev/null

Report MB freed using the du total captured before deletion.


Step 3 — Browser caches

For each browser, measure the cache dir with du -sh first, then delete contents.

Chrome

OSCache path
Windows$LOCALAPPDATA/Google/Chrome/User Data/Default/Cache
macOS$HOME/Library/Caches/Google/Chrome/Default/Cache
Linux$HOME/.config/google-chrome/Default/Cache

Also clean Code Cache and GPUCache subdirs where they exist.

Edge

OSCache path
Windows$LOCALAPPDATA/Microsoft/Edge/User Data/Default/Cache
macOS$HOME/Library/Caches/Microsoft Edge/Default/Cache
Linux$HOME/.config/microsoft-edge/Default/Cache

Firefox

Firefox on Windows stores profiles in Roaming, not Local — check both:

OSCache path
Windows$APPDATA/Mozilla/Firefox/Profiles/*/cache2 AND $LOCALAPPDATA/Mozilla/Firefox/Profiles/*/cache2
macOS$HOME/Library/Caches/Firefox/Profiles/*/cache2
Linux$HOME/.mozilla/firefox/*/cache2

Pattern for each browser:

# measure
du -sh <cache-path> 2>/dev/null

# delete contents only (not the cache dir itself)
rm -rf <cache-path>/* 2>/dev/null

If a browser cache path returns 0 or does not exist, note it as "not installed / not found" — do not silently skip.

Report MB freed per browser.


Step 4 — node_modules, .next builds, Python pycache

Run a single combined find for all three targets. Do not run three separate find commands — they will each take too long and background separately.

# Single pass: find all three target types across all project roots
find $HOME/Documents $HOME/Projects $HOME/code $HOME/dev \
  \( -name "node_modules" -o -name ".next" -o -name "__pycache__" \) \
  -type d -prune 2>/dev/null

Once the list is returned:

  1. Measure total size for each type: du -sh on each found path, group by type
  2. Delete all found paths: rm -rf
  3. Report count and MB freed per type

Do not re-run this find a second time. Use the results from this single pass for both measurement and deletion.


Step 5 — npm / pnpm / yarn cache

Measure each cache before clearing:

# npm
du -sh "$(npm config get cache 2>/dev/null)" 2>/dev/null
npm cache clean --force 2>/dev/null

# pnpm
du -sh "$(pnpm store path 2>/dev/null)" 2>/dev/null
pnpm store prune 2>/dev/null

# yarn
du -sh "$(yarn cache dir 2>/dev/null)" 2>/dev/null
yarn cache clean 2>/dev/null

Report MB freed per package manager. If a tool is not installed, skip silently.


Step 6 — VS Code cache

Measure each path individually before deleting. Do not use a subshell loop to accumulate sizes — variable changes inside subshells are lost to the parent shell. Use individual du calls instead:

OSPaths
Windows$APPDATA/Code/Cache, $APPDATA/Code/CachedData, $APPDATA/Code/logs, $LOCALAPPDATA/Temp/vscode-*
macOS$HOME/Library/Application Support/Code/Cache, CachedData, logs
Linux$HOME/.config/Code/Cache, CachedData, logs
# measure each path individually before deleting
du -sh "$APPDATA/Code/Cache" 2>/dev/null
du -sh "$APPDATA/Code/CachedData" 2>/dev/null
du -sh "$APPDATA/Code/logs" 2>/dev/null
du -sh "$LOCALAPPDATA/Temp/vscode-"* 2>/dev/null   # glob, not subshell

# then delete
rm -rf "$APPDATA/Code/Cache/"* 2>/dev/null
rm -rf "$APPDATA/Code/CachedData/"* 2>/dev/null
rm -rf "$APPDATA/Code/logs/"* 2>/dev/null
rm -rf "$LOCALAPPDATA/Temp/vscode-"* 2>/dev/null

Add all individual du results together for the reported total.


Step 7 — Final summary

Only print the summary after ALL steps above have completed and all results are in hand. Do not print a partial summary and update it later.

Take a final disk reading using the same command as Step 0:

df -h / 2>/dev/null || df -h "$HOME"

Print one summary block:

/clean results
──────────────────────────────────────────
Claude temp:      X MB
OS temp:          X MB
Browser caches:   X MB  (Chrome X | Edge X | Firefox X)
node_modules:     X MB  (N folders)
npm/pnpm/yarn:    X MB  (npm X | pnpm X | yarn X)
.next builds:     X MB  (N folders)
Python cache:     X MB  (N folders)
VS Code cache:    X MB
──────────────────────────────────────────
Total freed:      X MB
Disk free before: X GB
Disk free now:    X GB

Use the du measurements collected before each deletion as the source of truth — not disk delta, which is unreliable when operations overlap.


Super Mode (/clean super)

Never delete anything without explicit user approval. The goal is to help the user free space without losing anything important.


Phase 1 — Scan Everything

Run all discovery silently first. Do not delete anything yet. Measure sizes. Collect results into a ranked list.

Scan the following, in addition to everything in quick mode:

Package manager caches

# Homebrew (macOS)
du -sh "$HOME/Library/Caches/Homebrew" 2>/dev/null

# Gradle
du -sh "$HOME/.gradle/caches" 2>/dev/null

# Maven
du -sh "$HOME/.m2/repository" 2>/dev/null

# Cargo (Rust)
du -sh "$HOME/.cargo/registry" "$HOME/.cargo/git" 2>/dev/null

# Go modules
du -sh "$HOME/go/pkg/mod" 2>/dev/null

# RubyGems
du -sh "$HOME/.gem" 2>/dev/null

# pip / pip3
pip cache info 2>/dev/null

Docker

docker system df 2>/dev/null

Captures: stopped containers, dangling images, unused volumes, build cache.

IDE caches

# Xcode (macOS)
du -sh "$HOME/Library/Developer/Xcode/DerivedData" 2>/dev/null
du -sh "$HOME/Library/Developer/CoreSimulator/Devices" 2>/dev/null

# JetBrains (all IDEs)
du -sh "$HOME/Library/Caches/JetBrains" 2>/dev/null           # macOS
du -sh "$LOCALAPPDATA/JetBrains" 2>/dev/null                   # Windows
du -sh "$HOME/.cache/JetBrains" 2>/dev/null                    # Linux

# Android SDK
du -sh "$HOME/.android/avd" 2>/dev/null
du -sh "$HOME/Library/Android/sdk/.temp" 2>/dev/null

Log files

find "$HOME" -name "*.log" -size +5M -not -path "*/node_modules/*" 2>/dev/null | head -30
find /var/log -name "*.log" -size +5M 2>/dev/null | head -20   # Linux/macOS

Large files (anywhere under home, > 100 MB)

find "$HOME" -size +100M -not -path "*/node_modules/*" -not -path "*/.git/*" -type f 2>/dev/null | head -20

Downloads folder — large or old files

find "$HOME/Downloads" -size +50M -type f 2>/dev/null
find "$HOME/Downloads" -atime +90 -type f 2>/dev/null | head -20

Trash / Recycle Bin

du -sh "$HOME/.Trash" 2>/dev/null                          # macOS
du -sh "$HOME/.local/share/Trash" 2>/dev/null              # Linux
du -sh "/c/\$Recycle.Bin" 2>/dev/null                      # Windows

Git large objects

find "$HOME" -name "*.pack" -size +50M -path "*/.git/*" 2>/dev/null | head -10

App media / recordings

du -sh "$HOME/Documents/Zoom" 2>/dev/null
du -sh "$HOME/Zoom" 2>/dev/null
du -sh "$HOME/Library/Application Support/Slack/Cache" 2>/dev/null      # macOS
du -sh "$APPDATA/Slack/Cache" 2>/dev/null                                # Windows
du -sh "$APPDATA/Microsoft/Teams/Cache" 2>/dev/null                      # Windows
du -sh "$HOME/Library/Application Support/Microsoft/Teams/Cache" 2>/dev/null  # macOS

Old installers

find "$HOME/Downloads" \( -name "*.dmg" -o -name "*.pkg" -o -name "*.exe" -o -name "*.msi" \) 2>/dev/null | head -20

Phase 2 — Present Findings

After scanning, present a numbered list sorted by size (largest first). Each item shows:

  • Number, category, path/description, size, safety rating

Safety ratings:

  • Safe — regenerated automatically, safe to delete
  • Review first — user data, show filenames before deleting
  • Keep if active — safe only if no active projects use it

Example format:

What's taking your space — ranked by size
═══════════════════════════════════════════════════════
 #   Category              Detail                          Size      Safety
───────────────────────────────────────────────────────
 1   node_modules          ~/Projects/app-one              4.2 GB    Safe
 2   Docker images         3 unused images                 2.1 GB    Safe
 3   Xcode DerivedData     ~/Library/Developer/Xcode/...  1.8 GB    Safe
 4   Gradle cache          ~/.gradle/caches                1.1 GB    Safe
 5   node_modules          ~/code/old-project              980 MB    Safe
 6   Downloads (old)       43 files not opened in 90d     870 MB    Review first
 7   Zoom recordings       ~/Documents/Zoom                640 MB    Review first
 8   .next builds          ~/Projects/app-one/.next        420 MB    Safe
 9   Cargo registry        ~/.cargo/registry               380 MB    Safe
10   Docker volumes        2 unused volumes                310 MB    Safe
11   Large log files       /var/log/*.log (6 files)        290 MB    Safe
12   Browser caches        Chrome + Edge + Firefox         240 MB    Safe
13   Slack cache           ~/AppData/Roaming/Slack/Cache   210 MB    Safe
14   Go modules            ~/go/pkg/mod                    180 MB    Keep if active
15   JetBrains cache       ~/.cache/JetBrains              160 MB    Safe
16   Claude temp           /tmp/claude/                    120 MB    Safe
17   OS temp               /tmp/ files > 10 MB             95 MB     Safe
18   Python __pycache__    18 folders found                 72 MB    Safe
19   VS Code cache         Cache + CachedData + logs        58 MB    Safe
20   Maven repository      ~/.m2/repository                 45 MB    Keep if active
───────────────────────────────────────────────────────
TOTAL FOUND:  ~14.2 GB potentially recoverable

Then ask:

Which items do you want to KEEP? (I won't touch these)
Enter numbers separated by commas — e.g. "6, 7, 14"
Or type "none" to approve everything above for deletion
Or type "all" to cancel and keep everything

Your answer:

Wait for the user's response before proceeding.


Phase 3 — Clarify if needed

If the user approves items marked "Review first" for deletion, ask a follow-up before acting:

  • Downloads: "These are files in your Downloads folder not opened in 90+ days. Want me to list the filenames so you can pick which ones to delete?"
  • Zoom recordings: "These are your recorded meetings. Are you sure you want to delete them?"
  • Large unknown files: show filenames and ask "Which of these do you want to delete?"

Never skip this step for "Review first" items.


Phase 4 — Final Confirmation

Before deleting anything, show exactly what will be removed:

Ready to delete — please confirm
═══════════════════════════════════════════════════════
Will delete:
  ✓ node_modules — ~/Projects/app-one (4.2 GB)
  ✓ Docker images — 3 unused images (2.1 GB)
  ...

Will keep (your choice):
  ✗ Downloads — old files (870 MB)
  ✗ Zoom recordings (640 MB)

Space to be freed: ~13.1 GB

Type "yes" to proceed, or "no" to cancel.

Wait for "yes" before deleting anything.


Phase 5 — Execute

Delete only approved items. Report progress per item as it goes.


Phase 6 — Super Output

/clean super results
══════════════════════════════════════════════
[each deleted item and MB freed]
──────────────────────────────────────────────
Total freed:      X GB
Disk free now:    X GB
Kept by choice:   X GB (your decision)
══════════════════════════════════════════════
Run /clean super again anytime to re-scan.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.