{"success":true,"name":"storage-dedup-audit","description":"Use to audit a disk/volume for wasted or duplicate space.","category":"software-development","path":"software-development/storage-dedup-audit/SKILL.md","file":"SKILL.md","content":"---\nname: storage-dedup-audit\ndescription: Use to audit a disk/volume for wasted or duplicate space.\n---\n\n# Storage dedup audit\n\nGoal: find where a disk/volume is actually spending its space and which of that is a genuine duplicate, without guessing from screenshots or folder names alone — then let the user decide what to delete.\n\n## Procedure\n1. Map the volumes first: `diskutil list external` (or `list` for internal) and `ls -la /Volumes/`, `df -h` — get real used/free per mount, not just Finder's rounded GB. Disk images (.sparsebundle, .img, .dmg) show up as their own synthesized APFS containers in `diskutil list`; note their container size vs file size (sparse files report smaller `df` usage than their max size).\n2. Get top-level sizes fast: `du -sh -d1 \"<path>\"/* ` per top folder (not a deep walk) to rank by size before zooming in. Only `du` deeper into the top 5-8 biggest items.\n3. For disk images specifically: `hdiutil info | grep -A3 image-path` tells you which sparsebundle is actually mounted right now. Two mounted (or mountable) APFS volumes sharing the exact same **volume name** (e.g. both called \"DevSSD\") is a strong duplicate signal — mount the second one read-only and diff: `hdiutil attach -readonly -nobrowse \"<file>.sparsebundle\"`, then `diskutil mount readOnly <diskXsY>`, then compare top-level `ls -la` and dates between the two mounts. Prefer keeping the one with the newer mtimes.\n4. For plain folders suspected of being a stale backup/snapshot (e.g. a \"smart copy\" or similar dump), check whether a same-named subfolder duplicates something that already exists elsewhere on the same disk or on a live project location (GitHub folder, remote host) — confirm by `ls -la` + `diff` of top-level contents, not by folder name alone.\n5. Report as a colored table (status: confirmed duplicate / suspected / unknown-needs-check / keep) with size and the one-line reason, per this user's standing table-first, colored-cell preference. Never delete anything yourself — list confirmed vs suspected vs unknown and ask the user which to act on; only act after explicit confirmation.\n\n## Pitfalls\n- `du -sh` on a folder with huge file counts (node_modules, model blob caches, SSHFS-mounted remote paths) and `hdiutil attach` on a multi-GB sparsebundle can both exceed a 180s foreground command — run them with `terminal(background=true, notify=true)` and poll/read the log instead of re-issuing the same foreground command repeatedly on timeout.\n- Don't use a sparse disk image's `.sparsebundle` *file* size as its real used space — mount it (or use `df -h` on the mount point) to get actual used/container size; the file on disk can look big while the volume itself is nearly empty, or vice versa.\n- A duplicate-looking pair (two images with the same APFS volume name, two folders with the same project name) still needs a content diff before calling it a true duplicate — one copy is sometimes genuinely newer/different (extra files, newer mtimes); flag the newer one as keep.\n","linked_files":[],"origin":"brimind","owner_id":null,"source":"router"}