From eb34963ade5337348807f520671d3552fa7af66e Mon Sep 17 00:00:00 2001 From: "Hermes (blackbook)" Date: Wed, 2 Dec 2026 03:27:12 +0100 Subject: [PATCH] Skills von blackbook: devops/macos-disk-cleanup --- skills/devops/macos-disk-cleanup/SKILL.md | 31 +++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 skills/devops/macos-disk-cleanup/SKILL.md diff --git a/skills/devops/macos-disk-cleanup/SKILL.md b/skills/devops/macos-disk-cleanup/SKILL.md new file mode 100644 index 0000000..407cbf7 --- /dev/null +++ b/skills/devops/macos-disk-cleanup/SKILL.md @@ -0,0 +1,31 @@ +--- +name: macos-disk-cleanup +description: Use when a Mac disk is full. Find hogs, clean, verify freed. +--- + +# macOS Disk Cleanup + +## Procedure + +1. **Diagnose the real picture first.** + - `df -h /` for headline capacity, but also `diskutil apfs list | grep -E "Capacity|Size"` — on an APFS container with multiple volumes (system, data, VM, Preboot) the root `/` numbers can mislead; `/System/Volumes/Data` usually holds the user data and is the one that's actually full. + - Rank hogs top-down, not file-by-file: `du -sh ~/* | sort -rh`, then drill into the biggest hits (`~/Library/*`, `/Applications/*.app`, `/Library/Developer/*`). Don't `du` the whole tree at once — rank one level, descend only into the big entries. + - Treat any `/private/var/folders/.../Nextcloud.app/Wrapper` or similar sandbox mount showing huge usage as a view of the SAME underlying volume, not a separate cost — don't double-count it. + +2. **After deleting anything, the freed space often does NOT show up in `df` immediately.** Check for local Time Machine snapshots holding the deleted blocks: + - `tmutil listlocalsnapshots /` + - `tmutil deletelocalsnapshots ` for each `com.apple.TimeMachine.*` entry (leave `com.apple.os.update-*` ones alone, those are OS-update snapshots). + - Re-run `df -h /` after — this step alone can be the difference between "nothing was freed" and the real number. Always check this before telling the user a deletion didn't help. + +3. **Xcode iOS Simulator bloat** (`/Library/Developer/CoreSimulator`, often tens to 100+ GB) is safe to clear without touching Xcode.app itself: + - `xcrun simctl delete all` (removes simulator device instances) + - `xcrun simctl runtime delete all` (removes the downloaded iOS runtime disk images — this is where most of the space actually is, in `CoreSimulator/Volumes` and `/Cryptex`) + - Verify with `du -sh /Library/Developer/CoreSimulator` before/after. + +4. **Files refusing to delete with "Operation not permitted" despite correct ownership** are usually flagged immutable (`uchg`), common in old synced/backup folders: + - Check: `ls -lO ` (flags column shows `uchg`). + - Fix: `chflags -R nouchg,nouappnd,noschg,nosappnd ` then retry `rm -rf`. + +5. **Deduplicating against a reference/cloud copy**: match candidates by `(filename, exact byte size)`, not filename alone. Files with the same name but a different size are a different export/version — do not delete those without explicit confirmation, even if the user said "duplicates can go". Report the ambiguous set back instead of guessing. + +6. **Before pronouncing something "long unused" for cleanup** (e.g. local LLM models, caches), check `stat -f "%a %m" ` for actual access/modify time — don't assume age from directory listing alone. If there's only one item in the category asked about, there's nothing to "sort out"; say so rather than inventing a selection.