git-clean-branches

git-clean-branches is a skill for Claude Code, Codex from UfoMiao/zcf. It costs 27 tokens per session (1,057 once invoked), scanned A, original, MIT.

A Git branch cleanup tool. Git branches are separate lines of code work; this tool finds branches already merged into a chosen base branch or branches that have been inactive for a specified time.

In plain words
What is it for?
Use it to preview or remove old local or remote branches, clean merged branches after releases, or find inactive branches without deleting them first.
Why use it?
It helps identify branches that no longer need to be kept, while previewing the proposed deletions by default. Protected branches, remote branches, and deletion confirmation can be controlled with options.

Skill for Claude CodeCodex

About the project

ZCF is a command-line setup tool for configuring Claude Code and Codex with agents, instructions, skills, hooks, commands, and settings. It is for developers who want to install and personalize these coding-agent workflows through an interactive setup.

UfoMiao/zcf · 6,083 stars · on GitHub

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.

agentmods
npx agentmods add skills/ufomiao/zcf/git-clean-branches
Any agent
npx skills add UfoMiao/zcf --skill git-clean-branches
Clone the repo
git clone --depth 1 https://github.com/UfoMiao/zcf

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-clean-branches

README.md
[![agentmods](https://agentmods.dev/badge/skills/ufomiao/zcf/git-clean-branches.svg)](https://agentmods.dev/skills/ufomiao/zcf/git-clean-branches)
Your own site
<a href="https://agentmods.dev/skills/ufomiao/zcf/git-clean-branches"><img src="https://agentmods.dev/badge/skills/ufomiao/zcf/git-clean-branches.svg" alt="Measured on agentmods" height="20"></a>
Per session 27 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,057 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
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 $0.00027 $0.01057
Opus 5 $0.00014 $0.00528
Sonnet 5 $0.00005 $0.00211
Haiku 4.5 $0.00003 $0.00106

Measured 5d ago against content hash 1027e768d74a, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

git-clean-branches 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 5d 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.

templates/skills/en/git-clean-branches/SKILL.md · 100 lines

How it starts

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

Claude Command: Clean Branches

This command safely identifies and cleans up merged or stale Git branches. Runs in read-only preview (--dry-run) mode by default, requiring explicit instructions to perform deletions.


Usage

# [Safest] Preview branches to be cleaned without executing any deletions
/git-cleanBranches --dry-run

# Clean local branches merged to main and inactive for over 90 days (requires individual confirmation)
/git-cleanBranches --stale 90

# Clean local and remote branches merged to release/v2.1 (auto-confirm)
/git-cleanBranches --base release/v2.1 --remote --yes

# [Dangerous] Force delete an unmerged local branch
/git-cleanBranches --force outdated-feature

Options

  • --base <branch>: Specify the base branch for cleanup (defaults to repository's main/master).
  • --stale <days>: Clean branches with no commits for specified days (disabled by default).
  • --remote: Also clean remote merged/stale branches.
  • --dry-run: Default behavior. Only list branches to be deleted without executing any operations.
  • --yes: Skip individual confirmations and delete all identified branches directly (suitable for CI/CD).
  • --force: Use -D to force delete local branches (even if unmerged).

What This Command Does

  1. Configuration and Safety Checks

    • Update Information: Automatically executes git fetch --all --prune to ensure branch status is current.
    • Read Protected Branches: Reads the list of branches that should not be cleaned from Git config (see "Configuration" below).
    • Determine Base: Uses --base parameter or auto-detected main/master as comparison baseline.
  2. Analysis and Identification (Find)

    • Merged Branches: Find local (and remote if --remote is added) branches fully merged to --base.
    • Stale Branches: If --stale <days> is specified, find branches with last commit N days ago.
    • Exclude Protected Branches: Remove all configured protected branches from cleanup list.

Read the full file on GitHub · 100 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. 5d ago First seen · 100 lines · 27 tokens per session scan A 1027e768d74a

Subscribe to this mod's changes

git-clean-branches is a skill published in the GitHub repository UfoMiao/zcf (6,083 stars, last pushed 5d ago), licensed MIT. It adds 27 tokens to every session and 1,057 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-08-30.