---
description: "Run parallel review on a branch's diff or a Pull Request: 3 models on Claude Code (Fable + Opus + Sonnet; Opus + Sonnet while the fable rung is off), 3 models on Copilot CLI (GPT + Opus + Sonnet). On PR input, posts per-finding inline comments and sets approve/needs-work review state. Use when a branch diff or a pull request needs reviewing before it merges."
description-tr: "Bir branch diff'i veya Pull Request üzerinde paralel review koşar: Claude Code'da 3 model (Fable + Opus + Sonnet; fable kapalıyken Opus + Sonnet), Copilot CLI'da 3 model (GPT + Opus + Sonnet). PR girdisinde bulgu başına inline yorum atar ve approve/needs-work durumunu işaretler."
argument-hint: "[#N | repo#N | PR-URL | branch] [--with <path|owner/repo>]  -  optional: PR by number/URL, repo+number, or local branch. Supports GitHub and Bitbucket Server URLs. If omitted (interactive), open GitHub + Bitbucket PRs are listed for multi-select; autopilot falls back to the current branch. --with names the counterpart app repo for the platform-parity cross-check."
parameters: [{"name":"target","kind":"pull-request"},{"name":"--with","kind":"path"}]
gui: form
destructive: false
confirm: none
---

# multi-agent review  -  Review Only Mode

**Access check, before anything else.** This command can write outside this machine, so a login the site closed is stopped here, before any question or write.

```bash
ACCESS_LINE=$(node "$HOME/.claude/scripts/usage-access.mjs"); ACCESS_RC=$?
```

`ACCESS_RC` 3: print `$ACCESS_LINE` as written and stop: no question, no write, attended or unattended. Any other exit continues (the check fails open). Contract: `$HOME/.claude/multi-agent-refs/features/usage-reporting.md` "The access check".

**Input**: $ARGUMENTS

Skip Phase 0-3 and review a diff only: empty input (PR picker, or the current branch in autopilot), a branch, or a PR (`#N`, `repo#N`, GitHub or Bitbucket Server URL). Input matrix: `$HOME/.claude/multi-agent-refs/review/inputs.md`.

Branch mode prints to chat only. PR mode also posts per `$HOME/.claude/multi-agent-refs/channels/pr-review-actions.md`: inline comments + an approve / needs-work state.

## Gotchas

- The counterpart-repo comparison needs exactly one resolved candidate. With several, an unattended run skips it silently, so an autopilot review can have no cross-platform section.
- The counterpart's stack comes from marker files, never from the repo name.

## Steps

### 0. Session bootstrap

```bash
: "${TASK_ID:=review-$(date +%s)-$$}"
export TASK_ID
trap 'rm -f /tmp/multi-agent-review-${TASK_ID}-*' EXIT
```

Standalone only (a `review-` id): register a tracker record per `$HOME/.claude/multi-agent-refs/review-standalone-tracker.md`.

### 1. Parse the input  -  pick a resolution path

Empty -> `kind=pick`; `https://github.com/*/pull/*`, `repo#N`, `#N` or a bare number -> `kind=pr; provider=github`; `https://bitbucket.*/projects/*/repos/*/pull-requests/*` -> `kind=pr; provider=bitbucket-server`; anything else -> `kind=branch; provider=local`. Before parsing, read `review/inputs.md` "Step 1": the case block and field extraction.

Save to `agent-state.review.input = { kind, provider, ref?, orgRepo?, bbServerHost?, bbProjectKey?, bbRepoSlug?, prNumber?, raw }`. For `github`, Step 2 also persists `agent-state.review.headCommitSha` (inline comments need `commit_id`).

### 1a. No-input PR picker  -  interactive only

Autopilot skips it: no ref means branch mode on the current branch, no prompt. Otherwise list open PRs from both providers (an absent token or CLI contributes nothing, never a hard failure), ask `AskUserQuestion` `multiSelect: true` per `$HOME/.claude/multi-agent-refs/picker-contract.md`, and **loop Steps 2-7 once per selected PR**. An empty list or no selection falls back to branch mode. Commands and fields: `review/inputs.md` "Step 1a".

### 2. Fetch the diff  -  kind-aware

Branch: `git diff origin/develop...{ref}`. GitHub: `gh pr diff`, plus `headCommitSha`. Bitbucket Server: the REST diff endpoint, credentials through `prefs.global.keychainMapping` (never hardcoded key names, never on argv), any non-200 a hard failure. Read `review/inputs.md` "Step 2" before fetching. Save to `/tmp/multi-agent-review-${TASK_ID}-diff.patch`.

