gh-clean-brancheslisted
Install: claude install-skill seansmithworks/agent-skills
# Clean Branches
Prune stale local branches. Two kinds of branch debt cleaned up in one pass: branches whose remote is gone, and feature branches already merged into main.
Triggered by: `/gh-clean-branches`, "clean branches", "prune branches", "delete stale branches".
## Steps
### 1. Sync remote refs
```bash
git fetch --prune
```
This removes remote-tracking refs for branches that no longer exist on the remote. Required before detection — without it, gone branches won't show as gone.
### 2. Detect branches with gone remotes
```bash
git branch -vv | grep ': gone]'
```
Lists local branches whose upstream tracking remote has been deleted (e.g., merged PRs where the branch was auto-deleted on GitHub).
### 3. Detect merged feature branches
```bash
git branch --merged main
```
Also try `master` if `main` doesn't exist. Lists local branches fully merged into main. Exclude: `main`, `master`, `develop`, `staging`, and the currently checked-out branch.
### 4. Present combined candidate list
Show a single deduplicated table:
```
Branches to delete:
┌──────────────────────────────┬─────────────────────────────┐
│ Branch │ Reason │
├──────────────────────────────┼─────────────────────────────┤
│ feat/old-login │ remote gone │
│ fix/button-color │ merged into main │
│ chore/deps-update │ remote gone + merged │
└──────────────────────────────┴────