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 --squashas the only path tomain. - Do not run
git pushat 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 mergesucceeds. - Ensure PR state is
MERGED, neverCLOSED. - 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.mdfrom/reviewpr.local/prep.mdfrom/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 --squashonly. - Do not run
git pushat all in this command.