skills/reap-worktrees/SKILL.md
Inspect and reclaim leftover /start wt worktrees. Shows which worktrees under .claude/worktrees/ are eligible for cleanup (PR merged, branch merged, or Linear issue Canceled/Done) and which are preserved (active or abandoned-for-resumption), and can reap the eligible ones now. Use when the user says 'reap worktrees', 'clean up worktrees', 'what worktrees are leftover', 'prune worktrees', or invokes /reap-worktrees.
npx skillsauth add alienfast/claude reap-worktreesInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
/start wt creates a worktree at <repo>/.claude/worktrees/<issue-lower>. Two flows leave one behind
that nothing else reclaims:
/finish pr (worktree mode) — the PR merges asynchronously on GitHub later, so /finish
can't clean up when it runs. The SHIPPED-PR tag tells you to remove the worktree after the PR
lands, but that hand-off is manual and easy to forget./start session — /start Step 8.5 only
surfaces cleanup while a session is running, so a cancel outside that window orphans the worktree.(/finish merge does not leak — finish-merge.sh removes the
worktree on a successful merge.)
A local launchd job (reap-worktrees-cron.sh →
com.alienfast.worktree-reap, hourly) runs the reaper automatically, mirroring the merge-queue drainer.
This skill is for on-demand inspection and cleanup between those passes.
reap-worktrees.sh destroys a worktree only on positive evidence of completion — never on mere inactivity. A worktree is reaped iff all hold:
MERGED (via gh); or its Linear issue state type is
completed/canceled.origin remote-tracking branch (pushed).git status --porcelain is empty. The reaper never passes --force, so
untracked work is never destroyed; gitignored scratch (tmp/, node_modules) doesn't block removal.<repo>/.claude/merge-queue/<issue>.json marker (the drainer owns
those).Abandoned-for-resumption worktrees are preserved automatically — branch unmerged, PR open, issue still active means they fail the evidence test, so no special-casing is needed. A worktree that is eligible but dirty or has local-only commits is reported, not reaped, with the exact command to finish the job by hand.
Source branch comes from the per-worktree start.source-branch config recorded by
start-wt-setup.sh; the repo set is the union of the self-registering
~/.claude/worktree-repos.txt and ~/.claude/merge-queue-repos.txt.
Inspect (dry run — mutates nothing, takes no lock):
~/.claude/scripts/reap-worktrees.sh list # every registered repo
~/.claude/scripts/reap-worktrees.sh list <repo> # one repo
Each worktree prints one of: REAP-ELIGIBLE, KEEP (with the reason — active, unpushed, or dirty),
SKIP (detached / merge-queued), or STRAY.
Reap (mutating — removes eligible worktrees, serialized per repo under the same common-git-dir lock
/finish merge uses, so it can never race an in-flight merge):
~/.claude/scripts/reap-worktrees.sh reap # every registered repo
~/.claude/scripts/reap-worktrees.sh reap <repo> # one repo
When the user asks to inspect, run list and summarize the verdicts. When they ask to clean up, run
list first, show what will be removed, and on confirmation run reap. The hourly launchd log is at
~/.claude/logs/worktree-reap.log.
~/.claude/update.sh installs and refreshes the agent automatically (renders the __HOME__ template
and bootstraps it idempotently — see the plist header
for the by-hand commands). To remove it:
launchctl bootout gui/$(id -u)/com.alienfast.worktree-reap
rm ~/Library/LaunchAgents/com.alienfast.worktree-reap.plist
testing
Inspect and drain the local deferred-merge queue. Shows worktree merges that /finish deferred (transient block — e.g. the main checkout was on the source branch with WIP) and that a local launchd drainer retries until they land. Use when the user says 'merge queue', 'what merges are pending', 'drain the merge queue', or invokes /merge-queue.
testing
End-to-end Linear issue macro — runs /start then /finish in sequence, gated on the /quality-review verdict. Worktree mode is opt-in via the `wt` token, mirroring /start. Pauses only for plan approval and the deferred-items filing decision; otherwise autonomous. Use when the user says 'full PL-XX', 'ship PL-XX end-to-end', or invokes /full.
development
Adversarial implementation review with triage and fix loop. Hard-gates on `pnpm check`, delegates to the quality-reviewer agent for categorized findings (Critical/High/Medium/Nice-to-Have/Approved), then triages and fixes findings via the developer agent. Loops until a re-review surfaces no new Critical/High/Medium findings (convergence), with a soft ceiling of 5 cycles before asking the user how to proceed; option 3 of that prompt terminates with verdict `escalated-to-architect`. Use when the user says 'review my work', 'check this implementation', 'adversarial review', 'quality review', or invokes /quality-review.
testing
Triage and prioritize Linear backlog. Analyzes issues for staleness, blockers, and suggests priorities based on dependencies and capacity.