Home / All Skills / Workflow & Core Tools / macos-cleaner
Workflow & Core Tools · daymade/claude-code-skills

macos-cleaner

Diagnoses and safely reclaims macOS disk space. Use when a Mac is low on storage, reports “Caching needs more space,” shows large Apple Content Caching or AssetCacheManagerUtil usage, or needs analysis of caches, logs, application remnants, large or duplicate files, Docker or OrbStack, Chromium code-sign clones, Homebrew, npm, pip, Xcode, and other developer storage. Routes known suspects to targeted read-only diagnosis before broad scans, distinguishes nominal path accounting from physical release, requires an impact-and-recovery plan plus explicit confirmation before state changes, and verifies disk space and co-resident services afterward.

L4 High-Privilege · Graded auth & full auditV1 Commit-PinnedExecute CommandInstall DepsWrite FileDual-pass Audit
Author daymadeGitHub daymade/claude-code-skills ↗Stars 1385License MIT(仓库根 LICENSE,Copyright (c) 2025 daymade;GitHub API spdx MIT)Commit d5c4678cb5
Control levels describe skill capabilities and suggested control measures; they do not represent quality or safety certifications, nor do they dictate usability. Usage decisions rest entirely with users and administrators. Different agent hosts apply varying constraints; do not assume hosts provide automatic protection. Third-party skill copyrights belong to their original authors. Use at your own risk.

1How It Works & Mechanism

Ingress routing mechanism: Takes the narrowest path based on user signals—named suspect sources (Apple Content Caching / Docker / Chromium code-sign clones / specific cache directories) consult dedicated reference docs first; broad generic scans are used only when the source is truly unknown.

daymade-macos/macos-cleaner/SKILL.md
Choose the narrowest path that can answer the request
The principle of 'named suspect sources take priority over full-disk scans' prevents immediately running du across the entire home directory; user-provided scope exclusions override any generic scanning suggestions.

The safety core is a 4-phase state machine featuring 'separation of observation and mutation + precise approval gates': Observe (read-only) → Plan (pause at confirmation gate) → Execute (approved scope only) → Verify (independent read-back); phases 2 and 3 must never be collapsed into a single message.

daymade-macos/macos-cleaner/SKILL.md
Do not compress phases 2 and 3 into one message. A plan printed beside a cleanup command is not a confirmation gate.
10 explicitly numbered 'Safety and authorization contract' rules (separate observation and mutation, verify exact targets, plan first, require explicit approval, precise controlled commands, no prune commands, no broad rm, protect valuable state, execution follows authorization, fail fast).

Read-only diagnosis is executed via custom Python scripts (analyze_caches / analyze_dev_env / find_app_remnants / analyze_large_files / analyze_code_sign_clones) coupled with strict physical allocation accounting: du is nominal path accounting, not physical release (APFS clones share extents).

daymade-macos/macos-cleaner/SKILL.md
shared extents can be attributed to every path, so actual release remains unknown until deletion and `df` readback
Reports present both nominal (path accounting) and physical columns side-by-side; the stop condition only accepts candidates that have 'precise actionable operations and defensible physical reclaim', ignoring logical size, Trash moves, or unverified potential savings.

Dual-track deletion paths: Finder Trash is preferred (recoverable deletion via osascript, though physical space is released only after emptying Trash); the legacy safe_delete.py is a permanent deletion helper with denylists and interactive confirmation, explicitly downgraded in documentation (does not Trash, does not inspect all user data roots, does not check open files).

daymade-macos/macos-cleaner/scripts/safe_delete.py
HIGH_RISK_PATHS = frozenset( _canonical_path(path) for path in [ '/System', '/Library/Apple', '/usr', '/bin', '/sbin', '/etc', '/private/var/db', '~/.ssh', '~/.aws', '~/.gnupg', '~/Library/Keychains', ] )
The denylist covers system and credential directories; confirm_delete adds extra warnings for hazardous patterns like documents/desktop/credentials; batch mode supports 'all' (skipping per-item danger prompts—the SKILL documentation allows this helper only after precise approval, and it must never be used on user documents).

