Skip to content
Development
Skill

/cleanup-branches

Prune local branches whose work is already merged into the base. TRIGGER when the user says "clean up branches", "delete merged branches", "prune local branches", "remove old branches", "I have too many branches", "what branches can I delete", "/nyann:cleanup-branches". Do NOT

From plugin
nyann
741 skills41 commands3 hooks

Claude Code

$ npx -y skills add thettwe/nyann --skill cleanup-branches --agent claude-code

SKILL.md

cleanup-branches.SKILL.md
name: cleanup-branches
description: >
  Prune local branches whose work is already merged into the base.
  TRIGGER when the user says "clean up branches", "delete merged branches",
  "prune local branches", "remove old branches", "I have too many branches",
  "what branches can I delete", "/nyann:cleanup-branches".
  Do NOT trigger on "delete THIS branch" (that's a one-off `git branch -D`,
  not a cleanup pass) or "remove a branch from the remote" (this skill is
  local-only; remote pruning is `git push --delete origin <branch>` and
  the user should do that themselves). Do NOT trigger on "merge this branch"
  (that's the merge step before cleanup).

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 more
@thettwe
Ships withnyann

ငြမ်း is Burmese for scaffolding. Nyann is the Claude Code plugin that picks expert git defaults for your stack — branching, working hooks (Husky / pre-commit.com / lefthook), commits, releases, CI, docs — then keeps the repo on those rails through every PR

Stars on GitHub

Momentum

stars in total
7
Star history of thettwe/nyann on GitHub, a chart by star-history.com

Other skills on nyann.

add-team-source

add-team-source

Register a git URL as a team-profile source so nyann can periodically sync and expose its profiles under a namespace. TRIGGER…

@thettwe@thettweInstall Skill
bootstrap-project

bootstrap-project

Bootstrap a fresh or existing repo with nyann. TRIGGER when the user says "set up this project", "initialize git workflow",…

@thettwe@thettweInstall Skill
check-prereqs

check-prereqs

Survey the machine and report which nyann features are usable right now. TRIGGER when the user says "is my machine ready for…

@thettwe@thettweInstall Skill
commit

commit

Generate a Conventional Commits message from the staged diff and create the commit after user confirmation. TRIGGER when the user…

@thettwe@thettweInstall Skill
diagnose

diagnose

Bundle a redacted, support-grade snapshot of the current nyann state for inclusion in a bug report or support request. Combines…

@thettwe@thettweInstall Skill
diff-profile

diff-profile

Compare two nyann profiles side-by-side and show what would change. TRIGGER ON: 'diff profiles', 'compare profiles', 'what's…

@thettwe@thettweInstall Skill

More skills from other plugins.

brainstorming
Auto-invoked

brainstorming

You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or…

@obra@obraInstall Skill
ask-matt

ask-matt

Ask which skill or flow fits your situation. A router over the skills in this repo.

skills2w309k
@mattpocock@mattpocockInstall Skill
accessibility
Auto-invoked

accessibility

Design, implement, and audit accessible UI to WCAG 2.2 Level AA across Web, iOS, and Android — semantic ARIA roles and labels,…

ecc2w293k
@affaan-m@affaan-mInstall Skill
compiler-commit

compiler-commit

Use when you want to verify compiler changes and commit with the correct convention. Runs tests, lint, and format, then commits…

react5d252k
@facebook@facebookInstall Skill

Questions about cleanup-branches.

Which coding agents can use cleanup-branches?
cleanup-branches installs in Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, OpenCode and Windsurf with the skills CLI, using each agent's flag shown on this page. Flowy's auto-invocation, which fires a skill when your prompt matches, runs in Claude Code only.