Cleanup
Audit and remove idle git worktrees, caches, and test databases to free disk space.
Installation
- Make sure Claude is on your device and in your terminal.
Skills load from
~/.claude/skills/when Claude Code starts up — so you need it on your machine first. If you don't have it yet, install it once with the command below, then runclaudein any terminal to verify.One-time setupnpm i -g @anthropic-ai/claude-codeAlready have it? Skip ahead.
- Paste into Claude Code or into your terminal.
This copies the whole skill folder into
~/.claude/skills/cleanup-udecode/— the SKILL.md plus any scripts, reference docs, or templates the skill ships with. Works for every skill.What this command does
- Makes a new, empty temporary folder.
- Downloads the skill's folder,
skills/cleanup, fromgithub.com/udecode/ustack(branchmain), the GitHub repository it's listed from. You get the version that is there now, not a copy we keep. - Copies that folder to
~/.claude/skills/cleanup-udecode/. - Deletes the temporary folder.
Installing runs none of the skill's files; it only downloads and copies them. When you later use the skill, Claude follows its SKILL.md and may run scripts that come with it. Read them first.
Faster alternative (instruction-only skills)
Skips the clone and grabs only the SKILL.md file. Don't use this if the skill ships Python scripts, reference markdowns, or asset templates — they won't be downloaded and the skill will fail when it tries to load them.
Quick install (SKILL.md only)Sign up to copy - Restart Claude Code.
Quit and reopen Claude Code (or any other agent that loads from
~/.claude/skills/). New skills are picked up on startup. - Just ask Claude.
Skills auto-activate when your request matches the skill's description — no slash command needed. Trigger phrases live in the skill's own frontmatter; you can read them in the “What this skill does” section above.
Prefer to read the source first? Open on GitHub.
When Claude uses it
Audit disk usage and remove idle git worktrees, Next.js caches, test Postgres DBs, and unused Bun/npx/uv/Docker caches while preserving active checkouts. Use for /cleanup, /cleanup disk, or freeing worktree/build disk space.
What this skill does
Cleanup
Extends pstack's Worktree and simulator cleanup playbook (this skill wins on differences). Always remove worktrees with git worktree remove --force, never rm -rf, git worktree prune, or git stash. scripts/scan.mjs makes every verdict deterministically.
Modes
/cleanup scan: classify and report without deleting./cleanup: remove theSAFEset in the current repository plusmachine.mjs --delete./cleanup all: run across all sibling checkouts (--repos <parent dir>) plusmachine.mjs --delete./cleanup disk: read-only space audit vianode <skill>/scripts/disk.mjs(run in background; scans home,/private/tmp, tmp,/Applications>=10 GB up to 5 levels, flagswrittenvsquiet). Never delete quiet rows automatically; run/cleanup scanon top worktree repos.
Supporting commands
scan.mjs --landed <worktree>: verifies the main checkout holds all changes and<plans>/artifacts/ignored files of a landed card worktree before leaving it for cleanup.scan.mjs --remove <worktree>...: used by/chipscleanup to stop processes, save unique state, and remove archived card worktrees (skips locked, active, unresolved-merge, or unsafe paths).scan.mjs --brief --auto: optionalSessionStarthook; runs at most once/day in background removing onlySAFEitems (disable viaauto cleanup: offin~/.claude/pstack-models.md).machine.mjs [--delete]: clearsSAFEglobal caches (week-old Bun transpiler files, idle npx installs,uv cache prune, unused anonymous Docker volumes) and listsASKitems (pnpm store, named compose volumes).daily.mjs install: installs a 05:30 launchd job running cleanup across~/git(logs to~/Library/Logs/cleanup-daily/). Lock any pinned worktree withgit worktree lockso daily runs keep it.
Workflow (/cleanup, /cleanup scan, /cleanup all)
- Record
df -h <checkout>(macOSdf -h /shows the read-only system volume, not data). - If the runtime has a session-list tool, save all sessions (including archived) as a JSON array in the run directory. Without it, idle worktrees expire after one quiet day.
- Run
node <skill>/scripts/scan.mjs --repo . --sessions <file>(or--repos <dir>forall) in the background. Verdicts:- Worktree
KEEP: locked, T3-managed (~/.t3/worktrees/), current worktree, active process/server, running/pinned session, or modified/transcript-written within 1 day (reads HEAD reflog, Claude project transcripts, Codex rollouts). - Worktree
SAFE: agent-created location orclaude//codex//detached branch with noKEEPsignal. Before removal,--deletesaves unique state under<git-dir>/cleanup/<worktree>-<id>/(changes.patch,staged.patch,commits.bundle,ignored/,worktreemetadata), re-verifies no write occurred during save, removes viagit worktree remove --force, and expires week-old saves. Restore within a week viagit fetch <save>/commits.bundle 'refs/cleanup/*:refs/restored/*',git worktree add --detach,git apply, and copyingignored/. - Worktree
ASK: outside agent folders, nested worktree/dirty submodule, unresolved merge, unreadable git history, >20k ignored files, or missing.gitwith remaining files. - Caches:
.next/.next-plitebuild outputs stay; theirdev/cachesubdirs expire after 1 quiet day (maincheckout.next-<port>/devkept 7 days for Turbopack cache; worktree.next-*kept 1 hour, or 7 days ifBUILD_IDexists). Active server locks keep caches. - Run folders (
<plans>/artifacts/*,.tmp/*):KEEPif active/worktree/written within 1 day;SAFE stripremovesnode_modules/.next*/.turbo;SAFE expireremoves week-old unreferenced folders (after saving clone patches). Top-level files (ledger) are never touched. - Local Docker Postgres DBs:
KEEPif referenced by an env file, active connection, or written within 1 day;SAFEotherwise (dropped withoutFORCE).
- Worktree
- For
/cleanup scan, report the table and stop. Otherwise refresh the session list and runscan.mjs --deleteplusmachine.mjs --delete. - List every
ASKrow with path, size, reason, and session title. Only delete rows the owner explicitly names (git worktree remove --force <path>) and lock any they want kept (git worktree lock --reason "<why>" <path>). - Record
df -h <checkout>again and report actual space freed (duovercounts APFS clones), what was removed, and each kept/asked item.
Next telemetry note: If a KEEP row is held only by orphaned next/dist/telemetry/detached-flush.js (PPID 1), stop them, run next telemetry disable, and rescan.
Related skills
n8n Architect
EtienneLescot
Create, edit, and validate n8n workflows and automation configurations.
Deploy to Vercel
vercel-labs
Deploy your app to Vercel with preview or production environments.
Vercel CLI with Tokens
vercel-labs
Deploy and manage Vercel projects using token-based authentication instead of interactive login.
Skill Installer
foryourhealth111-pixel
Install Codex skills from curated lists or GitHub repositories.