Prepare PR
Overview
Prepare a PR branch for merge with review fixes, green gates, and an updated head branch.
Inputs
- Ask for PR number or URL.
- If missing, auto-detect from conversation.
- If ambiguous, ask.
Safety
- Never push to
mainororigin/main. Push only to the PR head branch. - Never run
git pushwithout specifying remote and branch explicitly. Do not run baregit push. - Do not run
git clean -fdx. - Do not run
git add -Aorgit add .. Stage only specific files changed.
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
- Rebase PR commits onto
origin/main. - Fix all BLOCKER and IMPORTANT items from
.local/review.md. - Run gates and pass.
- Commit prep changes.
- Push the updated HEAD back to the PR head branch.
- Write
.local/prep.mdwith a prep summary. - Output exactly:
PR is ready for /mergepr.
First: Create a TODO Checklist
Create a checklist of all prep steps, print it, then continue and execute the commands.
Setup: Use a Worktree
Use an isolated worktree for all prep work.
git rev-parse --show-toplevel
WORKTREE_DIR=".worktrees/pr-<PR>"
Run all commands inside the worktree directory.
Load Review Findings (Mandatory)
if [ -f .local/review.md ]; then
echo "Found review findings from /reviewpr"
else
echo "Missing .local/review.md. Run /reviewpr first and save findings."
exit 1
fi
Steps
- Identify PR meta (author, head branch, head repo URL)
- Fetch the PR branch tip into a local ref
- Rebase PR commits onto latest main
- Fix issues from
.local/review.md(all BLOCKER and IMPORTANT items) - Update
CHANGELOG.mdif flagged in review - Update docs if flagged in review
- Commit prep fixes (stage only specific files)
- Run full gates before pushing (
pnpm install && pnpm build && pnpm check && pnpm test) - Push updates back to the PR head branch (force-with-lease, never to main/master)
- Verify PR is not behind main
- Write prep summary artifacts to
.local/prep.md - Output diff stat and status
Guardrails
- Worktree only.
- Do not delete the worktree on success.
/mergeprmay reuse it. - Do not run
gh pr merge. - Never push to main. Only push to the PR head branch.
- Run and pass all gates before pushing.