Prune merged feature worktrees, fast-forward the root checkout's base branch, run the project's post-sync command, and refresh the "Active worktrees" row in docs/diary.md. Invoke as `/worktree-cleanup` (or `/worktree-cleanup --dry-run` to preview). Conservative — never removes dirty or unmerged worktrees.
85%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
Low
Low-risk findings worth noting
The canonical home for this skill is worktree-cleanup in agranado2k/google-books-clojure
Closes the lifecycle the root AGENTS.md's first hard rule opens. Agents create
worktree/<slug> per feature, but after the pull request merges the worktree,
its local branch, and the diary's "Active worktrees" row are all left behind —
and the root checkout's base branch goes stale, so the next worktree branches
from an old base and pays a merge-reconciliation tax later.
The git mechanics live in scripts/worktree-cleanup.sh; this skill runs it and
then does the one thing a script should not do on a human's behalf — edit the
project's own memory.
docs/diary.md's header): refresh the "Active worktrees" row in the
Current state block, which is edited in place; never rewrite or delete the
dated entries below it.Dry-run first and show the operator what would happen:
sh scripts/worktree-cleanup.sh --dry-runRun for real (skip step 1's pause if the operator invoked the skill with a clear "clean up" intent — the script is conservative by design):
sh scripts/worktree-cleanup.shUpdate docs/diary.md: set the "Active worktrees" row in the Current
state table to the worktrees that remain (or "None." if empty). If the row
was already stale before this run, say so in the next dated entry rather than
silently fixing history.
Report the script's summary block plus the diary edit: base branch before → after, worktrees removed, worktrees kept and why.
A branch is pruned when it is an ancestor of the base ref (the normal case for merge commits and rebases) or its pull request is recorded as merged by the forge CLI. The second test exists because squash merges rewrite the commits, so ancestry can never succeed for them. Anything that satisfies neither test is kept.
Both are environment variables read by the script, both optional:
WORKTREE_CLEANUP_BASE — the merge target. Defaults to origin's HEAD branch.WORKTREE_CLEANUP_POST_SYNC — a command to run when the base branch moved,
typically a dependency install. Empty by default: the kit does not know your
toolchain, so it prints a reminder instead of guessing. Set it in
constitution/local-workflow.md's "Before you push" section once you know
what it should be, so the next person does not have to rediscover it.AGENTS.md, hard rule 1 — why the worktrees exist at all./merge-train — runs this skill as its final step, once a batch has landed.docs/diary.md — the update protocol step 3 obeys.agranado2k/tic-tac-toe-haskell
7554191
Canonical home
since Nov 19, 2026
Also appears in
since Nov 19, 2026
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.