# clean-branches

clean-branches is a Claude Code skill that finds merged and stale git branches, marks protected ones, and asks before deletion. It helps clear accumulated branch clutter.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf (Devin Desktop), Claude.ai · ★ 276 repo stars
- Author: Samarth Gupta
- License: not stated · policy=link-only · description only; the file stays with the author
- Source: https://github.com/gupsammy/Claudest/tree/HEAD/plugins/claude-coding/skills/clean-branches/SKILL.md
- Updated: 2026-10-29
- Security check: automated, 2026-11-16 (text) — no signs of malicious code found.
- HTML: https://affpapa.org/en/nevibecode/skills/samarth-gupta-clean-branches

## What it does

clean-branches sorts branches into four groups: merged into the base branch, without recent commits, protected (main, master, develop, release/*), and blocked (active worktrees with uncommitted changes). It fetches the latest state from the remote, runs a detection script that flags worktree associations and squash-merged branches, then presents a confirmation dialog before executing any deletions.

The skill works through four phases. First, it updates branch metadata via `git fetch --all --prune`. Next, it identifies candidates using a local script that parses annotations: active worktrees and branches merged via squash or rebase. Branches with uncommitted changes in their worktrees are moved to a blocked list. The user then selects branches to remove through a structured prompt. Finally, it deletes worktrees first (if any), then branches locally using `-d` for regular merges and `-D` for squash/rebase-merged branches, then offers remote deletion.

Requires Bash and standard git commands. If no remote is configured, it continues with local branch analysis. The script preserves worktrees unless explicitly authorised by the user's selection.

## Install

### Claude Code (native platform)

1. **Plugin marketplace**
In the agent chat (not a shell):
```text
/plugin marketplace add gupsammy/Claudest
```
In the agent chat (not a shell):
```text
/plugin install claude-coding@Claudest
```
This installs the whole claude-coding plugin with all its skills

2. **Skills CLI (Vercel)**
```bash
npx skills add gupsammy/Claudest --skill clean-branches -a claude-code
```

3. **Manually: put the files in place**
- File: `~/.claude/skills/clean-branches/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/clean-branches/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add gupsammy/Claudest --skill clean-branches -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/clean-branches/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add gupsammy/Claudest --skill clean-branches -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/clean-branches/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install gupsammy/Claudest plugins/claude-coding/skills/clean-branches
```

2. **Manually: put the files in place**
- File: `.github/skills/clean-branches/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add gupsammy/Claudest --skill clean-branches -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/gupsammy/Claudest --path plugins/claude-coding/skills/clean-branches
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/clean-branches/SKILL.md` — The legacy .windsurf/skills/ path still works

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/gupsammy/Claudest/tree/HEAD/plugins/claude-coding/skills/clean-branches/SKILL.md

## When to use it
- Delete all branches merged into main after finishing features
- Prune branches with no commits for 30 days or more
- Remove branches matching a pattern, such as feature/*
- Safely delete a branch that was merged via a rebase-merge pull request

## Example prompts
- Clean up old branches in this repository
- Remove all merged feature branches
- Delete stale branches matching the hotfix/* pattern

## Similar
- [comparing-branches-visually](https://affpapa.org/en/nevibecode/skills/comparing-branches-visually.md) — skill · 421 installs
- [clean_gone](https://affpapa.org/en/nevibecode/commands/clean-gone.md) — command · ★ 47914 repo stars
- [branch-cleanup](https://affpapa.org/en/nevibecode/commands/branch-cleanup.md) — command · 342 installs
- [om-auto-create-pr](https://affpapa.org/en/nevibecode/skills/om-auto-create-pr.md) — skill · 4700 installs
- [om-auto-continue-pr](https://affpapa.org/en/nevibecode/skills/om-auto-continue-pr.md) — skill · 4600 installs
- [afk](https://affpapa.org/en/nevibecode/skills/jakubkrehel-afk.md) — skill · 3900 installs

## Other versions with the same name
- [clean-branches · dyoshikawa](https://affpapa.org/en/nevibecode/skills/clean-branches.md) — ★ 1636 repo stars

From the same set: [gupsammy/claudest](https://affpapa.org/en/nevibecode/by/gupsammy/claudest.md) — 47 cards

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
