clean-branches · gupsammy — Claude Code skill: remove merged and stale 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.
no license ★ 276 updated 2026-10-29
/plugin marketplace add gupsammy/Claudest
/plugin install claude-coding@ClaudestWhat clean-branches 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.
What it helps with
- 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 for the agent
- Clean up old branches in this repository
- Remove all merged feature branches
- Delete stale branches matching the hotfix/* pattern
How to install clean-branches
1Plugin marketplace
/plugin marketplace add gupsammy/Claudest/plugin install claude-coding@ClaudestThis installs the whole claude-coding plugin with all its skills
2Skills CLI (Vercel)
npx skills add gupsammy/Claudest --skill clean-branches -a claude-code3Manually: put the files in place
~/.claude/skills/clean-branches/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/clean-branches/
1Skills CLI (Vercel)
npx skills add gupsammy/Claudest --skill clean-branches -a codex2Manually: put the files in place
.agents/skills/clean-branches/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add gupsammy/Claudest --skill clean-branches -a cursor2Manually: put the files in place
.cursor/skills/clean-branches/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install gupsammy/Claudest plugins/claude-coding/skills/clean-branches2Manually: put the files in place
.github/skills/clean-branches/SKILL.md1Skills CLI (Vercel)
npx skills add gupsammy/Claudest --skill clean-branches -a gemini-cli2Platform CLI
gemini skills install https://github.com/gupsammy/Claudest --path plugins/claude-coding/skills/clean-branchesManually: put the files in place
.devin/skills/clean-branches/SKILL.mdThe legacy .windsurf/skills/ path still works
Claude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
Step by step, with commands for each platform: How to install skills in Claude Code: five ways
Questions about clean-branches
How do I install clean-branches in Claude Code?
Run /plugin marketplace add gupsammy/Claudest, then /plugin install claude-coding@Claudest, then npx skills add gupsammy/Claudest --skill clean-branches -a claude-code, and open ~/.claude/skills/clean-branches/SKILL.md.
What does clean-branches do?
It scans your git repository for branches that are merged into the base or have no recent commits, displays them grouped with worktree and merge-type annotations, prompts you to select which to delete, then removes the chosen branches locally and optionally on the remote.
Will it protect my worktrees with uncommitted changes?
Yes. If a branch is checked out in a worktree that has uncommitted changes, the skill blocks it from the deletion list, even if the branch is already merged.
Similar skills
All skills for Git and GitHub →clean-branches by other authors comes first.