branch-cleanup

branch-cleanup is a skill for Claude Code, Codex from gspencergoog/skills. It costs 103 tokens per session (1,697 once invoked), scanned A, original, Apache-2.0.

A cleanup tool for local and remote Git branches that have already been merged into the main branch.

In plain words
What is it for?
It helps preview and delete merged branches, associated worktrees, and matching remote-tracking branches.
Why use it?
It removes stale branch references while checking normal merges, squash merges, linked worktrees, and uncommitted changes for safety.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit It helps preview and delete merged branches, associated worktrees, and matching remote-tracking branches.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/gspencergoog/skills/branch-cleanup
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add gspencergoog/skills --skill branch-cleanup
Clone the repo
git clone --depth 1 https://github.com/gspencergoog/skills

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for branch-cleanup

README.md
[![agentmods](https://agentmods.dev/badge/skills/gspencergoog/skills/branch-cleanup/github.svg)](https://agentmods.dev/skills/gspencergoog/skills/branch-cleanup)
Your own site
<a href="https://agentmods.dev/skills/gspencergoog/skills/branch-cleanup"><img src="https://agentmods.dev/badge/skills/gspencergoog/skills/branch-cleanup/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for branch-cleanup

Your own site · 80×15
<a href="https://agentmods.dev/skills/gspencergoog/skills/branch-cleanup"><img src="https://agentmods.dev/badge/skills/gspencergoog/skills/branch-cleanup.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 103 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,697 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00103 $0.01697
Opus 5.5 $0.00041 $0.00679
Sonnet 5.5 $0.00021 $0.00339
Haiku 4.5 $0.00010 $0.00170

Measured 2d ago against content hash f4caaa9eef1a, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

branch-cleanup scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

The scan reads SKILL.md. This mod also ships 3 executable files (scripts/cleanup_branches.py, scripts/tests/run_coverage.py, scripts/tests/test_cleanup_branches.py), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/branch-cleanup/SKILL.md · 154 lines

How it starts

The opening of the file, as written. The whole thing — 154 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Git Branch Cleanup Skill

Finds branches whose work has landed and deletes them, together with their worktrees and, on request, their remote tracking branches.

The script runs in two phases. analyze inspects the repository and writes a plan saying what it believes is safe to delete and why. --execute reads that plan back, checks every branch tip still matches, and only then deletes anything. Nothing is deleted without a plan.

Workflow

  1. Analyze. This fetches every remote first, because a merge verdict measured against stale refs is worthless.

    python3 scripts/cleanup_branches.py --repo-dir /path/to/repo
    

    The plan is printed and written to <repo>/.git/branch-cleanup-plan.json alongside a readable .md version. Use --out to put it elsewhere.

  2. Read the plan. Every branch carries a verdict and the evidence behind it. Check the Needs review section by hand. When the a2ui-pane plugin is available (render_a2ui is reachable as a native or lazy MCP tool) and the plan reports DIVERGED or UNKNOWN branches under Needs review, read the genui skill and render a triage_matrix surface in the pane so the user can classify each branch (Delete, Keep, Inspect); otherwise present the Markdown summary and ask via your interactive question tool or chat.

  3. Confirm and execute. Before running --execute, request confirmation via an inline confirm_gate surface in genui (when a2ui-pane is available) or via your interactive question tool / chat (waiting for approval):

    python3 scripts/cleanup_branches.py --execute /path/to/plan.json
    

Verdicts

Only CONTAINED and SQUASHED are deleted.

Verdict Meaning
CONTAINED The branch is an ancestor of a target, or every commit has an equivalent patch there.
SQUASHED Merging the branch into the target changes nothing, so its content already landed.
DIVERGED Neither git nor the pull request data shows the work landing.
UNKNOWN The evidence is inconclusive. Reported for review, never deleted.
PROTECTED Excluded by rule. The reason is recorded in the plan.

Read the full file on GitHub · 154 lines

Files

What ships with it

3 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago Changed · -1 tokens per session f4caaa9eef1a
  2. 10d ago Changed · +7 lines · +50 tokens per session daafc21de535
  3. 14d ago Changed · +7 lines 39d118ae788a
  4. 1mo ago Changed · +103 lines acafc3c5ce09
  5. 1mo ago Changed · +2 lines 553043df16dc
  6. 2mo ago First seen · 35 lines · 54 tokens per session scan A 01a9e9e93415

Subscribe to this mod's changes

branch-cleanup is a skill published in the GitHub repository gspencergoog/skills (2 stars, last pushed today), licensed Apache-2.0. It adds 103 tokens to every session and 1,697 once invoked, about $0.0004 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.