cleanup-branches
Skill6 starsChanged 3 months agoMITView on GitHub
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).
- Commits and pushes
2 other projects use a version of this.
Adopted by
Most recently taken up by
- amit-nayar/skillstheir own version, first seen Oct 5, 2026
- dmzoneill/skillstheir own version, first seen Sep 3, 2026
Other versions2 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 2
- dmzoneill/skills★ 2same name
- amit-nayar/skills★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository41 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- add-team-sourceSkill
- bootstrap-projectSkill
- check-prereqsSkill
- commitSkill
- diagnoseSkill
- diff-profileSkill
- doctorSkill
- explain-diffSkill
- explain-stateSkill
- fleet-retrofitSkill
- fleetSkill
- gen-ciSkill
- gen-claudemdSkill
- gen-dependency-updaterSkill
- gen-devcontainerSkill
- gen-templatesSkill
- gh-protectSkill
- hotfixSkill
- iac-applySkill
- iac-planSkill
- inspect-profileSkill
- learn-profileSkill
- migrate-profileSkill
- new-branchSkill
- optimize-claudemdSkill
- prSkill
- record-decisionSkill
- releaseSkill
- retrofitSkill
- route-docsSkill
- settingsSkill
- setupSkill
- shipSkill
- suggestSkill
- syncSkill
- sync-team-profilesSkill
- undo-bootstrapSkill
- undoSkill
- wait-for-pr-checksSkill
- watchSkill
The file
We split this skill into the rules it gives an agent
4 rules. About 0 are common, 2 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 28
Always invoke without --yes first:
- Very specific: line 43
If summary.candidates_count == 0, tell the user there's nothing to clean up and exit.
- Distinctive: line 48
Ask: "Delete N merged branch(es)?" — list the names if there are 5 or fewer, or summarise if more.
- Distinctive: line 68
Don't run this for them — pushing is a high-blast-radius action and the user should pick which deletions to mirror.
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
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
--yesto 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> --yesThe 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_countand any entries inerrors[]. - Suggest the user push the deletions to the remote if they
maintain a personal fork branch list:
Don't run this for them — pushing is a high-blast-radius action and the user should pick which deletions to mirror.git push --delete origin <branch> # per branch
When to hand off
- "Why is X still here?" → it's not reachable from base. Run
/nyann:doctorand look at theLOCAL BRANCHESrow forstale_unmergedcount, or invokebin/check-stale-branches.shdirectly 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 originis what they want; not in scope here.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

