一键导入
git-branch-cleanup
Safely inspect and clean up local branches whose remote counterparts have been deleted, with explicit approval before deletions.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Safely inspect and clean up local branches whose remote counterparts have been deleted, with explicit approval before deletions.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Orchestrate Birdhouse child agents to investigate PR review feedback in parallel, classify it as strengthened, weakened, or invalidated, then address approved items serially with fixes or threaded replies.
Create isolated working directories using git worktrees without affecting the main workspace. Use when you want to use worktree, git worktree, worktree workflow, isolated development, work in worktree, create worktree, or worktree best practices.
Reply to GitHub PR review comments as threaded responses using the GitHub API replies endpoint.
Generate release notes from git branch commit history and analyze changes. Use when you want to generate release notes, prepare release notes, prep for a PR, find what changed in this branch, or get branch change summary.
Create GitHub pull requests using gh CLI with proper formatting for multi-line descriptions. Use when you want to create a pr, submit a pr, pull request, create a pull request, submit a pull request, open a pr, or new pr.
Core software development principles: code for readability and changeability, apply DRY wisely, test for confidence, and crash loudly on unexpected conditions.
| name | git-branch-cleanup |
| description | Safely inspect and clean up local branches whose remote counterparts have been deleted, with explicit approval before deletions. |
| trigger_phrases | ["branch cleanup","clean up branches","delete gone branches","remove stale branches"] |
| tags | ["git"] |
Use this skill to safely inspect and clean up local branches whose remote tracking branches are gone.
This skill is intentionally conservative.
Start by pruning deleted remote refs.
git fetch --prune
This updates your local view of which remote branches still exist.
Find local branches whose tracking branch is gone.
git branch -vv | grep ': gone]'
Useful follow-up commands:
# Count stale branches
git branch -vv | grep -c ': gone]'
# Show all local branches with tracking info
git branch -vv
The goal here is to inspect, not delete.
If the repo uses worktrees, inspect them too.
git worktree list
git worktree prune --dry-run
Look for:
Before making changes, present a short cleanup plan to the user.
Include:
git branch -dRecommended presentation shape:
Safe to deleteNeeds force deleteStale worktree metadataWorktrees needing reviewAsk explicitly which items should be cleaned up.
For approved branches, prefer safe deletion:
git branch -d branch-name
If deleting multiple approved branches, do it as a reviewed list, not a blind one-liner.
Example:
git branch -d branch-one branch-two branch-three
If a branch does not delete cleanly, stop and report why instead of automatically escalating.
If a branch still contains unmerged work and the user wants it removed anyway:
git branch -D branch-name
Use this only after the user explicitly approves force deletion.
Handle worktrees separately from branches.
Stale metadata only:
git worktree prune
Remove a specific worktree directory only with explicit approval:
git worktree remove path/to/worktree
If a branch is still checked out in a worktree, resolve that relationship before deleting the branch.
After cleanup, verify the remaining state.
# Remaining stale branches
git branch -vv | grep ': gone]' || true
# Current branches
git branch -vv
# Current worktrees
git worktree list
Report back with:
This is usually a single-agent task.
If the repo has many worktrees or a confusing branch state, it can help to delegate inspection to one child agent and keep deletion decisions with the main agent. Even then, only one agent should perform the actual cleanup commands.