branch-cleanup

branch-cleanup is a command for coding agents from armanzeroeight/fastagent-plugins. It costs 9 tokens per session (1,143 once invoked), scanned A, original, MIT.

A command that finds merged or inactive Git branches and removes them locally, with an option to clean up remote branches too.

In plain words
What is it for?
Use it to inspect merged and stale branches, preview cleanup with a dry run, and delete branches that are no longer needed.
Why use it?
It reduces clutter in repositories and makes it easier to see which branches are still relevant.

Command

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 commands/armanzeroeight/fastagent-plugins/branch-cleanup
Clone the repo
git clone --depth 1 https://github.com/armanzeroeight/fastagent-plugins

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/armanzeroeight/fastagent-plugins/branch-cleanup.svg)](https://agentmods.dev/commands/armanzeroeight/fastagent-plugins/branch-cleanup)
Your own site
<a href="https://agentmods.dev/commands/armanzeroeight/fastagent-plugins/branch-cleanup"><img src="https://agentmods.dev/badge/commands/armanzeroeight/fastagent-plugins/branch-cleanup.svg" alt="Measured on agentmods" height="20"></a>
Per session 9 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,143 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.00009 $0.01143
Opus 5 $0.00005 $0.00571
Sonnet 5 $0.00002 $0.00229
Haiku 4.5 $0.00001 $0.00114

Measured 2d ago against content hash a43cea3eae1f, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, 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.

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.

plugins/git-workflow-toolkit/commands/branch-cleanup.md · 178 lines

How it starts

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

Branch Cleanup

Context

  • Current branch: !git branch --show-current
  • Local branches: !git branch --list | wc -l
  • Remote branches: !git branch -r | wc -l
  • Merged branches: !git branch --merged | grep -v "^\*" | grep -v "main" | grep -v "master" | grep -v "develop" | wc -l

Your Task

Identify and clean up merged and stale branches to maintain a clean repository.

Arguments

  • --dry-run (optional): Show what would be deleted without actually deleting
  • --remote (optional): Also clean up remote branches
  • --force (optional): Delete unmerged branches (use with caution)

Steps

  1. Fetch latest changes:

    git fetch --prune
    
  2. Identify merged branches:

    git branch --merged | grep -v "^\*" | grep -v "main" | grep -v "master" | grep -v "develop"
    
  3. Identify stale branches (no commits in 30+ days):

    git for-each-ref --sort=-committerdate refs/heads/ --format='%(refname:short) %(committerdate:relative)'
    
  4. Review branches to delete:

    • Merged feature branches
    • Merged bugfix branches
    • Stale branches (no activity in 30+ days)
    • Branches with naming like test-*, tmp-*, wip-*
  5. Delete local merged branches:

    git branch --merged | grep -v "^\*" | grep -v "main" | grep -v "master" | grep -v "develop" | xargs git branch -d
    
  6. Delete remote merged branches (if --remote flag):

    git branch -r --merged | grep -v "main" | grep -v "master" | grep -v "develop" | sed 's/origin\///' | xargs -I {} git push origin --delete {}
    
  7. Report cleanup results:

    • Number of branches deleted
    • List of deleted branches
    • Remaining active branches
    • Disk space saved (if significant)

Examples

Dry run to preview:

/branch-cleanup --dry-run
# Shows what would be deleted without actually deleting

Clean up local branches:

/branch-cleanup
# Deletes merged local branches

Clean up local and remote:

/branch-cleanup --remote
# Deletes merged branches locally and on remote

Read the full file on GitHub · 178 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. 2d ago First seen · 178 lines · 9 tokens per session scan A a43cea3eae1f

Subscribe to this mod's changes

branch-cleanup is a command published in the GitHub repository armanzeroeight/fastagent-plugins (29 stars, last pushed 1mo ago), licensed MIT. It adds 9 tokens to every session and 1,143 once invoked, about $0.0000 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.