---
name: platform-pr-review
description: >-
  Review and merge all open PRs in the platform monorepo. Run on "review open
  PRs", "review and merge PRs", "check PRs", "/platform-pr-review". Triages
  each PR by type (release/changeset vs real code), groups related PRs, runs
  seam-reviewer on code diffs, adds security-gate for money paths
  (ledger/billing/auth/checkout/fulfillment/affiliate/webhook/payout), fixes
  failures via cursor-orchestrator, then merges passing PRs.
---

# platform-pr-review

**Audience: main-loop orchestrator (me).** Optimize for activation, not prose.

## Step 1 — List + triage

```bash
gh pr list --state open --json number,title,headRefName,files,additions,deletions
```

Classify each PR into one of three buckets:

| Bucket | Criteria | Action |
|---|---|---|
| **Release** | `headRefName` starts with `changeset-release/`; only CHANGELOGs + `package.json` version bumps + consumed `.changeset/*.md` + auto-generated `.astro/` files | Fast-path: verify no logic files sneaked in, then merge directly — no seam or security review needed |
| **Code — no money path** | Real code change; no files matching money-path pattern (see below) | seam-reviewer only |
| **Code — money path** | Real code change; ≥1 file matches money-path pattern | seam-reviewer **AND** security-gate |

**Money-path file pattern** (any match → money path):
- packages matching: `ledger`, `billing`, `checkout`, `fulfillment`, `affiliate`, `invoicing`
- file name/path matching: `auth`, `webhook`, `payout`, `refund`, `transfer`, `escrow`, `charge`, `session`, `token`, `password`, `crypto`

**Grouping rule:** PRs touching the same module family (e.g. two PRs both in `commerce-checkout*`) → review together as one diff. PRs in unrelated areas → review independently.

## Step 2 — Release PRs (fast-path)

For each Release bucket PR:
1. Skim diff — confirm only CHANGELOGs, `package.json` bumps, consumed changesets, auto-generated files.
2. If any logic file sneaked in → reclassify as Code PR and route accordingly.
3. If clean → merge: `gh pr merge <N> --merge`

## Step 3 — Code PRs: seam-reviewer

Dispatch `seam-reviewer` native codex subagent (not bash tool) for each PR (or grouped set). Give it:

```
Review the diff for PR #<N> against:
- The module's boundary spec in docs/specs/<module>-boundaries.md (if it exists)
- coding-standard.md §4 seam checklist
- R1–R3 porting hazards
- §2 ladder

Fetch the diff with: gh pr diff <N>

Fix small problems yourself (LOP ≥ LOC rule: if lines-to-fix ≤ lines-to-brief, fix in place).
Escalate only: big refactor needed, total redo, or spec contradiction you cannot resolve.

Return verdict: PASS | FAIL-SMALL (fixed) | FAIL-ESCALATE (describe what).
```

**seam-reviewer model/effort: gpt-5.6-sol (xhigh effort)**

## Step 4 — Money-path PRs: security-gate

For PRs in the money-path bucket, ALSO run `security-gate` skill after seam-reviewer:

```bash
python3 ~/.claude/security-gate/gate.py <target-file> \
  --alias '@platform-modules/=packages/' \
  --k 3 --depth 2 --report /tmp/security-gate-pr<N>.md
```

Run on each money-path file in the diff. Read report; any BLOCK or REPORT-ONLY finding must be resolved before merge.

## Step 5 — Handle failures

| Verdict | Action |
|---|---|
| **PASS** | Proceed to merge (Step 6) |
| **FAIL-SMALL (fixed)** | seam-reviewer already committed the fix; re-run gate if money path; proceed to merge |
| **FAIL-ESCALATE** | Invoke `gpt-5.6-luna/low` native codex subagents (not bash tool) with the escalation description as the task brief. After cursor fixes, re-dispatch seam-reviewer on the new diff. Loop until PASS. |
| **Security BLOCK** | Fix the finding (self if small, cursor if large). Re-run security-gate. Do not merge until clean. |

## Step 6 — Merge

```bash
gh pr merge <N> --merge
```

## Step 7 — Report

After all PRs processed, report concisely:
- PRs merged (list with numbers + one-line description)
- PRs that needed fixes (what was fixed)
- PRs blocked (why, what needs owner attention)

## Constraints

- **Never merge a PR with unresolved security-gate BLOCK** — not even with a justification note; fix first.
- **Never skip seam-reviewer on a code PR** — the value is the independent-context pass; inline review is not equivalent.
- **Never downgrade seam-reviewer to non-opus** — per seam-reviewer benchmark (opus vs sonnet: sonnet missed §4 catch + added rejected memo). See memory [[seam-reviewer-model-benchmark]].
- **Judgment stays in main loop** — seam-reviewer returns evidence + fixes small things; pass/fail verdict and merge decision are mine.
- **Release PRs: verify before fast-merging** — a changeset PR that accidentally contains a logic change is a code PR.
