# cleanup-merged-branches

Finds remote branches tied to merged pull requests, runs a dry-run preview, and deletes them only after your direct confirmation. Keeps remote repos clean without accidental data loss.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode · 656 installs
- Author: timschoch
- License: not stated · policy=link-only · description only; the file stays with the author
- Source: https://github.com/timschoch/skilly/tree/HEAD/bundles/workflow/skills/cleanup-merged-branches/SKILL.md
- Updated: 2026-10-23
- HTML: https://affpapa.org/en/nevibecode/skills/cleanup-merged-branches

## What it does

Branch clutter builds up rapidly when multiple agents work on a repository. This skill inspects remote tracking branches using `scripts/plan.sh`, selecting branches associated with merged pull requests that lack remaining open PRs. The default branch alongside `staging` are guarded unconditionally. Before altering remote state, the agent outputs a formatted candidate list and waits for explicit approval.

Task tracking receives a similar cleanup step via `scripts/stale-claims.sh`. When an agent session crashes or abandons an issue with an `in-progress` label for over 24 hours without an open PR, the helper strips the tag and assigns `ready-for-agent`. It also catches issues merged into integration branches that GitHub failed to resolve automatically.

Both `bash` and the official `gh` CLI tool must be present in your environment. Without GitHub CLI authorization, inspecting issue states and altering task labels fails immediately.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add timschoch/skilly --skill cleanup-merged-branches -a claude-code
```

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

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add timschoch/skilly --skill cleanup-merged-branches -a codex
```

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

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add timschoch/skilly --skill cleanup-merged-branches -a cursor
```

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

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install timschoch/skilly cleanup-merged-branches
```

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

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add timschoch/skilly --skill cleanup-merged-branches -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/timschoch/skilly --path bundles/workflow/skills/cleanup-merged-branches
```

### Windsurf (Devin Desktop)

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

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add timschoch/skilly --skill cleanup-merged-branches -a opencode
```

### 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/timschoch/skilly/tree/HEAD/bundles/workflow/skills/cleanup-merged-branches/SKILL.md

## When to use it
- prune remote branches after their pull requests are merged
- preview branch candidates via dry-run before deleting remote refs
- reclaim abandoned in-progress issues left behind by aborted agents
- close GitHub issues linked to PRs merged into integration branches

## Example prompts
- Run a dry-run to list remote merged branches ready for cleanup
- Prune merged branches on origin after showing me the plan
- Reap stale in-progress issue claims that have no active pull request

## Similar
- [triage](https://affpapa.org/en/nevibecode/skills/triage.md) — skill · 990453 installs
- [code-review](https://affpapa.org/en/nevibecode/skills/code-review.md) — skill · 789521 installs
- [implement](https://affpapa.org/en/nevibecode/skills/implement.md) — skill · 774700 installs
- [git-guardrails-claude-code](https://affpapa.org/en/nevibecode/skills/git-guardrails-claude-code.md) — skill · 499069 installs
- [setup-pre-commit](https://affpapa.org/en/nevibecode/skills/setup-pre-commit.md) — skill · 489289 installs
- [scaffold-exercises](https://affpapa.org/en/nevibecode/skills/scaffold-exercises.md) — skill · 480196 installs

From the same set: [timschoch/skilly](https://affpapa.org/en/nevibecode/by/timschoch/skilly.md) — 16 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
