# Prepare Pr

> Prepare a GitHub PR for merge by rebasing onto main, fixing review findings, running gates, committing fixes, and pushing to the PR head branch. Use after /reviewpr. Never merge or push to main.

- Skill: `jiayaoqijia/prepare-pr-2` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx get-skill add jiayaoqijia/prepare-pr-2`
- Raw SKILL.md: https://api.skillmd.com/api/skills/jiayaoqijia/prepare-pr-2/raw
- Safety review: pending (external: skill-scanner PASS, skillspector PASS)
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: jiayaoqijia (https://skillmd.com/u/jiayaoqijia)
- Updated: 2026-09-22
- Page: https://skillmd.com/skills/jiayaoqijia/prepare-pr-2

---


# 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 `main` or `origin/main`. Push only to the PR head branch.
- Never run `git push` without specifying remote and branch explicitly. Do not run bare `git push`.
- Do not run `git clean -fdx`.
- Do not run `git add -A` or `git 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.md` with 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.

```sh
git rev-parse --show-toplevel
WORKTREE_DIR=".worktrees/pr-<PR>"
```

Run all commands inside the worktree directory.

## Load Review Findings (Mandatory)

```sh
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

1. Identify PR meta (author, head branch, head repo URL)
2. Fetch the PR branch tip into a local ref
3. Rebase PR commits onto latest main
4. Fix issues from `.local/review.md` (all BLOCKER and IMPORTANT items)
5. Update `CHANGELOG.md` if flagged in review
6. Update docs if flagged in review
7. Commit prep fixes (stage only specific files)
8. Run full gates before pushing (`pnpm install && pnpm build && pnpm check && pnpm test`)
9. Push updates back to the PR head branch (force-with-lease, never to main/master)
10. Verify PR is not behind main
11. Write prep summary artifacts to `.local/prep.md`
12. Output diff stat and status

## Guardrails

- Worktree only.
- Do not delete the worktree on success. `/mergepr` may 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.

