SolidMITOriginal

Branch Cleanup

Lists merged and stale local branches, deletes the safe ones, flags the rest.

Entry verified April 21, 2026

The short answer

Local branch lists accumulate fast when you’re shipping multiple PRs a week. This skill runs git fetch --prune, classifies each local branch (merged / ahead / stale), and deletes the merged ones after confirming — never the ones you haven’t pushed.

When to use it

Monthly hygiene, or any time git branch starts spilling past one screen. Especially after a flurry of PR merges.

Setup

  1. 1

    Save as ~/.claude/commands/branch-cleanup.md. Skill runs git fetch --prune, then iterates local branches and classifies each against its upstream.

  2. 2

    Never deletes main, master, or branches listed in a PROTECTED allowlist (add it to the skill body).

  3. 3

    Always confirms before each delete — no batch --force mode.

Example

You: /branch-cleanup
Claude: [fetches, scans 14 local branches]
       9 merged-to-main (safe to delete)
       3 ahead of main (skipped — unpushed work)
       2 protected (main, staging)
       Delete the 9? [y/N]

Source & attribution

Licence
MIT (author's own work)
Type
Original

Original pattern published under MIT — attribution preserved by convention, not licence requirement.

Caveats

Shared repos: check with collaborators before deleting branches others may be using. Never run with --force.

New skills, explained plainly.

One short email when a new Claude Code skill is worth installing — and when to skip the hype. No spam.

56 skills across 10 categories, all licence-verified.