← ClaudeAtlas

workflow-cleanup-mergedlisted

Use after a PR has been merged on GitHub to remove the local worktree, delete the local branch, delete the remote branch, and fast-forward local main — safely, with squash-merge support.
lugassawan/swe-workbench · ★ 2 · Code & Development · score 71
Install: claude install-skill lugassawan/swe-workbench
# 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 ``` 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 ``` Read `state == "MERGED"` **and** `mergedAt != null`. Abort with a clear message if either condition fails. **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 n