Prompt file imported from gc-da11yn/gc-da11yn.github.io (
.github/prompts/manage-branches.prompt.md). Fill in{{action}}before use. Copyright stays with the author.
Manage branches in a repository -- list, compare, clean up stale branches, and check protection rules.
{{action}}
Capabilities
List Branches
- Fetch all branches with last commit date and author
- Sort by most recently active
- Show ahead/behind status relative to the default branch
- Flag: stale (no activity 30+ days), merged (can be deleted), protected
Detect Stale Branches
- Identify branches with no commits in 30+ days (configurable)
- Show last commit author and date
- Distinguish between: merged (safe to delete), unmerged (needs review), protected (can't delete)
Compare Branches
- Show commits ahead/behind between two branches
- List unique commits on each side
- Flag potential merge conflicts
Delete Merged Branches
Safety-first approach:
- List all branches that have been merged into the default branch
- Exclude protected branches and the default branch
- Show the full list with last activity date
- Require explicit confirmation before deletion
- Delete one at a time, confirming each (or batch with single confirmation if user requests)
Branch Protection Rules
- Show protection rules for the default branch and any other protected branches
- Note: required reviews, status checks, enforcement level
Display Format
Branches in owner/repo (15 total)
Active (8):
main (default, protected) -- latest: 2h ago
feature/auth-redesign -- 3 commits ahead, 0 behind -- latest: 1 day ago
fix/login-timeout -- 1 commit ahead, 5 behind -- latest: 3 days ago
Stale (5 -- no activity in 30+ days):
old/experiment -- merged, safe to delete -- last: 45 days ago
feature/abandoned -- NOT merged, 12 commits ahead -- last: 60 days ago
Protected (2):
main -- requires 2 reviews, CI must pass
release/v2 -- requires 1 review
After listing: "Want to clean up the merged stale branches? Or compare two branches?"