PluginBench
Skill
Pass
Audit score 90

ce-clean-gone-branches

everyinc/compound-engineering-plugin

Delete local branches whose remote tracking branch is gone, including associated worktrees.

What is ce-clean-gone-branches?

Cleans up stale local Git branches that no longer exist on the remote after their tracking branch has been deleted. Use this when you want to remove branches that are no longer needed and keep your local repository tidy.

  • Fetches latest remote state and identifies local branches marked as gone
  • Displays list of stale branches for confirmation before deletion
  • Removes associated worktrees for branches that have them
  • Deletes confirmed branches using git branch -D
  • Reports results of cleanup operation

How to install ce-clean-gone-branches

npx skills add https://github.com/everyinc/compound-engineering-plugin --skill ce-clean-gone-branches
Claude Code
Cursor
Windsurf
Cline

How to use ce-clean-gone-branches

  1. 1.Run the discovery script: bash scripts/clean-gone
  2. 2.Review the list of branches marked as gone
  3. 3.Confirm deletion when prompted (yes/no)
  4. 4.Script removes any associated worktrees first, then deletes each branch
  5. 5.Review the cleanup report showing deleted branches and worktrees

Use cases

Good for
  • Remove local branches after their remote counterparts have been deleted during code review cleanup
  • Prune stale feature branches after they've been merged and deleted on the remote
  • Clean up abandoned experiment branches that no longer exist upstream
  • Maintain a lean local branch list by removing branches orphaned by remote deletions
Who it's for
  • Git users managing multiple branches
  • Development teams with frequent branch deletions
  • Developers using git worktrees for parallel work

ce-clean-gone-branches FAQ

What happens if I decline the deletion prompt?

The script stops without deleting anything. Your branches remain unchanged.

Will this delete my main/master branch?

No. The script only targets branches whose remote tracking branch is gone. Main branches typically still exist on the remote.

What if a branch has an associated worktree?

The script automatically removes the worktree first (with --force if needed), then deletes the branch.

How does the script identify gone branches?

It runs git fetch --prune to sync remote state, then parses git branch -vv output for branches marked with ': gone]'.

Full instructions (SKILL.md)

Source of truth, from everyinc/compound-engineering-plugin.


name: ce-clean-gone-branches description: 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.

Clean Gone Branches

Delete local branches whose remote tracking branch has been deleted, including any associated worktrees.

Workflow

Step 1: Discover gone branches

Run the discovery script to fetch the latest remote state and identify gone branches:

bash scripts/clean-gone

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.

Step 2: Present branches and ask for confirmation

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 blocking question tool: AskUserQuestion in Claude Code (call ToolSearch with select:AskUserQuestion first if its schema isn't loaded), request_user_input in Codex, ask_user in Gemini, ask_user in Pi (requires the pi-ask-user extension). Fall back to presenting the list in chat only when no blocking tool exists in the harness or the call errors (e.g., Codex edit modes) — not because a schema load is required. Never silently skip the question.

This is a yes-or-no decision on the entire list -- do not offer multi-selection or per-branch choices.

Step 3: Delete confirmed branches

If the user confirms, delete each branch. For each branch:

  1. Check if it has an associated worktree (git worktree list | grep "\\[$branch\\]")
  2. If a worktree exists and is not the main repo root, remove it first: git worktree remove --force "$worktree_path"
  3. Delete the branch: 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.