--- description: Review, checkout, test, and prepare PR merge for git/jj repos argument-hint: " [test-command]" --- # Review, checkout, test, and prepare PR merge for git/jj repos 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. **PR**: $1\ **Test command override**: ${@:2} Workflow: 1. **Identify** - Detect VCS: `jj root` → jj, else git. Detect host/tooling: GitHub `gh` if available; otherwise generic git remote. - Resolve PR metadata: title, author, base, head, URL, status, CI, labels. - Fetch latest base/head: jj `jj git fetch`; git `git fetch`/`gh pr checkout` path. 2. **Protect local work** - Check jj `jj status` or git `git status --short`. - If dirty unrelated work exists: do not overwrite. Prefer isolated jj workspace or git worktree. - Detect repo style via jj `jj workspace list` or git `git worktree list`. 3. **Checkout** - jj: prefer isolated workspace: `jj workspace add -r `; otherwise `jj new ` only when safe. - git: prefer worktree when repo uses worktrees, current tree is dirty, or PR needs isolation; otherwise branch checkout when clean. - GitHub path: use `gh` for metadata/merge; use VCS-native fetch/checkout/workspace for files. - Generic path: fetch PR/head ref or remote branch/bookmark, then create branch/worktree/workspace. 4. **Review diff** - Compare PR head vs base: jj `jj diff --from --to `; git `git diff ...`. - Read relevant files, tests, docs, configs. - Check correctness, security, perf, API compat, migrations, UX, error handling. - Verify PR matches issue/description. 5. **Test** - If test override provided, run it. - Else infer project commands from README, package files, lockfiles, CI, justfile, Makefile. - Run focused tests first, then broader suite if reasonable. - Include lint/typecheck/build when conventional. - Capture exact commands and outcomes. 6. **Report** - Produce structured report: - PR summary - Checkout location + base/head SHAs/change IDs - Review findings: blockers / warnings / notes with file:line refs - Tests run: command → pass/fail - Merge readiness: READY | NOT READY - Exact merge plan/command to run after OK - If not ready, list minimal required fixes. 7. **Wait** - Stop after report. - Ask for explicit OK to merge only if READY. - 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. - After successful merge: remove jj workspace or git worktree/branch of PR