branch-cleanup

branch-cleanup is a command for Claude Code from wangke19/gemini-ai-helpers. It costs 12 tokens per session (2,540 once invoked), scanned A, a copy of branch-cleanup, Apache-2.0.

A Git cleanup workflow that finds old, merged, or unavailable branches and removes them locally or, optionally, from a remote repository.

In plain words
What is it for?
Use it to review and clean up completed feature branches, merged branches, and branches deleted from the remote.
Why use it?
It keeps branch lists manageable while protecting the current branch, protected branches, and branches with unmerged work.

Command for Claude Code

Written for Claude Code: argument-hint in frontmatter. Also seen: positional $N argument.

Good fit Use it to review and clean up completed feature branches, merged branches, and branches deleted from the remote.

Compare 6 commands from other repositories ↓
Install with agentmods
npx agentmods add commands/wangke19/gemini-ai-helpers/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.

Clone the repo
git clone --depth 1 https://github.com/wangke19/gemini-ai-helpers

Made for: Claude Code.

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/commands/wangke19/gemini-ai-helpers/branch-cleanup/github.svg)](https://agentmods.dev/commands/wangke19/gemini-ai-helpers/branch-cleanup)
Your own site
<a href="https://agentmods.dev/commands/wangke19/gemini-ai-helpers/branch-cleanup"><img src="https://agentmods.dev/badge/commands/wangke19/gemini-ai-helpers/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/commands/wangke19/gemini-ai-helpers/branch-cleanup"><img src="https://agentmods.dev/badge/commands/wangke19/gemini-ai-helpers/branch-cleanup.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 12 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 2,540 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 97% copy Near-identical to another mod 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.00012 $0.02540
Opus 5 $0.00006 $0.01270
Sonnet 5 $0.00002 $0.00508
Haiku 4.5 $0.00001 $0.00254

Measured 8d ago against content hash 9c721a1ca8be, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-11, 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 8d ago.

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.

Origin

This is a copy

97% identical to branch-cleanup — 2 lines differ, which has more behind it and is treated as the original. This page carries a canonical link to it rather than competing with it.

extensions/git/commands/branch-cleanup.md · 279 lines

How it starts

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

Name

git:branch-cleanup

Synopsis

/git:branch-cleanup [--dry-run] [--merged-only] [--remote]

Description

The git:branch-cleanup command identifies and removes old, defunct, or merged branches from your local repository (and optionally from remote). It helps maintain a clean repository by removing branches that are no longer needed, such as:

  • Branches that have been merged into the main branch
  • Branches that no longer exist on the remote
  • Stale feature branches from completed work

The command performs safety checks to prevent deletion of:

  • The current branch
  • Protected branches (main, master, develop, etc.)
  • Branches with unmerged commits (unless explicitly overridden)

The spec sections is inspired by https://man7.org/linux/man-pages/man7/man-pages.7.html#top_of_page

Implementation

The command should follow these steps:

  1. Identify Main Branch

    • Detect the primary branch (main, master, etc.)
    • Use git symbolic-ref refs/remotes/origin/HEAD or git branch -r to determine
  2. Gather Branch Information

    • List all local branches: git branch
    • Get current branch: git branch --show-current
    • Identify merged branches using multi-layered detection:
      • Standard merge: git branch --merged <main-branch>
      • Merge commit messages: git log <main-branch> --merges --oneline
      • Content comparison: git diff <main-branch>...<branch> --quiet
      • Cherry-pick detection: git cherry <main-branch> <branch>
    • Check remote tracking: git branch -vv
    • Find remote-deleted branches: git remote prune origin --dry-run
  3. Categorize Branches

    • Merged branches: Detected via one of these methods:
      • Standard: Commits directly in main branch history
      • Merge commit: Found in main's merge commit messages
      • Content-identical: All changes present in main (rebased/cherry-picked)
      • Cherry-picked: All commits have equivalents in main
    • Gone branches: Remote tracking branch no longer exists
    • Stale branches: Last commit older than threshold (e.g., 3 months)
    • Protected branches: main, master, develop, release/, hotfix/

Read the full file on GitHub · 279 lines

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. 8d ago First seen · 279 lines · 12 tokens per session scan A 9c721a1ca8be

Subscribe to this mod's changes

branch-cleanup is a command published in the GitHub repository wangke19/gemini-ai-helpers (2 stars, last pushed 5mo ago), licensed Apache-2.0. It adds 12 tokens to every session and 2,540 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. It is 97% identical to branch-cleanup, differing in 2 lines, and is treated as a copy.