| name | merge-pr |
| description | Merge a GitHub PR via squash after /preparepr. Use when asked to merge a ready PR. Do not push to main or modify code. Ensure the PR ends in MERGED state and clean up worktrees after success. |
Merge PR
Overview
Merge a prepared PR via gh pr merge --squash and clean up the worktree after success.
Inputs
- Ask for PR number or URL.
- If missing, auto-detect from conversation.
- If ambiguous, ask.
Safety
- Use
gh pr merge --squash as the only path to main.
- Do not run
git push at all during merge.
Execution Rule
- Execute the workflow. Do not stop after printing the TODO checklist.
- If delegating, require the delegate to run commands and capture outputs.
Completion Criteria
- Ensure
gh pr merge succeeds.
- Ensure PR state is
MERGED, never CLOSED.
- Record the merge SHA.
- Run cleanup only after merge success.
First: Create a TODO Checklist
Create a checklist of all merge steps, print it, then continue and execute the commands.
Setup: Use a Worktree
Use an isolated worktree for all merge work.
git rev-parse --show-toplevel
WORKTREE_DIR=".worktrees/pr-<PR>"
Run all commands inside the worktree directory.
Load Local Artifacts (Mandatory)
Expect these files from earlier steps:
.local/review.md from /reviewpr
.local/prep.md from /preparepr
Steps
- Identify PR meta
- Run sanity checks (not draft, checks passing, not behind main)
- Merge PR and delete branch (
gh pr merge <PR> --squash --delete-branch)
- Get merge SHA
- Optional comment thanking contributor
- Verify PR state is MERGED
- Clean up worktree only on success
Guardrails
- Worktree only.
- Do not close PRs.
- End in MERGED state.
- Clean up only after merge success.
- Never push to main. Use
gh pr merge --squash only.
- Do not run
git push at all in this command.