From systematic
Clean up local branches whose remote tracking branch is gone. Use when the user says "clean up branches", "delete gone branches", "prune local branches", "clean gone", or wants to remove stale local branches that no longer exist on the remote. Also handles removing associated worktrees for branches that have them.
How this skill is triggered — by the user, by Claude, or both
Slash command
/systematic:git-clean-gone-branchesThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Delete local branches whose remote tracking branch has been deleted, including any associated worktrees.
Delete local branches whose remote tracking branch has been deleted, including any associated worktrees.
Run the discovery script to fetch the latest remote state and identify gone branches:
bash scripts/clean-gone
The script runs git fetch --prune first, then parses git branch -vv for branches marked : gone].
If the script outputs __NONE__, report that no stale branches were found and stop.
Show the user the list of branches that will be deleted. Format as a simple list:
These local branches have been deleted from the remote:
- feature/old-thing
- bugfix/resolved-issue
- experiment/abandoned
Delete all of them? (y/n)
Wait for the user's answer using the platform's question tool (e.g., question in OpenCode, request_user_input in Codex, ask_user in Gemini; in Pi, use the blocking-question extension if available, otherwise present numbered options in chat and wait). If no question tool is available, present the list and wait for the user's reply before proceeding.
This is a yes-or-no decision on the entire list -- do not offer multi-selection or per-branch choices.
If the user confirms, delete each branch. For each branch:
git worktree list | grep "\\[$branch\\]")git worktree remove --force "$worktree_path"git branch -D "$branch"Report results as you go:
Removed worktree: .worktrees/feature/old-thing
Deleted branch: feature/old-thing
Deleted branch: bugfix/resolved-issue
Deleted branch: experiment/abandoned
Cleaned up 3 branches.
If the user declines, acknowledge and stop without deleting anything.
npx claudepluginhub marcusrbrown/systematic --plugin systematicDeletes local branches whose remote tracking branch is gone, including associated worktrees. Useful for cleaning up stale branches after remote deletions.
Removes local git branches that have been deleted from the remote, including cleaning up associated worktrees.
Safely identifies and deletes merged and stale Git branches after fetching latest state, filtering by pattern, and user confirmation via interactive prompts. Protects main branches.