2 -description: Review, checkout, test, and prepare PR merge
2 +description: Review, checkout, test, and prepare PR merge for git/jj repos
3 3 argument-hint: "<
pr-url|number|branch|ref> [test-command]"
6 -Review PR end-to-end and prepare merge. Do **not** merge until explicit user OK.
6 +Review PR end-to-end and prepare merge. Do **not** merge until explicit user OK. If `jj root` succeeds, use jj-native status/diff/workspace commands; otherwise use git.
9 9 **Test command override**: ${@:2}
14 - - Detect host/tooling: GitHub `gh` if available; otherwise generic `git`.
14 + - Detect VCS: `jj root` → jj, else git. Detect host/tooling: GitHub `gh` if available; otherwise generic git remote.
15 15 - Resolve PR metadata: title, author, base, head, URL, status, CI, labels.
16 - - Fetch latest base/head.
16 + - Fetch latest base/head: jj `jj git fetch`; git `git fetch`/`gh pr checkout` path.
18 18 2. **Protect local work**
19 - - Check `git status --short`.
20 - - If dirty unrelated work exists: do not overwrite. Prefer isolated worktree.
21 - - Detect repo style via `git worktree list`, existing branch/worktree conventions.
19 + - Check jj `jj status` or git `git status --short`.
20 + - If dirty unrelated work exists: do not overwrite. Prefer isolated jj workspace or git worktree.
21 + - Detect repo style via jj `jj workspace list` or git `git worktree list`.
24 - - Prefer worktree when repo uses worktrees, current tree is dirty, or PR needs isolation.
25 - - Use branch when repo convention/current state is clean and branch checkout is safe.
26 - - GitHub path: `gh pr checkout <PR>` or fetch ref, then create branch/worktree.
27 - - Generic path: fetch PR/head ref or remote branch, then create branch/worktree.
24 + - jj: prefer isolated workspace: `jj workspace add <path> -r <head-rev>`; otherwise `jj new <head-rev>` only when safe.
25 + - git: prefer worktree when repo uses worktrees, current tree is dirty, or PR needs isolation; otherwise branch checkout when clean.
26 + - GitHub path: use `gh` for metadata/merge; use VCS-native fetch/checkout/workspace for files.
27 + - Generic path: fetch PR/head ref or remote branch/bookmark, then create branch/worktree/workspace.
30 - - Compare PR head vs base.
30 + - Compare PR head vs base: jj `jj diff --from <base> --to <head>`; git `git diff <base>...<head>`.
31 31 - Read relevant files, tests, docs, configs.
32 32 - Check correctness, security, perf, API compat, migrations, UX, error handling.
33 33 - Verify PR matches issue/description.
43 43 - Produce structured report:
45 - - Checkout location + base/head SHAs
45 + - Checkout location + base/head SHAs/change IDs
46 46 - Review findings: blockers / warnings / notes with file:line refs
47 47 - Tests run: command → pass/fail
48 48 - Merge readiness: READY | NOT READY
53 53 - Stop after report.
54 54 - Ask for explicit OK to merge only if READY.
55 - - On OK: re-fetch, verify PR still current/mergeable, run critical checks if needed, then merge using repo convention (`gh pr merge`, platform tool, or local merge). Report final status.
56 - - After successful merge: remove worktree/branch of PR
55 + - On OK: re-fetch, verify PR still current/mergeable, run critical checks if needed, then merge using repo convention (`gh pr merge`, platform tool, jj bookmark move/push, or local git merge). Report final status.
56 + - After successful merge: remove jj workspace or git worktree/branch of PR