git-plugin/skills/deadbranch/SKILL.md
deadbranch CLI for stale-branch cleanup — dry-run preview, TUI or non-interactive delete, protects main/develop/WIP. Use when asked to clean up branches, prune branches, or remove stale branches.
npx skillsauth add laurigates/claude-plugins deadbranchInstall 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.
Survey stale git branches and clean them up safely. Always previews before deleting; backup system means every deletion is recoverable.
| Use this skill when... | Use another approach when... |
|------------------------|------------------------------|
| Asked to clean up, prune, or remove stale branches across a repo | Deleting a single known branch — git branch -d <name> is simpler |
| You want a survey of branch health (age, merge status, count) first | Doing routine gc / repo maintenance — use /git:maintain |
| You want recoverable deletion with a dry-run preview and backups | Pruning remote-tracking refs only — git remote prune origin |
Parse from $ARGUMENTS (all optional):
| Flag | Default | Description |
|------|---------|-------------|
| --days N | 30 | Age threshold — branches older than N days are stale |
| --local | off | Target local branches only |
| --remote | off | Target remote branches only |
| --force | off | Include unmerged branches (dangerous — ask for explicit confirmation) |
| --interactive | off | Open full-screen TUI for visual selection |
| --dry-run | on | Show what would be deleted without deleting (always on for the preview step) |
| --yes | off | Skip confirmation prompts (only use if user explicitly asks for automation) |
| --stats-only | off | Run stats + list only, skip the clean step entirely |
When no flags are given, default to the survey-first workflow below.
Run in parallel:
deadbranch stats
deadbranch list
Report both outputs. The stats command shows total branch count, stale count, and age distribution. The list shows each stale branch with its age, merge status, last commit date, and author.
If --days N was provided, pass -d N to both commands.
If --local or --remote was provided, pass the flag to list.
If no stale branches are found, stop here and report the repo is clean.
If --stats-only was provided, stop here after reporting.
Always run a dry-run before any real deletion:
deadbranch clean --dry-run [--days N] [--local|--remote] [--force]
Report the dry-run output. If nothing would be deleted (e.g. all stale
branches are unmerged and --force was not set), explain why and offer
to re-run with --force if the user wants to include unmerged branches.
After the dry-run, ask the user what to do:
AskUserQuestion("Proceed with branch deletion?", options=[
"Yes — delete all shown branches",
"Interactive TUI — let me pick",
"No — survey only, skip deletion"
])
deadbranch clean [options]deadbranch clean --interactive [options]
(note: the TUI requires a real terminal — warn the user that this
opens a full-screen interface they must interact with directly via
! deadbranch clean --interactive)If the user passed --interactive in $ARGUMENTS, skip the question
and go straight to TUI mode.
If --yes was explicitly passed, skip confirmation and delete directly.
After deletion, confirm with:
deadbranch backup list
Report how many branches were deleted and that their SHAs are backed
up (recoverable via deadbranch backup restore <branch>).
| Situation | Action |
|-----------|--------|
| --force requested | Show extra warning: "This deletes unmerged branches. These are NOT recoverable from the remote." before dry-run |
| --remote requested | Note that remote deletion affects everyone on the team |
| Branch is WIP / draft | deadbranch skips these automatically; mention it in the report |
| Protected branches (main/master/develop/staging/production) | deadbranch skips these automatically |
If the user wants to recover a deleted branch:
deadbranch backup list # see what's saved
deadbranch backup restore <branch> # restore by name
Backups store the branch tip SHA. Restoration creates the branch locally pointing at that SHA.
# Default survey + dry-run + confirm
deadbranch list
deadbranch stats
deadbranch clean --dry-run
# Local branches only, 60-day threshold
deadbranch list --local --days 60
deadbranch clean --local --days 60 --dry-run
# Remote branches — team-visible action, ask twice
deadbranch list --remote
deadbranch clean --remote --dry-run
# Interactive TUI (run by user in their terminal)
! deadbranch clean --interactive
# Non-interactive automation (CI / scripts)
deadbranch clean --yes --merged
deadbranch clean --interactive opens a full-screen TUI with:
hjkl, / to fuzzy search)Claude Code cannot operate the TUI — instruct the user to run it
themselves with the ! prefix: ! deadbranch clean --interactive.
deadbranch reads ~/.deadbranch/config.toml. View with:
deadbranch config show
Key settings:
| Setting | Default | Description |
|---------|---------|-------------|
| general.default_days | 30 | Default age threshold |
| branches.default_branch | auto-detect | Default branch name |
| branches.protected | main, master, develop, staging, production | Never deleted |
| branches.exclude_patterns | wip/, draft/, */wip, */draft | Pattern-excluded |
To change a setting:
deadbranch config set general.default_days 60
Check availability first:
which deadbranch || echo "not installed"
Install via cargo (preferred — already in mise/Rust toolchain):
cargo install deadbranch
Or via Homebrew:
brew install armgabrielyan/tap/deadbranch
| Context | Command |
|---------|---------|
| Quick health stats | deadbranch stats |
| List stale (machine-survey) | deadbranch list --days 30 |
| Safe preview before delete | deadbranch clean --dry-run |
| Non-interactive cleanup | deadbranch clean --yes --merged |
| Recover a deleted branch | deadbranch backup restore <branch> |
testing
Verify accumulated bug claims at upstream HEAD and dedup against trackers before filing issues. Use when filing upstream reports from backlogs, audit docs, or git-history findings.
documentation
Gate outward-bound text (upstream issues, docs, PR bodies) through isolated haiku fresh-reader critique before publishing. Use when an artifact must survive a reader with zero project context.
tools
Suggest improvements to SKILL.md content, descriptions, or tool config from eval results. Use when raising pass rates, fixing triggering, or iterating on a skill after evaluation.
tools
End-of-session capture to taskwarrior, optional journal, GitHub issues. Use when user says wrap up, session wrap, or done for now.