branch-cleanup

branch-cleanup is a command for Claude Code from openshift-eng/ai-helpers. It costs 12 tokens per session (2,539 once invoked), scanned A, original, Apache-2.0.

A Git command that finds and removes obsolete local branches, with optional cleanup of remote branches. Branches are separate lines of development, often kept after a feature or fix is finished.

In plain words
What is it for?
Use it to preview or perform branch cleanup, including merged feature branches and branches deleted from the remote repository.
Why use it?
It reduces repository clutter while checking for branches that are merged, missing remotely, or otherwise stale.

Command for Claude Code

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

Part of the git plugin — 2 skills, 10 commands shipped together

Good fit Use it to preview or perform branch cleanup, including merged feature branches…

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

Made for: Claude Code.

Or install git, the plugin that ships this one along with the rest of its 2 skills, 10 commands.

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/openshift-eng/ai-helpers/branch-cleanup.svg)](https://agentmods.dev/commands/openshift-eng/ai-helpers/branch-cleanup)
Your own site
<a href="https://agentmods.dev/commands/openshift-eng/ai-helpers/branch-cleanup"><img src="https://agentmods.dev/badge/commands/openshift-eng/ai-helpers/branch-cleanup.svg" alt="Measured on agentmods" 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,539 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.00012 $0.02539
Opus 5 $0.00006 $0.01269
Sonnet 5 $0.00002 $0.00508
Haiku 4.5 $0.00001 $0.00254

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

Copies of this mod

1 near-identical copy found in the catalogue:

plugins/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. 3d ago First seen · 279 lines · 12 tokens per session scan A 7da07cf21473

Subscribe to this mod's changes

branch-cleanup is a command published in the GitHub repository openshift-eng/ai-helpers (116 stars, last pushed 2d ago), licensed Apache-2.0. It adds 12 tokens to every session and 2,539 once invoked, about $0.0001 per session on Opus 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-09-03.