### 2b. Module review guides

A changed module's own CLAUDE guide must be consulted. Read `$HOME/.claude/multi-agent-refs/review/module-guides.md` before Step 2b: discovery, the cap of 5, the PR-mode probe, and the prompt block injected into every Step 3 reviewer. No hit: silent no-op. Persist `agent-state.review.moduleGuides`. A guide governs only files under its own directory.

### 2c. Valven delivery rules  -  required on every input

Read `$HOME/.claude/multi-agent-refs/review/valven.md` before Step 2c: gate arguments per input, every rule family, and the judgement rules each Step 3 prompt gets. Always:

- Exit 2: print the stderr line and continue with `Valven: not measured (<reason>)` in the Step 6 summary. Never print it as passed.
- `findings[]` join at Step 5 with `tag: valven`, accepted unless the task is exempt; an accepted `important` or `blocking` one makes Step 7 NEEDS WORK. Step 6 adds its "Summary lines".

### 3. Launch parallel reviewers  -  host-CLI dependent

Resolve the fable slots first on Claude Code (this command has no Phase 0):

```bash
REVIEW_RUNG=$(bash "$HOME/.claude/lib/model-dispatch.sh" subagent --persona reviewer --default fable)
TRIAGE_RUNG=$(bash "$HOME/.claude/lib/model-dispatch.sh" subagent --persona triage --default fable)
```

Anything but `fable` drops Agent 1, runs triage on `$TRIAGE_RUNG`, and prints `INFO: fable rung disabled by prefs; review panel = Opus + Sonnet, triage on <rung>.` Never dispatch a Fable reviewer or a Fable triage on the model list alone. Read `$HOME/.claude/multi-agent-refs/review/panel.md` "Reviewers" before dispatch: the per-host panels. Rung switch: `$HOME/.claude/multi-agent-refs/features/model-fallback.md`.

Each reviewer gets the diff, the 2b guides, the 2c judgement rules and the prompt from `$HOME/.claude/multi-agent-refs/phases/phase-3-review.md`, and returns `findings[]`.

### 4. Store-compliance cross-reference

Release-relevant files load the catalog (`apple-archive-compliance` for iOS, `google-play-compliance` for Android); each finding gets its `ruleID` plus the policy ref. Catalog-only, no binaries; a full scan is `/multi-agent:test "store-ready"`. Triggers and paths: `review/panel.md` "Store compliance".

### 4b. Platform parity cross-check (advisory, read-only)

When a counterpart repo on the other mobile platform resolves and the diff touches a screen, service, request model or localization file, compare endpoints, parameters, business rules and localization keys. Several candidates ask once interactively and skip silently unattended; none skips silently; the counterpart is never edited. Resolution order (including `--with` and `counterpartRoots`) and output: `$HOME/.claude/multi-agent-refs/platform-parity.md`.

### 5. Triage (`$TRIAGE_RUNG`)

Classify 🔴 Blocking / 🟡 Important / 🟢 Suggestion; mark each `accepted`, `deferred` (Triage notes) or `rejected`. Only `accepted` reach the PR. Settle every `cannotVerify` row per `phase-3-review.md` 3.2 (`verified` / `finding` / `out-of-scope`, each with its file:line); list unsettled rows.

### 6. Print the chat summary (always)

One row per reviewer that ran, then consensus; this ALWAYS prints, in every input mode. Template: `review/panel.md` "Summary".

### 7. Post to PR  -  only when input.kind === "pr"

- **Decision** from `accepted` counts: 0 accepted blocking AND 0 accepted important -> **APPROVE**; ≥1 accepted blocking OR ≥1 accepted important -> **NEEDS WORK** (`NEEDS_WORK`). Suggestions never block and never post inline.
- **No monolith advisory comment** (never one body via `gh pr comment`); findings are inline comments at `file:line`, in `outputLanguage`.

Interactive asks first (default: post); autopilot posts; `--no-comment` / `--no-post` skips. Post with `bash $HOME/.claude/lib/post-pr-review.sh "$TASK_ID"`. Prompt shape, `github` / `bitbucket-server` endpoints and fallbacks: `review/panel.md` "Posting". A failed post exits non-zero; the chat summary stays the source of truth.

### 8. Token telemetry

After each reviewer call: `bash $HOME/.claude/scripts/phase-tracker.sh tokens <N> <in> <out>` (`<N>` = the run's Review phase, or step 2 standalone; `tracker-contract.md`).
