Claude-skill-registry branch-cleaner
Identify and clean up stale git branches locally and on remotes with safe, reversible steps. Use when asked to prune, list, or delete merged/old branches or audit branch hygiene.
install
source · Clone the upstream repo
git clone https://github.com/majiayu000/claude-skill-registry
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/majiayu000/claude-skill-registry "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/data/branch-cleaner" ~/.claude/skills/majiayu000-claude-skill-registry-branch-cleaner && rm -rf "$T"
manifest:
skills/data/branch-cleaner/SKILL.mdsource content
Branch cleaner
Goal
Safely identify stale branches and provide explicit delete/prune commands.
Inputs to confirm (ask if missing)
- Default branch (main/master/develop).
- Remote name (origin) and whether remote deletion is desired.
- Safety rules: keep patterns (release/, hotfix/), minimum age, merged-only.
Workflow
- Sync and inspect
- Run
.git fetch --prune - Check
and note uncommitted changes.git status
- Run
- Build candidate lists
- Local merged into default:
git branch --merged <base> - Local not merged (list only):
git branch --no-merged <base> - Remote merged:
git branch -r --merged <base> - Stale by date:
git for-each-ref --sort=committerdate refs/heads --format="%(committerdate:short) %(refname:short)"
- Local merged into default:
- Exclude protected branches
- Always keep
, current branch, and user-provided patterns.<base>
- Always keep
- Confirm with user
- Present candidates grouped by local vs remote.
- Provide delete commands
- Delete branches approved for deletion by the user
Optional GitHub CLI checks
to correlate merged branches.gh pr list --state merged --base <base>
to verify status if needed.gh pr view <branch>
Deliverables
- Candidate lists and rationale.
- Warnings for unmerged or recently updated branches.
- Don't remove remote branches unless explicitly approved.