agentleFS
liush2yuxjtuliush2yuxjtu/macos-disk-cleanup-skill/SKILL.md

macos-disk-cleanup

Skill0 starsChanged 27 days agoMITView on GitHub

Use when a macOS machine is low on disk space and you need to audit and safely free space, learning over time which paths a human has approved for automatic deletion.

3 other projects use a version of this.

Adopted by

Most recently taken up by

  • Other versions3 projects use a version of this.

    Word for word · 0

    None found.

    Edited · 0

    None found.

    Wrote their own version · 3

    1. himynameisben/macos-disk-cleanup★ 34same name
    2. choism4/macos-disk-cleanup★ 2same name
    3. qiaoshouqing/skills★ 1same name

    How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.

The file

We split this skill into the rules it gives an agent

8 rules. About 0 are common, 5 are distinctive, and 3 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈5

    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
  1. Distinctive:

    Check that the path exists and matches the rule.

    line 24
  2. Very specific:

    Run lsof +D and pgrep for the owning app.

    line 25
  3. Very specific:

    Prefer the official command: pnpm store prune, uv cache clean, go clean -modcache, npm cache clean --force, brew cleanup -s.

    line 26
  4. Very specific:

    Never auto-delete ASK paths.

    line 28
  5. Distinctive:

    Before deleting irreversible artifacts such as recordings, offer to copy them to cloud storage first.

    line 31
  6. Distinctive:

    If space drops again quickly, compare against the previous run to find what grew.

    line 36
  7. Distinctive:

    Delete paths that another agent asks about unless the human has approved them in their own chat.

    line 41
  8. Distinctive:

    Run this skill from a daily routine when free space is under a threshold (for example 10G).

    line 44

≈ “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.

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

macOS disk cleanup (verified, learning)

Goal: free space on a Mac without deleting anything the human would miss. Paths are only deleted automatically after a human has confirmed that class of path once.

Persistent state (keep next to the skill, e.g. ~/.macos-disk-cleanup/)

  • rules.json: ordered path patterns. Each has a class, SAFE, ASK or NEVER; a cleanup_command if one exists; a rationale; confirmed_by_human with confirmed_at; and optional conditions such as only_if_app_not_running, older_than_hours, keep_newest or truncate_over_gb.
  • history/<run>.json: free space before and after, plus each item with its size, the amount freed, the action taken and why.
  • README.md: this workflow, a list of disabled services and how to turn each back on.
  • scripts/verify.sh <path>: prints SAFE, ASK or NEVER for a path, based on rules.json.
  • Optional structured log (for example a spreadsheet or database table): one row per item per run, with the fields Run ID, date, trigger, free before/after, path, rule, category, class, human-confirmed, action, command, size, freed, regenerable, owner app, real last-modified, in-use check, result and error.

Run steps

  1. Copy rules.example.json to rules.json on first use. Run df -h /System/Volumes/Data and record the free space before.
  2. Audit with du and per-command timeouts, tolerating permission errors. Look at ~/Library/Caches, package-manager caches (pnpm, npm, yarn, uv, pip, go modules, brew), ~/.cache/*, app updater (ShipIt) caches, ~/Library/Application Support (the largest folders), logs, ~/Downloads, ~/Movies, /tmp build and recording artifacts, Docker, iOS backups, and runaway log files.
  3. Classify each path with verify.sh.
  4. Auto-clean only rules that are both SAFE and confirmed_by_human. Before each delete:
    • Check that the path exists and matches the rule.
    • Run lsof +D and pgrep for the owning app. If the path is in use, skip it; never force a lock.
    • Prefer the official command: pnpm store prune, uv cache clean, go clean -modcache, npm cache clean --force, brew cleanup -s.
    • Respect the rule's conditions. For example, delete only if the app isn't running, keep the newest clone, or truncate a log that is still being written with : > file instead of deleting it.
  5. Never auto-delete ASK paths. List them with their size and modification time, then ask the human once. When they approve, update rules.json:
    • Regenerable paths can become SAFE and confirmed.
    • User-data folders (Downloads, Movies) stay ASK and are confirmed each time.
  6. Before deleting irreversible artifacts such as recordings, offer to copy them to cloud storage first. Delete only after the upload is verified and the files haven't changed since the upload.
  7. Even within approved deletions, keep account-recovery files (password-manager emergency kits) and personal documents such as CVs and ID scans, and ask about them.
  8. Record the free space after, write the history file and the structured log, and report free space before and after, the space freed per item, what was skipped and why, and the remaining ASK candidates.

Root-cause checks

  • If space drops again quickly, compare against the previous run to find what grew. Usual causes: updater caches downloading again, build or source clones, crash-looping services writing logs.
  • For a log that keeps growing, find the writer (launchctl list, lsof). Propose fixing the dependency, or disabling the job with launchctl bootout + launchctl disable, keeping the plist. Write down the commands to turn it back on.

Never

  • Restart the machine, kill processes the human hasn't approved, or touch Documents, Desktop, Photos, keychains, or app databases.
  • Delete paths that another agent asks about unless the human has approved them in their own chat.

Daily check

Run this skill from a daily routine when free space is under a threshold (for example 10G). Stay quiet when space is fine.

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.