skills/git-cleanup/SKILL.md
--- name: git-cleanup description: Prune local git branches that are already on main, detecting classic merges, squash-merges via merged PRs, and content-in-main via diff. Confirms with the user before deleting. Use when the user wants to clean up, prune, or delete merged branches, or asks which branches are safe to delete. category: development argument-hint: [--base main] [--dry-run] [--include-archive] [--yes] allowed-tools: Bash(git *) Bash(gh *) --- # Git Cleanup List every local branch,
npx skillsauth add RonanCodes/ronan-skills skills/git-cleanupInstall 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.
List every local branch, classify it against main, and delete the ones the user confirms. Works with squash-merge workflows where git branch --merged is blind.
git branch --merged main only detects merge-commits and fast-forwards. Under a squash-only workflow (see /ro:new-tanstack-app step 13a and connections-helper/docs/adr/0002-github-branch-protection-squash-only-merges.md), branches get merged by replaying their diff into a new single commit on main. The original commit SHAs are never in main's history, so --merged marks them as unmerged even though their content is fully landed.
This skill combines three detection strategies so the result is correct regardless of merge strategy.
/ro:git-cleanup # interactive, asks before deleting
/ro:git-cleanup --dry-run # show the report, touch nothing
/ro:git-cleanup --base master # if the repo uses master instead of main
/ro:git-cleanup --include-archive # include branches named backup/*, archive/*, heads/*
/ro:git-cleanup --yes # skip confirmation, delete every confirmed-merged branch
For each local branch (excluding current + base):
git branch --merged <base>. Deletable with -d.gh pr list --head <branch> --state merged --json number returns at least one merged PR. The original commits are not in main but the PR was merged. Deletable with -D (force).git diff <base>..<branch> is empty. The branch's tree is identical to main. Deletable with -D. (Rare but possible: branch was rebased to match main without a PR, or the same changes were committed independently on both.)Branch names matching backup/*, archive/*, heads/* are treated as archive-intentional and skipped by default. Include with --include-archive.
# Ensure we're in a git repo
git rev-parse --git-dir >/dev/null 2>&1 || { echo "not a git repo"; exit 1; }
# Working tree cleanliness is NOT required (we're only touching refs, not files)
# Base branch exists
BASE=${BASE:-main}
git rev-parse --verify "$BASE" >/dev/null 2>&1 || { echo "base branch $BASE not found"; exit 1; }
# Stash current state? No: we don't modify the tree. But if current branch is
# about to be deleted (shouldn't happen, we skip current), bail.
CURRENT=$(git rev-parse --abbrev-ref HEAD)
git fetch --prune origin
This also removes stale origin/* remote-tracking branches whose remote was auto-deleted by delete_branch_on_merge: true.
Build a table. One row per local branch (excluding $CURRENT and $BASE):
for branch in $(git for-each-ref --format='%(refname:short)' refs/heads/ | grep -vE "^($CURRENT|$BASE)$"); do
# Skip archive-ish names unless --include-archive
if [[ "$branch" =~ ^(backup|archive|heads)/ ]] && [ -z "$INCLUDE_ARCHIVE" ]; then
status="archive-skip"
# Strategy 1: classic merge
elif git branch --merged "$BASE" | grep -qE "^ $branch$"; then
status="classic-merged"
# Strategy 2: merged PR on GitHub
elif command -v gh >/dev/null && gh pr list --head "$branch" --state merged --json number --jq '.[0].number' 2>/dev/null | grep -q .; then
pr=$(gh pr list --head "$branch" --state merged --json number --jq '.[0].number')
status="squash-merged-pr#$pr"
# Strategy 3: content in main
elif [ -z "$(git diff "$BASE..$branch")" ]; then
status="content-in-main"
else
# Check unpushed / ahead state
ahead=$(git rev-list --count "$BASE..$branch")
status="unmerged-ahead-$ahead"
fi
echo "$status | $branch"
done
Print a grouped summary. Example:
Classic-merged (safe, -d deletion):
- chore/pnpm-pin
- fix/og-external-fonts
Squash-merged via PR (use -D, PR confirms intent):
- chore/github-hygiene-and-commitlint (PR #19 merged)
- test/visual-home-baselines (PR #18 merged)
Content matches main (use -D):
- feat/rebased-onto-main
Archive-style (kept by convention, use --include-archive to delete):
- backup/feat-prism-mock-server-pre-split
- heads/pre-tanstack-migration
Unmerged (NOT proposed for deletion):
- feat/wip-xyz (3 commits ahead of main)
Stashes on this repo (informational only, not touched):
- stash@{0}: user-wip-prism-mock (73 minutes ago)
- stash@{1}: pre-migration-working-state (6 days ago)
Use AskUserQuestion with 3 options:
Skip the question if --yes was passed.
# classic-merged: -d (asserts git thinks it's merged)
git branch -d "$branch"
# squash-merged-pr / content-in-main: -D (force, because git doesn't know)
git branch -D "$branch"
Record each deletion and its prior SHA in the final summary, so the user can recover with git branch <name> <sha> if a delete was wrong.
Print:
unmerged-ahead-N (future /ro:git-cleanup runs will keep skipping them).gh installed: skip strategy 2. Classic-merged + content-in-main still work, so the skill is still useful, just misses squash-merged-PR cases where the branch had no patch-equivalent landing.gh: strategy 2 fails silently (its query errors, we treat as "no merged PR"). Report at the end: "gh auth missing, squash-merge detection was skipped, here are the branches that could have been squash-merged that we couldn't verify."origin: fetch step no-ops. All detection still works against the local $BASE.$CURRENT). Print a note suggesting git checkout $BASE then re-run.main has moved since last fetch: fetch step at the start prevents stale classification.git branch --merged <base> uses local <base>, not origin/<base>. Without the fetch, a branch merged to origin but not pulled locally would be misclassified as unmerged. The fetch step prevents this.gh pr list --head <branch> matches the branch name, not the SHA. If the branch was renamed after the PR merged, detection misses it. Unusual edge case.git branch <name> <sha> can recover./ro:stacked-prs: the rebase flow this skill's output enables (once the parent is cleanly merged-and-pruned)./ro:gh-ship: opens the PR in the first place. Most branches this skill deletes were opened by gh-ship.connections-helper/docs/adr/0002-github-branch-protection-squash-only-merges.md.github-branch-protection-and-squash-merges in llm-wiki-research.testing
--- name: linear-pipeline description: The Fable orchestrator for a single dispatched Linear ticket. Holds almost no context itself; it receives `--issue <ID> --detached`, decides the stage sequence, and fans out a sub-agent per stage, passing forward only each stage's artifact (never re-derived, never inlined into its own context). Step zero, before any planning or stage routing, is a boundary triage against `canon/security-boundary.md` (#199): a match tags Ronan Connolly and stops the run, no
development
--- name: in-your-face description: Capture a chat-only answer into a durable artifact (markdown + HTML, PDF when cheap) and launch it automatically so the user cannot miss it. Use when user says "in your face", "don't let me lose this", "save that answer", "make that durable", or right after answering a substantive side question (a recipe, comparison, how-to, or generated prompt) that would otherwise die with the context. category: workflow argument-hint: [--no-open] [--vault <short>] [hint of
tools
One-shot headless OpenAI Codex CLI calls for background/admin AI tasks — summaries, classification, extraction, admin glue. The default engine for anything that runs AI constantly in the background (daemon-driven, per-event), because it bills the flat ChatGPT subscription instead of Claude usage or per-token API spend, and it keeps working while Claude is rate-limited. NEVER for coding — coding stays Claude. Use when a skill or daemon needs a cheap always-on AI call, when the user says "use codex", "ask codex", "codex as backup", or when building a background summarizer/classifier into a listener or loop. Reads auth from ~/.codex/auth.json (ChatGPT account, no API key).
research
Turn a warranty rejection, repair quote, or RMA email into a cited decision brief — legal read (NL/EU consumer law), is the part user-serviceable, live part and new-unit prices, repair-vs-DIY-vs-new economics, before-you-send-it checklist, deadlines. Use when the user pastes or screenshots a repair quote, warranty rejection, "not covered" email, onderzoekskosten fee, or asks "should I repair or replace this".