git-clean-gone-branches

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.

13,089 stars

Best use case

git-clean-gone-branches is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

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.

Teams using git-clean-gone-branches should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/git-clean-gone-branches/SKILL.md --create-dirs "https://raw.githubusercontent.com/EveryInc/compound-engineering-plugin/main/plugins/compound-engineering/skills/git-clean-gone-branches/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/git-clean-gone-branches/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How git-clean-gone-branches Compares

Feature / Agentgit-clean-gone-branchesStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

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.

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

Related Guides

SKILL.md Source

# 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
bash scripts/clean-gone
```

[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 question tool (e.g., `AskUserQuestion` in Claude Code, `request_user_input` in Codex, `ask_user` in Gemini). 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.

### 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.

Related Skills

skill-one

13089
from EveryInc/compound-engineering-plugin

Sample skill

disabled-skill

13089
from EveryInc/compound-engineering-plugin

A skill with model invocation disabled

default-skill

13089
from EveryInc/compound-engineering-plugin

No description provided.

custom-skill

13089
from EveryInc/compound-engineering-plugin

No description provided.

todo-triage

13089
from EveryInc/compound-engineering-plugin

Use when reviewing pending todos for approval, prioritizing code review findings, or interactively categorizing work items

todo-resolve

13089
from EveryInc/compound-engineering-plugin

Use when batch-resolving approved todos, especially after code review or triage sessions

todo-create

13089
from EveryInc/compound-engineering-plugin

Use when creating durable work items, managing todo lifecycle, or tracking findings across sessions in the file-based todo system

test-xcode

13089
from EveryInc/compound-engineering-plugin

Build and test iOS apps on simulator using XcodeBuildMCP. Use after making iOS code changes, before creating a PR, or when verifying app behavior and checking for crashes on simulator.

test-browser

13089
from EveryInc/compound-engineering-plugin

Run browser tests on pages affected by current PR or branch

slfg

13089
from EveryInc/compound-engineering-plugin

Full autonomous engineering workflow using swarm mode for parallel execution

setup

13089
from EveryInc/compound-engineering-plugin

Configure project-level settings for compound-engineering workflows. Currently a placeholder — review agent selection is handled automatically by ce:review.

resolve-pr-feedback

13089
from EveryInc/compound-engineering-plugin

Resolve PR review feedback by evaluating validity and fixing issues in parallel. Use when addressing PR review comments, resolving review threads, or fixing code review feedback.