Docker / OrbStack discipline: Per-object analysis (lists each image/container/volume, inspects references and library content, checks sparse file physical allocation), with database volume names (mysql/postgres/redis/mongo/mariadb) mandating content inspection before deletion can be proposed; **never use the prune family of commands**.

daymade-macos/macos-cleaner/SKILL.md
**Never use Docker prune-family commands.** This includes image, container, volume, system, builder, and buildx prune.
docker_analysis.md inspects volumes using temporary containers via docker run --rm --pull=never --network=none --read-only --cap-drop=ALL (no network, read-only, stripped privileges); dangling does not equal valueless data, and build cache is only measured, never deleted (Docker only provides category-level prune controls).

Post-verification discipline: Calculates actual reclaim from before/after df readings (never trusting deletion tool self-reports), re-checks cleaned subsystems, re-resolves PIDs and health probes for critical co-resident services, and observes at bounded intervals if APFS accounting lags or potential backfills occur; never report 'fixed' when only the exit code is known.

daymade-macos/macos-cleaner/SKILL.md
Never report “fixed” when only the command exit code is known. A successful cleanup requires both the intended state and the protected invariants.
The optional cleanup_report.py writes before/after snapshots under ~/.macos-cleaner to assist comparison, but documentation states direct df reads are the source of truth, and it only runs on local targets.

2Core Capabilities

01Disk pressure root-cause diagnosis (identity / baseline / subsystem status + separate df -k / -h computation and display)
02Dedicated diagnosis and controlled cleanup for Apple Content Caching / AssetCacheManagerUtil (front-loaded with references/apple_content_caching.md in full)
03Chromium code-sign clones nominal vs. physical separation analysis (analyze_code_sign_clones.py read-only manifest, optional non-overwriting manifest export)
04Read-only scanning of developer environments, caches, large files, and app remnants (four scripts: caches, dev_env, large_files, app_remnants)
05Comprehensive cleanup plan table covering exact targets, impact, recovery, service impact, and postconditions
06Finder Trash-first deletion + legacy guarded permanent deletion following explicit approval
07Before/after snapshot reporting (cleanup_report.py --snapshot before/after --compare)

3External Dependencies

KindDependency / Endpoint
clidf / du / lsof / pgrep / launchctl / ps(系统状态与分配测量)
cliuv(运行 bundled python 脚本)
cliosascript(Finder Trash 删除)
clidocker(可选:per-object 分析 + 受权后的临时只读检查容器)
climo / Mole(可选第三方全盘扫描器 github.com/tw93/Mole,需用户批准其固定宽扫描根)
clisudo AssetCacheManagerUtil / AssetCache(受权后的服务控制)

4Recommended Governance & Evidence

Suggested Controls for Safe Operation
For Agent Runtime
Graded/per-use authorization, sandbox recommended
For Administrators
Approval workflow, rollback support, full audit
Evidence & Triggers (File Paths & Excerpts)
  • scripts/: Executes local scripts or commands: scripts/analyze_caches.py / analyze_dev_env.py / find_app_remnants.py / ana
  • scripts/ 或 SKILL.md: Declares dynamic installation of external language package dependencies
  • 本地工作目录: File I/O and artifact generation: ~/.macos-cleaner/{before,after}.json (cleanup_report.py snapshots)
Audit Notes: Local cleanup skill: Performs no external network requests and reads no credentials (explicitly protecting ~/.ssh, Keychains, etc.). The yellow rating stems from its intentional capability to execute destructive actions upon approval—permanent deletion helper (safe_delete.py denylist + interactive confirmation), Finder Trash, Docker object cleanup, sudo AssetCacheManagerUtil service control, as well as optional full-disk read-only scans (Mole, scanning home/system libraries/apps/volumes) and Docker volume content inspection. Destructive actions are tightly constrained by the '10 safety contracts + 4-phase gate + exact target confirmation + post-df/service verification' and default to read-only; however, the potential blast radius objectively exists, warranting a 'Use with caution' yellow rating (falling short of orange due to no credential access or outbound network traffic).

