cleanup-branches

cleanup-branches is a skill for Claude Code from thettwe/nyann. It costs 144 tokens per session (765 once invoked), scanned A, original, MIT.

A tool for finding local Git branches whose changes have already been merged into a base branch such as main or develop.

In plain words
What is it for?
It previews old merged branches and, after confirmation, deletes them with Git's safe branch-delete command.
Why use it?
It helps reduce branch clutter while checking that unmerged work is not removed.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin.

Part of the nyann plugin — 41 skills, 41 commands, 3 hooks shipped together

Good fit It previews old merged branches and, after confirmation, deletes them with Git's safe branch-delete command.

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

Made for: Claude Code.

Or install nyann, the plugin that ships this one along with the rest of its 41 skills, 41 commands, 3 hooks.

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

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

Your own site · 80×15
<a href="https://agentmods.dev/skills/thettwe/nyann/cleanup-branches"><img src="https://agentmods.dev/badge/skills/thettwe/nyann/cleanup-branches.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 144 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 765 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.00144 $0.00765
Opus 5 $0.00072 $0.00382
Sonnet 5 $0.00029 $0.00153
Haiku 4.5 $0.00014 $0.00076

Measured 8d ago against content hash 4e8235b4776b, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-08, from the pricing page.

Security

Grade A, and why

cleanup-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 8d 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/cleanup-branches/SKILL.md · 81 lines

How it starts

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

cleanup-branches

Wraps bin/cleanup-branches.sh. Lists local branches whose tip is reachable from the base branch (main / develop / wherever the profile points), then either previews the list or actually deletes them with git branch -d (safe — refuses unmerged work).

Mirrors the same preview-then-mutate contract as undo and migrate-profile: nothing is deleted unless the caller passed --yes AND --dry-run was absent.

1. Run the preview

Always invoke without --yes first:

bin/cleanup-branches.sh --target <cwd>

Output is a CleanupBranchesResult JSON (see schemas/cleanup-branches-result.schema.json). Show the user:

  • The base branch the merge check ran against (base_branch).
  • The list of candidates (candidates[]), one per merged branch, with last-commit timestamp + short SHA so they can sanity-check.
  • The total count from summary.candidates_count.
  • The recovery hint: re-run with --yes to delete.

If summary.candidates_count == 0, tell the user there's nothing to clean up and exit. Don't prompt.

2. Confirm and apply

Ask: "Delete N merged branch(es)?" — list the names if there are 5 or fewer, or summarise if more. On confirmation:

bin/cleanup-branches.sh --target <cwd> --yes

The script uses git branch -d (lowercase d, the safe form) so even if a candidate's merge state changed between the preview and the apply, git will refuse the unsafe delete and the entry lands in errors[] instead of deleted[]. Surface any errors verbatim.

3. After deletion

  • Report summary.deleted_count and any entries in errors[].
  • Suggest the user push the deletions to the remote if they maintain a personal fork branch list:
    git push --delete origin <branch>   # per branch
    
    Don't run this for them — pushing is a high-blast-radius action and the user should pick which deletions to mirror.

When to hand off

  • "Why is X still here?" → it's not reachable from base. Run /nyann:doctor and look at the LOCAL BRANCHES row for stale_unmerged count, or invoke bin/check-stale-branches.sh directly to see the full classification.
  • "Delete a specific branch by name" → just git branch -D <name>. This skill is for the bulk-merged case.
  • "Prune the remote-tracking refs too" → git remote prune origin is what they want; not in scope here.

Read the full file on GitHub · 81 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. 8d ago First seen · 81 lines · 144 tokens per session scan A 4e8235b4776b

Subscribe to this mod's changes

cleanup-branches is a skill published in the GitHub repository thettwe/nyann (6 stars, last pushed 10d ago), licensed MIT. It adds 144 tokens to every session and 765 once invoked, about $0.0007 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-31.

Related

Other skills, from other repositories

release

CONTRIBUTOR TOOL - Cut a plugin release: bump plugin.json version, finalize CHANGELOG, update README if needed, gate on make ci, commit, tag vX.Y.Z, and create the GitHub release. Use when shipping a new plugin version. NOT distributed.

oliver-kriska/claude-elixir-phoenix · 60 tokens

catchup

Summarize and review what changed while you were away. Use after a weekend, vacation, or flight to check missed PRs, git commits, Linear tickets, and meetings — one prioritized brief, not a firehose.

oliver-kriska/claude-elixir-phoenix · 48 tokens

pr-review

Address feedback left on a GitHub pull request: fetch unresolved review threads, make agreed Elixir/Phoenix code fixes, reply, and resolve. Use for a PR URL/number or reviewer comments. NOT for pre-PR review, findings triage, or CI monitoring.

oliver-kriska/claude-elixir-phoenix · 59 tokens

phx-pr-review

Address feedback left on a GitHub pull request: fetch unresolved review threads, make agreed Elixir/Phoenix code fixes, reply, and resolve. Use for a PR URL/number or reviewer comments. NOT for pre-PR review, findings triage, or CI monitoring.

oliver-kriska/claude-elixir-phoenix · 61 tokens

watch-pr

Watch an Elixir/Phoenix PR with an Amp Orb keep-alive lease until required non-deployment CI is green and review threads are resolved. Use after opening or updating a PR.

oliver-kriska/claude-elixir-phoenix · 41 tokens

pr-create

Creates a pull request from current changes, monitors GitHub CI, and debugs any failures until CI passes. Activate when the user says "create pr", "make a pr", "open pull request", "submit pr", "pr for these changes", or wants to get their current work into a reviewable PR. Assumes the project uses git, is hosted on…

posit-dev/skills · 112 tokens