
cleanup-merged-branches
Delete remote branches whose PR was merged. Read-only dry-run, then confirm, then delete.
- Installs
- 671
- Last 24h
- +22
- Trending rank
- #5565
- Security
- Not audited
Install
Works with every agent the skills CLI supports.
npx skills add https://github.com/timschoch/skilly --skill cleanup-merged-branches- 01
Install
Run the command in your project. The CLI asks which agents to install for.
- 02
Describe the task
Ask your agent for something this skill covers. It loads cleanup-merged-branches automatically when relevant.
- 03
Review the result
The agent follows the SKILL.md steps, scripts and references bundled with the skill.
SKILL.md
The instructions your agent reads when the skill is triggered.
Delete remote branches that belong to a merged PR. Destructive, so it runs as a dry-run first and never deletes without explicit confirmation.
Delete rule
A branch is deletable iff all hold — encoded in scripts/plan.sh, the single source of truth:
- it still exists on the remote,
- it has a merged PR,
- it has no open PR,
- it is not protected.
Protected = the default branch + staging. Never delete these, even if a merged PR points at them. A branch with no PR, or only a closed-unmerged PR, is not deletable (it never "belongs to a merged PR"). Extend the protected set in is_protected() inside scripts/plan.sh, nowhere else.
Steps
- Dry-run. Run
bash scripts/plan.sh(pass a remote name as$1if notorigin). It prints deletable branches as<branch> #<pr> <title>, and deletes nothing. Done when you have the list. Empty output → report "nothing to clean up" and stop. - Show + confirm. Show the full list to the user and ask for explicit go. Do not delete on a vague reply — only on a clear yes. This gate is mandatory every run.
- Delete. For each confirmed branch:
git push origin --delete <branch>. Nothing outside the plan's list may be deleted. - Report. List what was deleted; note any push that failed.
Also: stale claims (the reaper)
Releases abandoned in-progress claims (agent crashed / session died / no PR ever opened) so a dead claim doesn't pin an issue as "taken" forever. See docs/agents/triage-labels.md for the label; /implement sets it, PR-open removes it, this reaps the leftovers.
Stale rule. An in-progress issue is stale iff all hold — encoded in scripts/stale-claims.sh, the single source of truth:
- it is open and labeled
in-progress, - it has no open linked PR (linked = an open PR referencing
#Nin title/body, or whose head branch == the branch named in the claim comment), and - the
in-progresslabel is older than the threshold (latestlabeledtimeline event): default 24h, override via$1/$STALE_CLAIM_HOURS.
Steps (fold into the same run, on the same confirm gate as branch deletion):
- Dry-run. Run
bash scripts/stale-claims.sh [hours]. It prints stale claims as#<n> <title>and changes nothing. Empty → nothing to reap. (Logic proof:bash scripts/stale-claims.test.sh.) - Show + confirm. Show the list; reap only on explicit go. Same mandatory gate.
- Reap. For each confirmed issue:
gh issue edit N --remove-label in-progress --add-label ready-for-agent(abandoned work re-enters the free queue). Nothing outside the printed list is touched.
Also: stale-open issues
Closes #N only auto-closes on merge into the default branch — a PR merged into an integration branch (e.g. rebuild/v1) leaves #N open forever. For each merged PR you clean up here, check its linked issue: if the work is on the default branch but the issue is still open, hand-close it (gh issue close #N --reason completed --comment "merged via #<pr>"). Same misfire hides "done" issues as open — this is where to catch them.
FAQ
What does the cleanup-merged-branches skill do?
Delete remote branches whose PR was merged. Read-only dry-run, then confirm, then delete.
How do I install cleanup-merged-branches?
Run npx skills add https://github.com/timschoch/skilly --skill cleanup-merged-branches in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/cleanup-merged-branches/ (personal) or .claude/skills/cleanup-merged-branches/ (project).
Which AI agents can use cleanup-merged-branches?
Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.
Is cleanup-merged-branches safe to install?
No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.
Who maintains cleanup-merged-branches?
It is published by timschoch in timschoch/skilly. It has 671 recorded installs.
More from timschoch/skilly
git-shortcuts
timschoch/skilly
Translates shorthand git/GitHub workflow commands into the correct sequence of actions. ALWAYS trigger when the user's message contains a "--" prefixed shorthand like: "--c", "--p", "--cp", "--pr", "--prm", "--cppr", "--cpprm", "--ff", "--release", "--pub", "--close" — with or without a trailing "?". The "--" prefix is required — do NOT trigger on bare letters like "c" or "pr" appearing in normal sentences. NEVER invoke this skill autonomously — it MUST always be user-invoked via an explicit "--" shorthand in their message.
step-by-step
timschoch/skilly
Walk the user through a manual procedure step by step, with every value spelled out and every link clickable.
plan-critics
timschoch/skilly
Critiques an implementation plan — or a wayfinder map/ticket — from multiple angles (security, simplicity, edge cases, scope creep, codebase conflicts, tech-specific best practices) via parallel critic subagents. Trigger: user says "kritisiere den plan", "plan check", "plan-kritik", "blinde flecken", "/plan-critics" — also invoke when a planning agent wants to validate its own plan before presenting it, or a wayfinder session wants a resolution checked before closing a ticket. Must be called at top-level (not inside a subagent) — it uses the Task tool.
qa
timschoch/skilly
Interactive QA session where user reports bugs or issues conversationally, and the agent files GitHub issues. Explores the codebase in the background for context and domain language. Use when user wants to report bugs, do QA, file issues conversationally, or mentions "QA session".
1-3-1
timschoch/skilly
Frame a problem or decision as 1-3-1: one problem, three distinct solutions, one recommendation. Use when the user brings a non-trivial decision or fork and wants options weighed before a pick ("what should I do about X", "help me decide", "weigh the tradeoffs"), or names "1-3-1" or "do a 131". Skip questions with one right answer, just answer those.
term-check
timschoch/skilly
Probe whether a candidate term carries its meaning alone, by asking three models to guess it from a bare scenario. Use when naming a field, an enum value, a table or a glossary word and several candidates are in play ("carry or carryOver", "does this name read", "which word is clearer").
Popular code quality & workflow skills
grill-me
mattpocock/skills
A relentless interview to sharpen a plan or design.
improve-codebase-architecture
mattpocock/skills
Scan a codebase for deepening opportunities, present them as a visual HTML report, then grill through whichever one you pick.
handoff
mattpocock/skills
Compact the current conversation into a handoff document for another agent to pick up.
domain-modeling
mattpocock/skills
Build and sharpen a project's domain model. Use when discussing codebase terminology, writing or editing a GLOSSARY.md, or recording or editing an ADR.
codebase-design
mattpocock/skills
Shared vocabulary for designing deep modules. Use when the user wants to design or improve a module's interface, find deepening opportunities, decide where a seam goes, make code more testable or AI-navigable, or when another skill needs the deep-module vocabulary.
diagnosing-bugs
mattpocock/skills
Diagnosis loop for hard bugs and performance regressions. Use when the user says "diagnose"/"debug this", or reports something broken/throwing/failing/slow.