5Second-Pass Verification

  • [ok] safe_delete.py denylist 与删除逻辑 — HIGH_RISK_PATHS 含 /System、/usr、/bin、/etc、~/.ssh、~/.aws、~/.gnupg、~/Library/Keychains 等;delete_path 对 is_high_risk_path 直接拒绝;文件 unlink/目录 shutil.rmtree。
  • [ok] 『观察/变更分离 + 确认门禁』在源码与文档双重存在 — SKILL.md 10 条 contract + 四相状态机 + 'Do not compress phases 2 and 3 into one message';safe_delete 每次删除前交互 input('[y/N]')。
  • [ok] nominal vs physical 纪律有代码/文档支撑 — SKILL.md 明示 du 路径记账 vs df 物理读回;cleanup_report 只做 df 快照不做释放断言;safe_delete 输出 'Measured size removed' 并提示 'Physical release: verify with before/after df -k'。
  • [ok] Docker prune 禁令与 per-object 纪律 — SKILL.md 六行明文禁 prune 家族;docker_analysis.md 给 --pull=never --network=none --read-only --cap-drop=ALL 的只读检查容器配方。
  • [ok] 无网络/无凭证(安全结论基础) — 全目录扫描零网络调用代码、零凭证读取;Mole/AssetCacheManagerUtil 等外部工具仅在有授权与安装前提下由宿主调用。
  • [ok] batch 'all' 可跳过逐项危险模式警告的注意点 — safe_delete.py batch_confirm 支持输入 'all' 直接返回全部 items(不做 danger_patterns 逐项检查,仅 denylist 兜底)——已在 risks 注明;SKILL.md 也限定该助手仅用于精确批准的非用户数据目标。
  • [ok] 元数据(commit/license/stars) — 本地 HEAD == pin d5c4678cb5d4fd6acc9c922690df035dbd33d247;GitHub API:MIT、stars 1385(2026-09-09 实采)、pushed_at 2026-09-09T12:33:29Z。

6Verdict & Scenarios

  • Safety workflows are core architecture rather than decoration: separation of observation and mutation, exact confirmation phrasing, step-by-step execution, and independent verification are fully documented and integrated into scripts.
  • Honest physical release accounting: never mistakes du or logical sizes for reclaimable space; reclaim is verified strictly via before/after df readings.
  • Suspect-based routing backed by a literature base: common heavy consumers (Content Caching / Docker / Chromium clones) each have dedicated in-depth documentation, avoiding indiscriminate full-disk scans.
  • Self-contained test suite verifying safety logic (safe_delete / cleanup_report / code_sign_clones plus root safety tests), which is rare among cleanup skills.
  • Explicitly acknowledges tool boundaries: safe_delete is marked as legacy (does not Trash, does not check open files), with a Trash-first, recoverable philosophy guiding the deletion path.
  • Best for: Ideal for macOS disk pressure alerts, “Caching needs more space” warnings, and real-world cleanup scenarios with heavy cache consumers—especially for users who accept the “read-only diagnosis → plan approval → execution → verification” workflow and can provide explicit confirmations; also provides proven pathways for cautious remote Mac maintenance and targeted cleanups of Docker, Chromium, and developer caches.
    Not for: Not suitable for Windows or Linux; not for users wanting “one-click silent auto-cleaning” (the skill explicitly refuses unaudited automatic deletions); not for adjusting app behavior without disk reclamation goals; not for users unwilling to grant broad read/mutation permissions or unable to specify precise free-space targets.
    Install Agent-Ready
    ① Verified Mirror 2026-09-09
    Option A · Direct DownloadDownload macos-cleaner.tar.gz
    sha256: 2e94bb1d20bbcc55…
    Option B · Copy Guide for Agent
    install.json
    Agents automatically download and verify mirrors from this JSON guide.
    ② Upstream GitHub
    GitHub Repo ↗
    Pinned to commit d5c4678cb5.