/skill-madness:git-post-merge-cleanupfrom skill-madness
Cleans up stale git state after merges: merged local branches, orphaned tracking refs, and worktrees with phantom modifications. Scans, shows a plan, acts only on confirmation.
Ships in skill-madness. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
After a batch of PRs land, the local repo accumulates debris: fully merged branches, tracking refs whose remote was deleted by GitHub, and worktrees that still show "modified" files even though those changes are already on main. This skill cleans all of it in one pass — scan, classify, present a plan, confirm, execute. The scan is cheap; always do both classes.
--dry-run — scan and present the plan, but do not delete anything.--yes — skip the confirmation prompt. Still presents the plan first.Default (no flags): scan, present plan, wait for confirmation.
The default scan and --dry-run are read-only: use existing refs and git ls-remote --heads --tags origin to observe remote state without updating local refs. Record freshness; remote failure means UNKNOWN, not safe to delete. Fetch/prune is an optional approved mutation, never part of the nonmutating preview.
Tags: scan and classify tags nonmutantly before any deletion actions.
A name is not provenance. Enumerate git for-each-ref refs/tags --format='%(refname) %(objectname) %(*objectname)', peel each tag with git rev-parse 'refs/tags/<tag>^{commit}' and check git merge-base --is-ancestor <target> origin/$DEFAULT (0 reachable, 1 not reachable, other status inspection error). Record object ID, peeled commit, active-branch reachability, remote object, release status and explicit retention policy. Reachable does not mean disposable: release/signed/unknown-policy tags are KEEP; unreachable tags may be the only recovery handle and are KEEP/NEEDS ATTENTION. Only owner-approved disposable tags are deletion candidates.
Include candidate tags in the presented plan (Step 4) and ONLY delete tags after
explicit user approval:
# Executed only after user confirmation in Step 5:
git tag -d <tag-name> # delete locally
git push origin --delete refs/tags/<tag-name> # delete remotely
Do not assume main:
git symbolic-ref -q --short refs/remotes/origin/HEAD 2>/dev/null | sed 's@^origin/@@'
If that fails, fall back to checking whether main or master exists
locally. Use the result as $DEFAULT.
Run both classifiers. Results feed the single plan in Step 4.
Cross-reference: git branch -vv (tracking status), git branch --merged origin/$DEFAULT (local merged), git branch -r --merged origin/$DEFAULT
(remote merged), git branch -r --no-merged origin/$DEFAULT (context).
Bucket every branch into one of:
--merged, not the default branch. Safe to git branch -d.-r --merged, not origin/HEAD and not origin/$DEFAULT. Safe to git push origin --delete.git branch -vv shows tracking remote as gone AND branch is not in --merged. Unmerged work; flag for user attention, do not delete.See references/branch-classification.md for edge cases (squash-merged
branches that don't appear in --merged, detached HEAD, etc).
git worktree list
The first entry is the main worktree (the repo root) — never a candidate. For each secondary worktree, classify as either:
$DEFAULT OR squash-merged with empty diff vs $DEFAULT OR uncommitted changes all match $DEFAULT. Safe to git worktree remove --force.The detection commands and the exact "safe" definition live in
references/worktree-cleanup-rules.md. Use them — do not eyeball.
Show one combined plan, grouped by category, with counts and reasons:
Post-merge cleanup plan ($DEFAULT = main)
Local branches to delete (fully merged) — N:
- feat/add-retry
- chore/bump-deps
Remote branches to delete (fully merged) — M:
- origin/feat/add-retry (or: already pruned by GitHub)
Tags to delete (owner-approved disposable policy) — T:
- snapshot/example [object SHA, peeled commit SHA, remote SHA, retention reason]
Tags kept / unknown — U:
- v1.0.0 [release]
Worktrees to remove (safe) — P:
- .claude/worktrees/heuristic-northcutt [claude/heuristic-northcutt] — branch merged
- .worktrees/auth-feature [feat/auth] — squash-merged (empty diff)
Needs attention (will NOT touch) — K:
- branch: experimental — remote gone, unmerged work
- worktree: .worktrees/spike-foo — 3 files differ from main
Keeping — J active branches, 1 main worktree.
If a category is empty, say so explicitly ("No orphaned branches.") rather than omitting it — the user should see every category was checked.
--dry-run: print the plan and stop.--yes: authorizes only the explicitly requested cleanup scope; it never implies remote tag deletion or an unknown retention policy. Still print the exact plan first.Order matters: remove worktrees before deleting their branches, otherwise
git branch -d refuses because the branch is checked out elsewhere.
Remove safe worktrees first:
git worktree remove --force <worktree-path>
--force is needed because the worktree shows local modifications relative
to its HEAD — those changes are already on $DEFAULT, which is why we
classified it safe. The classification IS the safety net.
Delete local merged branches:
git branch -d branch1 branch2 branch3
Lowercase -d refuses to delete unmerged branches as a backstop. Never use
-D unless a squash-merge was confirmed (empty diff vs $DEFAULT) or the
user explicitly asked to force-delete.
Delete remote merged branches:
git push origin --delete branch1 branch2 branch3
Use bare names — strip origin/. "remote ref does not exist" is expected
when GitHub already deleted on PR merge; note and move on.
Before deleting tags, recheck local and remote object IDs against the approved plan. Any drift blocks deletion. Delete only listed local/remote tag scopes; remote deletion requires explicit authorization and a lease bound to the observed object. A failed remote command is not success.
Prune worktree metadata and tracking refs (approved execution only):
git worktree prune
git fetch origin --prune
Show the final state with git branch -vv and git worktree list. Report:
local branches deleted, remote branches deleted, worktrees removed, items
flagged for attention, and what remains.
When resolving a merge conflict in an automated/non-interactive context,
git merge --continue opens Vim for the commit message and hangs indefinitely.
Use one of these instead:
GIT_EDITOR=true git merge --continue # accept auto-generated message
git commit -m "Merge branch 'X' into Y" # explicit message
git merge --continue does NOT accept --no-edit (it takes no arguments),
so the GIT_EDITOR env var is the reliable path.
$DEFAULT, develop, staging, or production.-d before uppercase -D. Always.--merged — covered by the empty-diff
check in references/worktree-cleanup-rules.md; same check applies to
branches without worktrees.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub ivy00johns/skill-madness --plugin skill-madness87 skills in this plugin
/accessibility-auditAudit and fix web accessibility against WCAG 2.2 AA, Section 508 and the ADA: axe scan, keyboard, screen-reader and zoom checks, plain-language content and PDFs, source fixes, and an honest conformance report (ACR/VPAT draft). Use for any a11y review, fix or compliance question. Trigger on "accessibility audit", "is this ADA compliant", "Section 508", "WCAG", "VPAT", "a11y"./andonRun work through a live Andon board (the kanban that dispatches cards to Claude Code, Codex and Gemini on your machines): push a plan's cards with the skills each run must load, read the board, answer what needs you, administer a machine, and refresh this skill when Andon changes. Trigger on "/andon", "put this plan on andon", "what needs me on andon", "why isn't my card running".
/Other plugins' skills for the same job