.claude/skills/branch-audit/SKILL.md
Audit branches in the current git repo — identify which are safe to delete, which have open PRs, and which need a decision. Use when asked to "audit branches", "clean up branches", "triage branches", or similar.
npx skillsauth add sebjacobs/dotfiles branch-auditInstall 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.
Produces a categorised branch status table, then stops. Does not delete or modify anything unless the user explicitly asks.
git branch --format='%(refname:short)' | grep -v '^main$'
Two checks are needed — git branch --merged only catches merge-commit merges, not rebase fast-forwards:
# Check 1: is the branch an ancestor of main? (merge-commit merge)
git merge-base --is-ancestor <branch> main && echo "ANCESTOR"
# Check 2: is the diff empty? (rebase fast-forward — changes are on main, branch is stale)
git diff main...<branch> --stat
A branch is safe to delete if either:
merge-base returns true), ORgit diff main...<branch> --stat produces no output (empty diff)gh pr list --state all --limit 100 --json number,title,headRefName,state,mergedAt
Map each branch to its PR (if any). PR states:
OPEN — active work, do not touchMERGED — PR merged; if diff is also empty, safe to deleteCLOSED (not merged) — abandoned PR; flag for decisionPresent results in three sections:
Safe to delete — empty diff or merged ancestor. No risk. | Branch | PR | Notes | |--------|-----|-------|
Active — open PR, leave alone | Branch | PR | Size (files changed) | |--------|-----|---------------------|
Needs a decision — closed/abandoned PR, or changes with no PR | Branch | PR state | Situation | |--------|----------|-----------|
For the "Needs a decision" rows, include a one-line assessment: e.g. "superseded by X", "orphaned — no PR, 3 files changed", "PR closed without merging".
Do not delete, push, or propose any git commands. Present the table and ask the user what they'd like to do. If they say "delete the safe ones", proceed branch by branch — local first, then remote — confirming each group before acting.
main branch; if the default branch is master or something else, adjust the main referencesgit branch -a with remotes/origin/ prefix — include them in the audit but note they are remote-onlygh is not available, skip the PR cross-reference and note that PRs could not be checkeddevelopment
Run the session start routine — ask about available time and hard stops, read recent session logs and ROADMAP.md priorities, propose a realistic goal. Use when the user says "/start", "/start-session", "let's start", "start session", "begin session", or at the start of any longer session. Skip for quick focused tasks where the goal is already clear.
development
Mid-session checkpoint — snapshot current decisions and progress without archiving or cleaning up. Use when the user says "/save", "checkpoint", "save progress", or before risky operations like schema migrations, large refactors, or long-running tasks.
tools
Recover context from a crashed or unfinished session by reading the most recent JSONL transcript. Use when the user says "/recover", "recover session", "what was I doing", or when /start detects the last entry isn't a finish.
testing
TDD ping-pong pairing mode — collaborative spec, alternating test-write and implement roles