workflow-cleanup-merged

workflow-cleanup-merged is a skill for Claude Code from lugassawan/swe-workbench. It costs 47 tokens per session (7,249 once invoked), scanned A, original, MIT.

A post-merge Git workflow that removes the finished local worktree and branches, deletes the remote branch, and updates local main. It supports pull requests merged with a squash merge.

In plain words
What is it for?
Use it after confirming a GitHub pull request has merged to clean up the local checkout, delete its local and remote branch, and fast-forward main.
Why use it?
It removes leftover branches and worktrees after a pull request is merged, while avoiding deletion when there are uncommitted changes.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin. Also seen: names the AskUserQuestion tool; positional $N argument.

Part of the swe-workbench plugin — 61 skills, 25 commands, 23 agents, 4 hooks shipped together

Good fit Use it after confirming a GitHub pull request has merged to clean up the local checkout, delete its local and remote branch, and fast-forward main.

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

Made for: Claude Code.

Or install swe-workbench, the plugin that ships this one along with the rest of its 61 skills, 25 commands, 23 agents, 4 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 workflow-cleanup-merged

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

Your own site · 80×15
<a href="https://agentmods.dev/skills/lugassawan/swe-workbench/workflow-cleanup-merged"><img src="https://agentmods.dev/badge/skills/lugassawan/swe-workbench/workflow-cleanup-merged.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 47 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 7,249 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.00047 $0.07249
Opus 5.5 $0.00019 $0.02900
Sonnet 5.5 $0.00009 $0.01450
Haiku 4.5 $0.00005 $0.00725

Measured 2d ago against content hash 842089b362e5, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

workflow-cleanup-merged 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 2d ago.

The scan reads SKILL.md. This mod also ships 5 executable files (scripts/check-rimba-hook.sh, scripts/delete-branches.sh, scripts/probe-worktree.sh, …), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

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/workflow-cleanup-merged/SKILL.md · 250 lines

How it starts

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

Workflow: Cleanup Merged Branch

Announce at start: "I'm using the workflow-cleanup-merged skill to clean up after the merged PR."

When to Invoke

  • After the user has confirmed a PR is merged on GitHub.
  • Invoked by /swe-workbench:cleanup-merged (user-triggered, one-off cleanup).
  • Invoked by Mode C orchestration (orchestration.md) at Step 7, after each merge round.

Never auto-trigger. Cleanup is user-initiated or orchestrator-initiated. Do not attach to a Stop hook.

What This Skill Does NOT Do

  • Does not merge PRs — that is the user's action.
  • Does not force-delete branches with uncommitted work — no --force, ever.
  • Does not squash, rebase, or alter commit history.
  • Does not bypass branch protection rules.
  • Does not verify CI status — CI verification happens in Phase 3/4 before the PR is created.

Cleanup Contract

Step 1 — Resolve Target PR

  • If the user passed a PR number → use it directly.
  • Else → derive from current branch:
    gh pr view --json number,state,mergedAt,headRefName,headRepository,body
    
    Extract headRefName as the branch name to clean up.

Step 2 — Verify Merged via gh (Sole Oracle)

gh pr view <number> --json state,mergedAt,headRefName,headRefOid,url,body

Read state == "MERGED" and mergedAt != null. Abort with a clear message if either condition fails. Capture the url-derived owner/repo (the PR record in hand) and headRefOid for Step 5 — swe-workbench-sweep-residuals "$NUMBER" --repo "$OWNER/$REPO" --head-sha "$HEAD_SHA" uses them to scope the backstop sweep by repository and to fingerprint-attribute legacy un-scoped artifacts.

Never use git branch --merged as a merge check. GitHub's default squash-merge strategy creates a new commit SHA on main; the original branch tip is not a merge ancestor of main, so git branch --merged silently lies. gh is the only oracle that does not lie.

Step 3 — Classify the Primary Lease, Free Session, Anchor cwd, Sync Local Main

Read the full file on GitHub · 250 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. 2d ago Changed 842089b362e5
  2. 10d ago Changed · +10 lines 7b3072fca12e
  3. 26d ago Changed · +2 lines scan C → A fae1bcb7b022
  4. 1mo ago Changed 188fa57a8eb2
  5. 1mo ago First seen · 238 lines · 47 tokens per session scan C 8abfb6774afa

Subscribe to this mod's changes

workflow-cleanup-merged is a skill published in the GitHub repository lugassawan/swe-workbench (3 stars, last pushed yesterday), licensed MIT. It adds 47 tokens to every session and 7,249 once invoked, about $0.0002 per session on Opus 5.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-09-03.

Related

Other skills, from other repositories

release

Cut a brooks-lint release: set the version in package.json, propagate it across all four plugin manifests and every version-bearing text file (README badges, docs site metadata), write the CHANGELOG entry, validate, then commit, push, tag, and publish the GitHub release. Triggers when the maintainer asks to "release"…

hyhmrright/brooks-lint · 135 tokens

gh-skill

Manage agent skills with gh skill. Use this skill to discover, preview, install, update, and publish Agent Skills so an agent can self-manage the skills available in its environment.

cli/cli · 41 tokens

update-pr

Update an existing pull request with new changes. Use when the user wants to update a PR, push follow-up changes to a PR, refresh a PR description, or sync a PR with latest commits. Triggers on: update pr, update-pr, update the pr, push to pr, refresh pr, sync pr, update pull request.

ReflexioAI/claude-smart · 71 tokens

new-skill

Scaffold a new brooks-lint analysis skill so it passes npm run validate and npm run evals on the first try — generates skills/{name}/SKILL.md (with the mandatory "Do NOT trigger for:" clause and a Process section citing guide step ranges) plus skills/{name}/{name}-guide.md (sequentially numbered steps), then appends…

hyhmrright/brooks-lint · 145 tokens

smart-rebase

Smart partial rebase for squash-merge repositories. Auto-detect which commits to keep/drop when base branch was squash-merged into target. Use when: user says 'rebase', 'partial rebase', 'base already merged', 'smart rebase', or /smart-rebase. Not for: simple git rebase (the developer runs it — no skill executes…

sd0xdev/sd0x-harness · 133 tokens

architecture-refiner

Facilitate a structured conversation to define architecture principles for a repository. Supports multiple architecture styles: clean architecture (default), hexagonal / ports & adapters, modular monolith, or custom. Produces a formal architecture document that the corresponding atom will use. Use when setting up a…

techygarg/lattice · 114 tokens