Skip to main content
skill CX Codex

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

Install into Claude Code · Plugin marketplace All methods and platforms ↓
/plugin marketplace add gupsammy/Claudest
/plugin install claude-coding@Claudest
Open on GitHub

What 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@Claudest

This installs the whole claude-coding plugin with all its skills

2Skills CLI (Vercel)

npx skills add gupsammy/Claudest --skill clean-branches -a claude-code

3Manually: put the files in place

~/.claude/skills/clean-branches/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/clean-branches/

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.

clean-branches dyoshikawa clean-branches — a skill that walks your local git branches, finds merged and orphaned ones, and deletes them one at a time with a closing report. CX Codex +1 ★ 1,636repo stars comparing-branches-visually spencerpauly comparing-branches-visually is a Claude Code skill that runs two branches in separate worktrees on different ports and screenshots the same pages to show UI changes before and after. CX Codex +1 421installs clean_gone official Anthropic clean_gone — a Claude Code command that removes local git branches flagged as [gone] — branches whose remote counterpart no longer exists. It also clears out any attached worktrees before deletion. CX Codex +1 ★ 47,914repo stars branch-cleanup davila7 branch-cleanup — a Claude slash command that finds merged and stale branches, checks them before deletion, and tidies up both local and remote refs. CX Codex +1 342installs om-auto-create-pr open-mercato om-auto-create-pr converts an arbitrary task brief into an autonomous development run, from execution tracking to a ready PR. Operates in an isolated git worktree with incremental commits. CX Codex +1 4,700installs om-auto-continue-pr open-mercato om-auto-continue-pr resumes unfinished pull requests from their tracking plan inside an isolated worktree. When the plan is missing, it rebuilds one from the PR context and keeps working on that PR. CX Codex +1 4,600installs afk jakubkrehel afk is a Claude Code skill that inspects your repository while you are away, implements verified improvements on a dedicated branch, and writes a concise report. CX Codex +1 3,900installs

From the same set47

The whole set →
commit This skill reviews Git changes and creates Conventional Commits. Use it to split unrelated work into separate commits and push when requested. CX Codex +1 ★ 276repo stars signal-discoverer The signal-discoverer subagent for Claude Code mines recent sessions for undocumented user corrections, architectural decisions, behavioral patterns and preferences to save to project memory. CX Codex ★ 276repo stars skill-lint skill-lint audits SKILL.md files against seven structural quality dimensions, fixing critical defects immediately and flagging minor issues for approval. CX Codex ★ 276repo stars memory-auditor The memory-auditor subagent for Claude Code checks memory against code and Git, flagging stale or duplicate entries. Run it after a major refactor. CX Codex ★ 276repo stars council council launches parallel personas to deliberate on technical questions, examine codebase files, and formulate an opinionated verdict. CX Codex +1 ★ 276repo stars claw-advisor claw-advisor is a Claude Code skill for OpenClaw setup, troubleshooting, and architecture questions. It handles requests about channels, gateways, models, and automation. CX Codex +1 ★ 276repo stars update-readme update-readme rewrites an existing README.md using the current code, git log and changelog. Useful once the docs drift away from what the repo actually does. CX Codex +1 ★ 276repo stars architecture-auditor architecture-auditor reviews system structure, detects circular dependencies, and suggests design patterns when features touch multiple modules. CX Codex ★ 276repo stars

Project sponsors

Companies that keep this analytics open