git-branch-cleanup

git-branch-cleanup is a skill for Claude Code, Codex from pivoshenko/pivoshenko.ai. It costs 99 tokens per session (918 once invoked), scanned A, original, MIT.

A Git branch cleanup procedure for finding local branches that are already merged or whose remote branch no longer exists. Git branches are separate lines of development in a code repository.

In plain words
What is it for?
Use it to prune old branches, compare them with the correct remote base branch, and keep explicitly named branch patterns.
Why use it?
It reduces stale branches while previewing candidates and requiring confirmation before deletion.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one. Also seen: positional $N argument.

Good fit Use it to prune old branches, compare them with the correct remote base branch, and keep explicitly named branch patterns.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/pivoshenko/pivoshenko.ai/git-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 pivoshenko/pivoshenko.ai --skill git-branch-cleanup
Clone the repo
git clone --depth 1 https://github.com/pivoshenko/pivoshenko.ai

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 git-branch-cleanup

README.md
[![agentmods](https://agentmods.dev/badge/skills/pivoshenko/pivoshenko.ai/git-branch-cleanup/github.svg)](https://agentmods.dev/skills/pivoshenko/pivoshenko.ai/git-branch-cleanup)
Your own site
<a href="https://agentmods.dev/skills/pivoshenko/pivoshenko.ai/git-branch-cleanup"><img src="https://agentmods.dev/badge/skills/pivoshenko/pivoshenko.ai/git-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 git-branch-cleanup

Your own site · 80×15
<a href="https://agentmods.dev/skills/pivoshenko/pivoshenko.ai/git-branch-cleanup"><img src="https://agentmods.dev/badge/skills/pivoshenko/pivoshenko.ai/git-branch-cleanup.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 99 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 918 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.00099 $0.00918
Opus 5.5 $0.00040 $0.00367
Sonnet 5.5 $0.00020 $0.00184
Haiku 4.5 $0.00010 $0.00092

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

Security

Grade A, and why

git-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 29d 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.

skills/git-branch-cleanup/SKILL.md · 52 lines

How it starts

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

Git Branch Cleanup

Prune locals = merged OR remote gone. Destructive -> preview + confirm.

Flow

  1. If user mentioned keep-patterns inline (e.g. "but keep spike/*") -> capture them. Else assume none. Don't prompt up front
  2. Parallel:
    • git fetch --all --prune
    • git branch --show-current
  3. Base: user names one -> use it. Else detect: git symbolic-ref --short refs/remotes/origin/HEAD -> strip the origin/; ref missing -> git remote set-head origin -a, re-read; no remote -> main, fall back master. Why -> this is a delete path, and --merged <wrong-base> misclassifies live branches as merged. Compare against origin/<base>, not the local ref -> the local base is often stale or absent entirely (git-branch-create branches off origin/<base> without ever creating it), so a local-ref check either errors or reports branches as unmerged that the remote already has
  4. Candidates:
    • Gone: upstream gone
      git for-each-ref --format='%(refname:short) %(upstream:track)' refs/heads \
        | awk '$2 == "[gone]" {print $1}'
      
    • Merged: fully merged into the remote base (step 1 already fetched + pruned)
      git branch --merged origin/<base> --format='%(refname:short)'
      
    • No remote -> compare against the local <base> (git branch --merged <base>) and skip the Gone bucket entirely (no upstreams can exist)
    • Note: squash-merged PRs leave no merge commit, so they won't appear in Merged. Closing the PR deletes the remote -> they show up in Gone instead. The Gone bucket is the catch-all for PR-merged work
    • Union. Exclude:
      • Current
      • Base (main/master)
      • Protected: exact names develop, staging, plus any branch matching the glob release/*. Skip silently if none exist
      • User keep-patterns from step 0 (if provided)
  5. Print grouped by reason (gone vs merged), one line per branch, no prose. Ask confirm
  6. On confirm:
    • Merged: git branch -d <name>. -d re-checks against HEAD/upstream, not origin/<base>, so it can refuse a branch the Merged bucket listed -> that's a safe refusal, not a bug: report it as skipped, don't reach for -D
    • Gone + unmerged: git branch -D <name>. Explicit confirm only
    • Branch checked out in another worktree -> both -d and -D refuse. Same safe refusal: report as skipped, don't force it
  7. Print summary: counts + one line per skipped branch (+ why). No recap of what was already listed

Read the full file on GitHub · 52 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. 29d ago First seen · 52 lines · 99 tokens per session scan A e314a17624d5

Subscribe to this mod's changes

git-branch-cleanup is a skill published in the GitHub repository pivoshenko/pivoshenko.ai (6 stars, last pushed yesterday), licensed MIT. It adds 99 tokens to every session and 918 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-09-18.

Related

Other skills, from other repositories

skill-upstream-pr

Improve an open-source GitHub skill and open a friendly suggestion PR upstream: fork, run skill-creator's retrofit, attach asm eval before/after metrics. Don't use for local-only skills, authoring from scratch, bulk repos, or registry publish.

luongnv89/asm · 56 tokens

meanest-editor

Roast a pitch or press release with the eye of a veteran PR director. Honest, sharp, constructive — never cruel for its own sake.

elvisun/newsjack · 33 tokens

headline-generator

Generate headline candidates from a story's raw facts: news-style headlines, press-release headlines, and pitch subject lines. A pure generation skill — it finds the charge in the facts, then runs ten proven moves (consequence, picture, number-as-hero, two-beat turn, naming, reader's-own-story, open question, voice…

elvisun/newsjack · 88 tokens

ai-visibility-writing

Audit, question, suggest, or fact-preservingly revise a press release, blog post, contributed article, or expert explainer so AI answer systems can more easily retrieve, understand, quote, and cite its useful information. Use when someone asks for AI visibility, AI search, answer-engine, AEO, GEO, AI Overview, or…

elvisun/newsjack · 137 tokens

docs-updater

Provides automated documentation updates by analyzing git changes between the current branch and the last release tag. Performs git diff analysis to identify modifications, then updates README.md, CHANGELOG.md following Keep a Changelog standard, and discovers documentation folders for contextual updates. Use when…

giuseppe-trisciuoglio/developer-kit · 96 tokens

github-issue-workflow

Provides a structured 8-phase workflow for resolving GitHub issues in Claude Code. Covers fetching issue details, analyzing requirements, implementing solutions, verifying correctness, performing code review, committing changes, and creating pull requests. Use when user asks to resolve, implement, work on, fix, or…

giuseppe-trisciuoglio/developer-kit · 79 tokens