git-clean-gone-branches

git-clean-gone-branches is a skill for Claude Code, Codex from marcusrbrown/systematic. It costs 70 tokens per session (595 once invoked), scanned A, original, MIT.

A cleanup tool for local Git branches whose matching branches on the shared remote repository have been deleted. It can also remove worktrees, which are extra working folders linked to branches.

In plain words
What is it for?
Use it to find branches marked as gone after updating remote information, show the list, and delete the ones you confirm.
Why use it?
It removes stale local branches and linked worktrees that no longer have a purpose, reducing clutter and preventing confusion about which branches still exist.

Skill for Claude CodeCodex

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/marcusrbrown/systematic/git-clean-gone-branches
Any agent
npx skills add marcusrbrown/systematic --skill git-clean-gone-branches
Clone the repo
git clone --depth 1 https://github.com/marcusrbrown/systematic

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

README.md
[![agentmods](https://agentmods.dev/badge/skills/marcusrbrown/systematic/git-clean-gone-branches.svg)](https://agentmods.dev/skills/marcusrbrown/systematic/git-clean-gone-branches)
Your own site
<a href="https://agentmods.dev/skills/marcusrbrown/systematic/git-clean-gone-branches"><img src="https://agentmods.dev/badge/skills/marcusrbrown/systematic/git-clean-gone-branches.svg" alt="Measured on agentmods" height="20"></a>
Per session 70 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 595 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.00070 $0.00595
Opus 5 $0.00035 $0.00298
Sonnet 5 $0.00014 $0.00119
Haiku 4.5 $0.00007 $0.00060

Measured 5d ago against content hash 721f5e32f7f2, 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-gone-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.

skills/git-clean-gone-branches/SKILL.md · 68 lines

How it starts

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

Clean Gone Branches

Delete local branches whose remote tracking branch has been deleted, including any associated worktrees.

Workflow

Step 1: Discover gone branches

Run the discovery script to fetch the latest remote state and identify gone branches:

When this skill loads, its own directory is stated in the surrounding instructions; set SKILL_DIR to that directory because the scripts live beside this file.

# Resolve helper scripts relative to this skill's directory.
SKILL_DIR="<skill directory stated when this skill loads>";
bash "$SKILL_DIR/scripts/clean-gone"

scripts/clean-gone

The script runs git fetch --prune first, then parses git branch -vv for branches marked : gone].

If the script outputs __NONE__, report that no stale branches were found and stop.

Step 2: Present branches and ask for confirmation

Show the user the list of branches that will be deleted. Format as a simple list:

These local branches have been deleted from the remote:

  - feature/old-thing
  - bugfix/resolved-issue
  - experiment/abandoned

Delete all of them? (y/n)

Wait for the user's answer using the platform's question tool (e.g., question in OpenCode, request_user_input in Codex, ask_user in Gemini; in Pi, use the blocking-question extension if available, otherwise present numbered options in chat and wait). If no question tool is available, present the list and wait for the user's reply before proceeding.

This is a yes-or-no decision on the entire list -- do not offer multi-selection or per-branch choices.

Step 3: Delete confirmed branches

If the user confirms, delete each branch. For each branch:

  1. Check if it has an associated worktree (git worktree list | grep "\\[$branch\\]")
  2. If a worktree exists and is not the main repo root, remove it first: git worktree remove --force "$worktree_path"
  3. Delete the branch: git branch -D "$branch"

Report results as you go:

Removed worktree: .worktrees/feature/old-thing
Deleted branch: feature/old-thing
Deleted branch: bugfix/resolved-issue
Deleted branch: experiment/abandoned

Cleaned up 3 branches.

Read the full file on GitHub · 68 lines

Files

What ships with it

1 file beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

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 · 68 lines · 70 tokens per session scan A 721f5e32f7f2

Subscribe to this mod's changes

git-clean-gone-branches is a skill published in the GitHub repository marcusrbrown/systematic (24 stars, last pushed yesterday), licensed MIT. It adds 70 tokens to every session and 595 once invoked, about $0.0003 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.