Use when cleaning up local branches, deleting merged branches, pruning stale or gone branches, or tidying `git branch` output. Removes branches whose work has already landed, including squash-merged PRs.
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Clean Branches?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/tartinerlabs-clean-branches)
---
name: clean-branches
description: Use when cleaning up local branches, deleting merged branches, pruning stale or gone branches, or tidying `git branch` output. Removes branches whose work has already landed, including squash-merged PRs.
license: MIT
allowed-tools: Read Bash(git fetch --prune *) Bash(git branch -vv *) Bash(git branch --merged *) Bash(git branch -d *) Bash(git branch --dry-run --delete-merged *) Bash(git branch --delete-merged *) Bash(git --version) Bash(git worktree list *) Bash(git symbolic-ref *) Bash(git rev-parse *) Bash(git remote get-url *) Bash(gh pr list *) Bash(glab mr list *)
model: haiku
effort: low
compatibility: Requires git; `--delete-merged` needs git 2.56+. Squash-merge detection uses a GitHub (gh) or GitLab (glab) remote
metadata:
short-description: Delete local branches that are already merged.
title: Clear out old branches
goal: keep-code-tidy
audience: developers
---
You delete local branches whose work has already landed, and leave everything else alone.
## Rules Overview
| Rule | Impact | File |
|------|--------|------|
| Merged detection | HIGH | [rules/merged-detection.md](rules/merged-detection.md) |
## Workflow
1. Sync remote state and note the branches that must never be deleted: the current one, and any checked out in a worktree
2. **Native pass**: let git delete the branches it can prove merged into their upstream, previewing first. Skip on git older than the version [rules/merged-detection.md](rules/merged-detection.md) names
3. **Gap pass**: collect the branches the native pass skips (gone or missing upstream), and keep a candidate only when git or the forge confirms it landed. For the forge check, load **only** the matching guide: [references/github.md](references/github.md) for a `github.com` remote (the default), [references/gitlab.md](references/gitlab.md) for GitLab
4. Show the combined list with the evidence per branch (e.g. `#93 merged`, `merged into main`) and confirm before deleting
5. Report what was deleted and what was kept, with the reason for each kept branch — closed-unmerged PR, no PR, upstream ahead, checked out
## Keep, don't guess
A branch with a closed-but-unmerged PR or no PR at all may hold unfinished work. List it as kept and let the user decide; never delete it on age or name alone. Remote branches are out of scope — this skill only touches local refs.