/pstack-picks:worktree-cleanupfrom pstack-picks
Audit git worktrees and stale simulators, then prune only the ones proven unused, with uncommitted work and in-use worktrees held back. Use for /worktree-cleanup, 'clean up my worktrees', 'reclaim disk space', or 'which worktrees can I delete'.
Ships in pstack-picks. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description, though model invocation is off: only you can start it.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
You own the disk and the safety gate. Prune merged or abandoned git worktrees and stale iOS simulators to reclaim space. Deletion is irreversible, so every step guards against deleting something in use or holding uncommitted work.
Snapshot and audit. Record df -h /, then run scripts/worktree-audit.sh
from this skill's directory. It takes an optional repo path and defaults to the current repo. Build
the tool rather than eyeballing the list: it reads paths from git worktree list, never hand-typed,
since a hand-typed myrepo-worktrees/x misses one that lives at .claude/worktrees/agent-<id>
(the principle-encode-lessons-in-structure skill). It classifies each worktree by size, age,
merge state, uncommitted work, PR state, and the newest chat that touched it, then suggests a
bucket. The transcript scan is slow, so run it with run_in_background: true.
The script is read-only. It runs git plumbing, gh, and greps, and never removes anything.
The bucket is advice, not permission. The set of sessions the user still has open is the real
artifact (the principle-prove-it-works skill). Ask the user which sessions are live and
cross-check every candidate against that set. The script has marked safe a worktree the user was
still working in, so the user's answer wins.
Verify usage before deleting. For every verify-recent-chat row, or anything you doubt, fan out
Agent calls with subagent_type: "Explore" and run_in_background: true to read the transcripts
and report whether the session is ongoing and which worktrees it touched (the
principle-guard-the-context-window skill: transcripts are bulk, they belong in a subagent).
A live session spawns arena and repro trees into sibling worktrees through background subagents, and
those are in use even when the user never named them.
Transcripts are at ~/.claude/projects/<slug>/, where <slug> is the repo's absolute path with
every / replaced by -, leading dash included. Main-thread sessions are <uuid>.jsonl; subagent
transcripts are at <uuid>/subagents/agent-<id>.jsonl.
Pause on irreversible loss. wip:N is N tracked uncommitted edits. Show the diff and get a
decision first, since removing a clean worktree is recoverable from its branch but uncommitted work
is gone. scratch:N is untracked throwaway, safe to drop, but name the files. Clean, merged, and
not-in-use proceeds without asking; wip and in-use pause.
Prune the confirmed set. Per path, git worktree remove --force <path>; if the directory survives
on ignored build artifacts, rm -rf it, then git worktree prune. Branch refs survive, so no
commits are lost. Confirm with df -h / and re-list.
Simulators and other reclaimers. On macOS with Xcode, simulators are usually the next-biggest win:
xcrun simctl --set testing delete all (XCTestDevices clones), xcrun simctl delete unavailable,
and xcrun simctl runtime list then runtime delete <id> for old runtimes. More when needed: Xcode
DerivedData and iOS DeviceSupport; old transcript directories under ~/.claude/projects/ for
repos that no longer exist; package caches (npm, pnpm, uv, brew, yarn). Clear only caches the user
has not said to keep, and never delete a transcript directory for a repo that is still checked out.
This is the one routine here that deletes user state with no code review to catch a slip, so the gates above are the review.
Reply: df -h / before and after with space reclaimed, the worktrees pruned, and a one-line reason
for each held back (in use by which session, or uncommitted work).
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub gethubgod/worker-skills --plugin pstack-picks20 skills in this plugin
/architectSketch types, signatures, and module structure before code, then stay in the loop while implementation fills in. Use for /architect, 'architect this', 'design this', or non-trivial work where jumping to code would lock in the wrong shape./arenaSpawn N parallel candidates at the same task, pick a base, graft the strongest parts of the losers into it. Use for /arena, 'arena this', 'throw it in the arena', or when one attempt at a non-trivial artifact would lock in the wrong shape./automate-meUse for "automate me", "create/update/refresh my -mode skill", "turn/capture my preferences or working style into a skill", or wanting agents to follow how the user works. Drafts or revises a personal -mode skill via create-skill, optionally pulling fresh evidence from recent transcripts.Other plugins' skills for the same job