Clears space on the Mac when Dan types /disk-clean. A scan of what can go that removes nothing, one review page where he ticks what goes, one confirm, then removal through disk-remove.sh with the result verified by df. For working out why a disk is full, use disk-full.
Resources
15Install
npx skillscat add danwright32/claude-config/disk-clean Install via the SkillsCat registry.
disk-clean
Dan starts this by typing /disk-clean; Claude never starts it on its own, because it ends in removing
things. The flow is six steps, in order, and nothing is removed before step 4. Every script it
calls says what happened by its exit code, and each step below says what to tell Dan for every code
that script can return (test-disk-clean-skill.sh derives the codes from the scripts and fails
when one is missing here). Judge each run by its exit code, never by its last line (L184).
Before starting
<folder>below isdisk-cleaninside the scratchpad directory this session's system prompt
names, written out as a full path. Every file of one run goes there: the review page, its nonce,
the pasted selection and the plan.- Nothing is ever removed by hand: no
rm,mvortrashtyped by Claude. Removal isdisk-remove.sh, which refuses sync and cloud stores, app packages, Mail and Messages, keys and
anything under /Applications or /System, judges each item again just before it goes, and checks it
really went. - Claude never runs
sudoitself. Anything that needs Dan's password is handed to him as one
command in step 6. - Steps 1 and 2 remove nothing, but they are not write free, so never call them read only. They
write the scan record~/.claude/state/disk-clean/last-scan.json(replacing the last scan's) and
in<folder>the review page and its nonce, and step 2's--clear-clipboardempties the
clipboard. They change nothing inside the
folders they judge: a worktree's state is read withgit --no-optional-locks status, since a
plaingit statusrefreshes the repository's index file as it reads it (#3216). And git is run
there with the folder's own program running settings turned off, so judging a folder never
starts a program that folder's configuration names (#3328).
1. Scan
Tell Dan the scan has started, that it removes nothing, and that it can take several minutes. Run it
with run_in_background and wait for its notification, since each kind is bounded at ten minutes
and the walk of the home folder at fifteen, longer than a foreground call is allowed:
bash ~/.claude/skills/disk-clean/scan.shReport what it printed, in plain words, in this order:
- The Full Disk Access result, first, because it decides how far every figure after it can be
trusted. Granted needs one line. Not granted means every folder macOS protects was read as
permission denied rather than as its size, so the figures are short: tell Dan he can turn it on
in System Settings, Privacy & Security, Full Disk Access, for the app Claude Code runs in, then
quit and reopen that app and type /disk-clean again. Unmeasured means there was no Mail folder to
try, so it is not known; say that. - Each kind's total: what can go, with its item count, keeping "at least" wherever the scan said
it, because then part of the kind could not be measured and the figure is a lower bound. A kind
with nothing in it says nothing was found. Everything offered, the Trash apart, has gone 30 days
without being changed or run, on top of its kind's own rule (one row waits 7 days instead, a
bulky leftover in a session still open, which item 5 covers); say "changed or run", never "used"
or "opened", because a data file read again and again without changing can still look unopened
(access time records only the first read after each change). Docker images and the build cache
are always unmeasured, since when they were last used is not read. - Every kind the scan could not measure, by name, stated as unmeasured with the reason it printed
(timed out, a tool missing, Docker not running), never as zero and never left out, since an
unmeasured kind may be the large one. A walk that was partial or unmeasured is said the same way,
with the kinds that read it (build folders, worktrees, worktrees whose repository is gone,
runaway logs, forgotten tools and large files). For a partial walk, name each folder it could not read, as the scan printed them, with
the reason beside each: Operation not permitted is macOS protecting the folder, which Full Disk
Access usually lifts, and Permission denied is the folder's own permissions, which it does not. - Every note the scan printed under a kind, in plain words. Under Project build folders it says
how many build folders were left out because a sync service keeps them, and where (Documents or
Desktop while iCloud syncs them, Dropbox, Google Drive, OneDrive, Box and the rest): none of those
is ever offered, since removing one would remove it on every device that syncs it (#3215, #3233). - Two kinds mostly show where space is (#3235): Records Claude Code and this config keep (its
state, session notes among them, file history, the finding spool and its backups, the home
folders its hooks write, with the rest of the state and every other home entry named for Claude
counted in its note), and Claude items in the user temp folder, which lists no rows and gives
its count and size in its note. Say the first one's largest rows by size and both notes, as
space shown, not as space that can be freed. Records offers three things, each a folder in
session notes that goes to the Trash (Dan, 2026-11-19): a folder of images or documents the
daily keep rules kept in an ended session's notes, once nothing in it was changed or opened in
30 days; a bulky leftover in a session that is still open, once nothing in its task folder was
changed or run for 7 days and no session is working there, which is the one row whose time is
shorter than 30 days, so say the 7 days when you report it; and a git checkout an ended
session kept, only when git says it has nothing uncommitted, no stash and no commit missing
from its remote, by the Finished worktrees test. Only a checkout that holds its own repository
is one of these, which git is asked too: a worktree or submodule of a repository elsewhere is
shown and never offered. All three are read from lists the keep rules
job writes once a day, so a row can be up to a day old. When the kind says any of them is
unmeasured, say which and why in its words (the list is missing, over two days old, or the job
is switched off on this Mac), and thatclaude-sync remove-leftoverswrites new lists. npm and
pnpm caches offers two things: npx copies (Dan, 2026-11-18), and one row named store prune (Dan,
2026-11-19), which removes no folder and instead runs pnpm's ownpnpm store prune, so pnpm
decides what no project uses. That row carries no size, because nothing says what a prune will
free until it has run; say so, never the store's size as what it frees. It is offered only when
pnpm is installed, pnpm says its store is in~/Library/pnpm/store, no process holds a file in
it and nothing in it was changed or run in 30 days; otherwise it is shown with the reason. The
kind's other rows, the pnpm store's own folder among them, are shown, never offered. What
Claude Code sessions leave that can go is under Tool output beside transcripts, Old Claude Code
versions, GitHub command line cache (one row, its kept entries counted in its note) and Project
build folders (which now include Swift .build folders).
- Exit 0: the scan was written, unmeasured kinds included. Report it as above and go on to step 2.
- Exit 2: it refused, or its record could not be written, so there is nothing to review. Tell
Dan the reason it printed and stop. - Exit 75: a removal is running now, and a new scan would replace the record it is working from,
so nothing was scanned. Tell Dan, and scan again once that removal has finished.
2. Open the review page
Render the page for this scan, clearing the clipboard first so a selection copied from an earlier
page cannot be the one pasted:
bash ~/.claude/skills/disk-clean/review-page.sh --out <folder> --clear-clipboardThen tell Dan, in the same message, that focus is about to move to Chrome, and open it:
open -a "Google Chrome" <folder>/disk-clean-review.htmlTell him: everything starts unticked; tick what should go, press Copy selection, and paste it here.
Grayed rows are what the scan will not remove, each with its reason. The selection must be
confirmed within an hour of the scan, after which disk-remove refuses it and the scan has to be run
again.
- Exit 0: the page and its nonce are written. Open it as above.
- Exit 3: the page is written but the clipboard could not be cleared. Open it anyway, and tell
Dan an older selection may still be on his clipboard, so he should copy from this page before
pasting; the checker refuses an old one by its nonce. - Exit 2: no page was written. Tell Dan the reason it printed. When it says there is no scan
record or the record is cut short, go back to step 1; otherwise stop.
3. Check the selection and confirm
When Dan pastes his selection, write exactly what he pasted to <folder>/selection.json with the
Write tool, never through a shell command, which would expand anything in it that looks like a
variable (L229). Then check it against the scan:
bash ~/.claude/skills/disk-clean/review-check.sh --out <folder> --payload <folder>/selection.json --plan <folder>/plan.txt- Exit 0: the plan is written, and it printed each kind's count and total, then every item by
path with its size and marks, except for a kind chosen whole. Build the confirm picker below from
that output. - Exit 2: the selection could not be checked (not what the page copies, or no scan or page to
check it against). Tell Dan the reason in plain words and ask him to press Copy selection on the
page again and paste it; when it says there is no scan record, go back to step 1. When it says
the summary could not be worked out, copying again cannot help: tell Dan that and stop. - Exit 3: a newer scan has replaced the one he reviewed. Nothing was planned. Go back to step 2,
which renders the page for the newer scan. - Exit 4: the selection came from an older copy of the page, or was left on the clipboard from
an earlier run. Nothing was planned. Ask him to copy from the page open now. - Exit 5: the count does not match the items listed, so some were lost between the page and the
chat. Nothing was planned. Ask him to copy and paste again. - Exit 6: some chosen items cannot be removed now (kept, unmeasured, already removed, or not in
the scan). Nothing was planned. Name each one with the reason it printed, and ask him to untick
those and copy again, or to start again from step 1. - Exit 7: nothing was ticked, so nothing will be removed. Say so and stop.
- Exit 8: the Trash or the GitHub command line cache was ticked as its one row, but what the
selection says of it is not what the scan offers now: an entry went after the page was drawn, the page was drawn for another scan, or
the selection was edited. Nothing was planned. Go back to step 2, which draws the page for what
the scan offers now, and ask him to tick again and copy from it.
Then put up one AskUserQuestion confirm picker, the only picker in this flow. Its question names
what will go, taken from the checker's output and never retyped from memory: each kind with its
count and total, and under Worktrees whose repository is gone, Large personal files and Tools not
used in 180 days every item by path, with its size, any mark it carries (Holds a credential, Removes
it from iCloud on every device) and, for a worktree, the date it last changed. The Trash and the
GitHub command line cache, each ticked as its one row, are kinds chosen whole; for each: the checker says it in one line, its count and total and any
mark some of its entries carry, and the picker says it the same way, never an entry a line (the Trash held 5,979 entries on the personal
MacBook, the GitHub cache 2,095). When Dan asks to see those entries, list them, which writes
nothing, and then put the same picker up again (--entries gh-cache for the GitHub cache):
bash ~/.claude/skills/disk-clean/review-check.sh --entries trash --plan <folder>/plan.txtIn the picker's question, say how each goes: Trash entries are deleted for good; Worktrees whose repository is gone, Large
personal files, Tools not used in 180 days, Tool output beside transcripts and every session notes row (a folder of images or documents, a bulky leftover of an open session, a git checkout) are moved to the Trash, which frees nothing until it
is emptied (a worktree git has forgotten can still hold work nothing else has); the store prune row
runs pnpm store prune, which leaves it to pnpm to remove from its store what no project uses, so
how much it frees is known only afterwards; everything else is
deleted because it regenerates, or, for a log a program holds open, emptied in place. Two options:
remove them, or keep everything. On keep everything, say nothing was removed and stop.
4. Remove
Read the free space just before, and keep the figure:
df -m /System/Volumes/DataThen run the plan the checker wrote:
bash ~/.claude/hooks/lib/disk-remove.sh --plan <folder>/plan.txtIt prints one line per item (removed, trashed, truncated, skipped with the reason, or failed with
the error), then the verified totals.
- Exit 0: every item went. Go on to step 5.
- Exit 5: at least one item was skipped or failed, or the scan record could not be marked with
what went. Name each skipped or failed item with its reason in plain words; a failure that says
Permission denied goes to step 6. Then go on to step 5 for what did go. The store prune row is
skipped, never failed, when pnpm ran and found nothing no project uses: say that pnpm's store
had nothing to prune, not that something went wrong. When it is removed, its figure is how much
smallerdufound pnpm's store, which can be more than the disk gained where a project holds a
package as a clone sharing the store's disk blocks; say so, and trust thedffigure of step 5. - Exit 2: it refused before touching anything (a plan or record it cannot use). Nothing was
removed. Tell Dan the reason it printed and stop. - Exit 3: the scan is more than an hour old, so what it measured may have changed. Nothing was
removed. Start again from step 1. - Exit 4: the plan is for a scan that is no longer the last one. Nothing was removed. Start
again from step 1. - Exit 75: another removal is running now. Nothing was removed. Once it finishes, run the same
command again, if the scan is still under an hour old; otherwise start again from step 1.
5. Report the verified result
Read the free space again, just after:
df -m /System/Volumes/DataReport three things, never on du alone, which overstates anything holding clones or hard links:
- What disk-remove verified: each item's own size, measured just before it went and checked gone
after, summed. - What moved to the Trash apart from that, since it frees nothing until the Trash is emptied; the
next /disk-clean offers it under the Trash. - What df says was freed: the free space before and after, in GB with one decimal. Other programs
write to the disk too, so this is context, but a gain far below the verified total is worth
saying, with the local Time Machine snapshots disk-remove named, which keep removed files until
they expire.
6. Anything that needs Dan's password
Claude never runs sudo itself. An item that failed in step 4 with Permission denied is owned by
another user, usually root, and only Dan can remove the rest of it. Collect those paths from the
failed lines (each already passed disk-remove's own checks and Dan's confirm), and hand Dan one
command for all of them, in its own code block, each path absolute and in single quotes, never a
glob, shaped like this:
sudo rm -rf '/private/tmp/com.example.helper'A failure that says Operation not permitted is macOS protecting the folder, which sudo does not
get past; say so rather than handing a command. A trashed item that failed is for Dan to move to
the Trash in Finder, which asks for his password itself. Once he says he ran it, check each path is
gone with ls -d and read df -m /System/Volumes/Data again for the gain.
The macOS symbol cache, which can reach hundreds of gigabytes, is root only and not part of the
scan; when the totals do not explain a full disk, the disk-full skill's step 7 has its commands.