branch-cleaner

Identify and prune stale Git branches locally and on remotes.

130|15|Updated Dec 14, 2025
One-click install
npx skills add https://github.com/jMerta/codex-skills --skill branch-cleaner
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: branch-cleaner
Source: https://github.com/jMerta/codex-skills/tree/main/branch-cleaner
Command: npx skills add https://github.com/jMerta/codex-skills --skill branch-cleaner

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps developers safely prune stale git branches both locally and on remote repositories, preventing accidental deletions and maintaining branch hygiene.

Core Features & Use Cases

  • Identify local branches that have been merged into the base and those that have not
  • Identify remote branches that are merged or stale
  • Respect protected patterns (base branch, current branch, and user-specified keepers) before deletion
  • Provide explicit, confirmable delete or prune commands and a clear audit trail
  • Use cases: cleaning up release or feature branches after merging, auditing branch hygiene during release cycles

Quick Start

Sync with remotes and inspect

  • Run: git fetch --prune
  • Check status: git status Identify candidates
  • Local merged into base: git branch --merged <base>
  • Local not merged: git branch --no-merged <base>
  • Remote merged: git branch -r --merged <base> Review and delete
  • Exclude protected: keep <base>, current, and user patterns
  • When ready, run the appropriate delete commands for the chosen branches

Frequently Asked Questions about branch-cleaner

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I safely prune stale git branches locally and on remotes?▼

To prune stale git branches safely, sync remotes with git fetch --prune, identify merged branches using git branch --merged, and execute explicit delete commands while respecting protected base branches and user-specified keepers.

How do I find local and remote git branches that have been merged?▼

You can find merged git branches by running git branch --merged <base> for local branches and git branch -r --merged <base> for remote branches, identifying candidates for safe cleanup based on your base branch.

Can I prevent accidental deletions when cleaning up git branches?▼

Yes, accidental deletions are prevented by defining safety rules that protect the base branch, current branch, and user-specified patterns, ensuring only explicitly confirmed branches are pruned.

What is the best way to clean up feature and release branches after merging?▼

The best way to clean up feature and release branches is to fetch remote updates, identify merged local and remote branches excluding protected patterns, and run confirmable delete commands for a clear audit trail.

Does git fetch --prune remove stale remote branches automatically?▼

Running git fetch --prune syncs with remotes and removes stale remote tracking references, but you still need to manually identify and delete local branches using safe, reversible steps.

How do I audit branch hygiene during release cycles?▼

You audit git branch hygiene during release cycles by inspecting merged and unmerged local branches, identifying stale remote branches, and reviewing protected patterns before executing any deletions.