[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6BVJ23D24K530S7WK257HHK":3,"skill-same:01M6BVJ23D24K530S7WK257HHK":105},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":8,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":18,"categories":19,"keywords":30,"publishedAt":51,"linkOnly":52,"markdownContent":53,"markdownBody":54,"frontMatter":55,"refName":56,"commitSha":57,"skillDirectory":58,"forksCount":59,"repositoryHtmlUrl":60,"repositoryHomepageUrl":17,"ownerHtmlUrl":61,"ownerBlogUrl":17,"ownerDescription":17,"updatedAt":62,"install":63,"resources":76},"01M6BVJ23D24K530S7WK257HHK","pr-review","PR 全面代码审查","Comprehensive pre-PR review orchestrator. Runs named specialist subagents on the current branch's committed diff, conditionally checks simplification, verifies each normalized Critical\u002FImportant candidate with a dedicated finding-verifier, then synthesizes Critical \u002F Important \u002F Suggestions \u002F Strengths using the bundled `references\u002Freview-criteria.md` gate policy. Use before creating a pull request as a heavy quality gate. Intended successor to the legacy bash `triple-review` orchestrator.","全面的 PR 前审查编排器。针对当前分支已提交的差异运行命名的专项子智能体，按需检查简化情况，并使用专门的发现项验证器逐一核验规范化后的 Critical\u002FImportant 候选发现项，随后结合内置的 `references\u002Freview-criteria.md` 门禁策略，综合生成 Critical \u002F Important \u002F Suggestions \u002F Strengths。在创建拉取请求前作为重量级质量门禁使用。是旧版 bash `triple-review` 编排器的预期继任者。","toku345\u002Fdotfiles","toku345","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F3142849?v=4","01M6BVHFC948X4EGTFPQF53G6Q","Fumitaka Tokumitsu","01M6BVHFGV7PA8A2QHR2H8YWMX",1,"MIT",null,"https:\u002F\u002Fgithub.com\u002Ftoku345\u002Fdotfiles\u002Fblob\u002Fmain\u002Fprivate_dot_codex\u002Fskills\u002Fpr-review\u002FSKILL.md",[20,25],{"categoryNo":21,"categoryName":22,"taxonomyType":23,"taxonomyTypeDesc":24},"01M8BQ6TQZN6R52WBJ9H8NRMQM","软件开发工程师","PROFESSION","适用职业",{"categoryNo":26,"categoryName":27,"taxonomyType":28,"taxonomyTypeDesc":29},"01M8BR5V701HCN066VEP7H4812","代码仓库协作管理","SCENARIO","使用场景",[31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50],"pr review","pr","review","use","candidate","with","verifier","critical","as","simplification","references","Legacy","diff","orchestrator","branch","Bash","pull","pull request","quality gate","policy","2026-11-10 10:12:30",false,"---\nname: pr-review\ndescription: Comprehensive pre-PR review orchestrator. Runs named specialist subagents on the current branch's committed diff, conditionally checks simplification, verifies each normalized Critical\u002FImportant candidate with a dedicated finding-verifier, then synthesizes Critical \u002F Important \u002F Suggestions \u002F Strengths using the bundled `references\u002Freview-criteria.md` gate policy. Use before creating a pull request as a heavy quality gate. Intended successor to the legacy bash `triple-review` orchestrator.\n---\n\n# pr-review\n\n## Goal\n\nRun a comprehensive specialist review of the current branch's changes against its base, then synthesize findings into a single actionable report.\n\n## Review Criteria\n\nUse the bundled `references\u002Freview-criteria.md` as the source of truth for severity normalization, output budgeting, and re-review behavior. The short global `AGENTS.md` \u002F `CLAUDE.md` policy explains when to choose built-in review versus heavy gates; this skill file and its bundled reference define how `$pr-review` gates a change once invoked.\n\nApply these high-level constraints throughout the Procedure:\n- Optimize for merge decisions, not finding count.\n- Do not put nits, style preferences, speculative rewrites, or weakly grounded concerns into the fix queue.\n- Important findings are capped at 5 in the final aggregation; Suggestions are capped at 3.\n- If evidence is incomplete but the risk may be severe, state the missing verification explicitly instead of silently dropping the finding.\n- Re-review verifies prior Critical\u002FImportant findings and should not extend the loop with new nits, style feedback, or optional refactors.\n- Critical findings require `blocking: yes`, `impact_scope`, `verified_assumptions`, and no `unverified_assumptions` needed for the blocker claim.\n- Post-verification `needs-verification` with non-empty `missingVerification` downgrades a Critical candidate to Important; it remains visible, but not as a proven blocker. Other verdicts carrying `missingVerification`, or `needs-verification` without it, are invalid verifier outputs and must fail closed.\n- Stop the review loop when Critical and Important are both 0; do not re-run only for Suggestions.\n\n## Preconditions\n\n**Environment note**: this skill must be invoked from a terminal directly (`codex exec ...`), not from within an enclosing Claude Code session. The nested-bwrap permission failure documented in `~\u002F.codex\u002Fhistory.jsonl` (2026-03) makes nested invocation infinite-spawn-retry. The skill cannot reliably self-detect this; the caller takes responsibility.\n\nRun these checks in order. If any fails, abort with the indicated actionable error and do not proceed to the Procedure section.\n\n0. **V1\u002FV2 runtime contract** — Before running any shell or Git command and before invoking any collaboration tool, inspect the tool definitions exposed to this session. Runtime contract sentinel: `PR_REVIEW_RUNTIME_CONTRACT_V1_V2`.\n   - If collaboration tools are deferred, use the runtime's tool-discovery mechanism to resolve and inspect their definitions. Tool discovery is allowed here; a probe spawn is not. Do not infer the contract from feature flags, model name, tool namespace, profile name, or a prior session.\n   - Admit exactly one coherent family and record the selected adapter for the entire run:\n     - **The V1 adapter** requires `spawn_agent(agent_type,message)` with both arguments required and an `agent_id` in the successful result, targeted `wait_agent(targets)`, and `close_agent(agent_id)`. Its `spawn_agent` must not accept `task_name` or `fork_turns`.\n     - **The V2 adapter** requires `spawn_agent(task_name,message,agent_type?,fork_turns?,model?,reasoning_effort?)` with `task_name` and `message` required, untargeted `wait_agent(timeout_ms?)`, `list_agents(path_prefix?)`, and `interrupt_agent(target)`. Its `wait_agent` must not accept `targets`; `close_agent` must not be part of this family. `send_message(target,message)` and `followup_task(target,message)` may also be present and do not make the schema mixed, but the orchestrator must not use them for review-result transport or synchronization, and specialists must not use them under the control-plane ban. Although `agent_type`, `fork_turns`, `model`, and `reasoning_effort` are optional in the tool schema, every pr-review specialist spawn must set the exact `agent_type` and explicitly set `fork_turns` to `\"none\"`; omit `model` and `reasoning_effort` to inherit the parent.\n   - Optional unrelated, non-discriminating fields may be present in either family and do not by themselves make it mixed. Admission is determined by the required and forbidden control fields above; any added field that conflicts with those discriminators, or changes result identity or wait\u002Fcleanup semantics, is unknown and incompatible.\n   - Missing, unresolved, incomplete, mixed, or unknown definitions are not compatible. Do not combine tools from different families or use a generic\u002Fdefault agent fallback.\n   - If no coherent adapter can be selected, abort before repository inspection with this exact message:\n\n     ```text\n     ERROR: $pr-review requires one coherent Codex multi-agent V1 or V2 schema, but this session exposes missing, mixed, incomplete, or unknown collaboration tools.\n\n     No specialist was spawned and no review was performed. Tool exposure is fixed for the lifetime of this session.\n\n     Start a new Codex process from the repository under review:\n\n       codex exec --profile review -C '\u003Crepo-root>' '$pr-review --base \u003Csame-base>'\n\n     If the review-profile command still does not expose one exact supported schema, stop and report compatibility drift. Do not fall back to default agents.\n     ```\n\n   - For both adapters, before repository inspection read `references\u002Fbase-resolution-runtime-contract.json`, require sentinel `PR_REVIEW_BASE_RESOLUTION_CONTRACT_V2`, and use its operation allowlist, classification precedence, retry limit, invocation-fingerprint, immutable-OID values, and `allow_no_pr` transition sequence as the machine-readable base-resolution contract. Record whether the shell tool exposes `sandbox_permissions=require_escalated`; absence does not invalidate the immutable-OID path, but any later sandbox-denied operation that needs escalation must fail closed before specialist spawn. Abort before repository inspection if the contract is missing, malformed, unsupported, or conflicts with this prose.\n   - For both adapters, before repository inspection read `references\u002Ffinding-verifier-contract.json`, require sentinel `PR_REVIEW_FINDING_VERIFIER_CONTRACT_V1`, and use its candidate, task, scope, output, verdict, and integrity values as the machine-readable finding-verifier contract. Abort before repository inspection if the contract is missing, malformed, unsupported, or conflicts with this prose.\n   - For V2 only, call `list_agents` immediately after selection and require a **fresh agent tree**: the current orchestrator entry may exist, but it must have no descendant. Abort before repository inspection if listing fails, a descendant already exists, or the current tree cannot be identified unambiguously. This prevents this run from adopting, interrupting, or confusing another run's tasks.\n   - For V2 only, before repository inspection read `references\u002Fv2-runtime-contract.json`, require sentinel `PR_REVIEW_V2_SCHEDULER_CONTRACT_V4`, and use its timing, spawn, result, reconciliation, cleanup, and aggregation values as the machine-readable scheduler contract. Abort before repository inspection if the file is missing, malformed, unsupported, or conflicts with this prose.\n\n1. **Clean worktree** — Run `git status --porcelain --untracked-files=normal`. If the command fails, abort with the command output and do not review an unknown worktree state. If output is non-empty (uncommitted tracked changes or untracked-non-ignored files), abort with:\n   > \"Worktree has uncommitted changes: \\\u003Clist\\>. The review covers committed branch diff only; uncommitted changes would be silently excluded. To inspect staged, unstaged, and untracked changes first, run `codex review --uncommitted`. Commit or stash all listed changes, then retry `$pr-review`. (See ADR 0020.)\"\n\n2. **Base ref resolution** — Determine `$BASE` from one of three sources, in priority order. For the allowlisted `gh pr view`, `git fetch`, and `git remote set-head origin --auto` operations below, always try the ordinary sandbox first. Retry only a sandbox\u002Ftransport denial (`socket: operation not permitted`, a sandbox-caused DNS\u002Fconnect denial, blocked TLS\u002Fservice access, or EROFS\u002FEACCES on required `.git` metadata) by reissuing the exact original executable, argv, cwd, and ordinary environment once with `sandbox_permissions=require_escalated`. Never request a persistent prefix approval. Approval metadata and the sandbox field are the only permitted fingerprint differences. Do not elevate an ordinary Git ref\u002Fremote\u002FSSH-auth error, a GitHub API error, or an ambiguous failure. If escalation is unavailable, denied, or fails, abort before specialist spawn and recommend an immutable base OID.\n   - (a) If the user prompt provides an explicit base (for example, `--base develop` or \"review against develop\"), use that verbatim and skip all `gh` checks below. If the explicit base is an immutable commit\u002FOID, set `$BASE_REF` to that value and do not run `gh`, fetch, or any elevated command. Otherwise treat it as an origin branch name only after it passes `git check-ref-format --branch \"$BASE\"` and does not start with `-` or `+`, contain `:`, or contain another refspec\u002Fcontrol separator; reject anything else before running `git fetch`. For a valid branch name, run `git fetch --quiet origin \"refs\u002Fheads\u002F$BASE\"` through the scoped retry policy before validation, abort if it still fails, set `$BASE_REF=FETCH_HEAD`, and resolve `$BASE_COMMIT` immediately before any later fetch can overwrite `FETCH_HEAD`. Do not pass `$BASE` as a raw refspec. Do not proceed from existing local refs alone. If the caller needs offline execution, pass an immutable base commit.\n   - (b) If the user prompt includes `--allow-no-pr` or `$ALLOW_NO_PR` is set to `1` \u002F `true`, skip `gh` entirely. Run `git fetch --quiet origin` through the scoped retry policy; if it still fails, abort instead of reviewing a possibly stale default branch. Run `git remote set-head origin --auto` through the same policy; if it still fails, abort instead of trusting a stale local `origin\u002FHEAD` symref. Run `git symbolic-ref --quiet --short refs\u002Fremotes\u002Forigin\u002FHEAD`; if it fails or returns an empty value, abort instead of guessing a base. Strip the leading `origin\u002F` from the captured value, use the result as `$BASE`, use the full captured `origin\u002F\u003Cbranch>` ref as `$BASE_REF`, and add a `**Degraded coverage**: no PR base, fell back to default branch` line to the Output.\n   - (c) Otherwise use the required PR lookup itself as the only GitHub auth\u002Fnetwork probe; do not run the origin-unscoped `gh auth status`:\n     - Run `gh pr view --json baseRefName,baseRefOid --jq '[.baseRefName,.baseRefOid] | @tsv'` in the ordinary sandbox.\n     - If it fails with the explicit \"no pull request found for the current branch\" result, treat only that as the no-PR case. Otherwise run the same operation once in the ordinary sandbox with only `GH_DEBUG=api` added as a discriminator.\n     - Give a proven sandbox\u002Ftransport denial precedence over credential-looking text. On such a denial, retry the original non-debug `gh pr view` invocation once with `sandbox_permissions=require_escalated`. If the discriminator or elevated attempt reaches GitHub and proves HTTP 401 \u002F bad credentials, abort with:\n       > \"Stale `gh` auth detected. Run `gh auth login` and retry — the skill cannot resolve PR base ref without authenticated gh.\"\n     - If the discriminator remains ambiguous, escalation is unavailable\u002Fdenied, or the elevated command fails for any other reason, abort with a sanitized classification and the immutable-OID escape hatch. Do not persist or reproduce raw debug headers, responses, credential text, or tokens.\n     - If the successful authoritative result contains exactly two non-empty tab-separated fields (branch name and base commit OID), use the branch name as `$BASE`. Validate it with the same explicit-branch safety rules (`git check-ref-format --branch \"$BASE\"`, no leading `-` \u002F `+`, no `:` or other refspec\u002Fcontrol separator). Then run `git fetch --quiet origin \"refs\u002Fheads\u002F$BASE\"` through the scoped retry policy. Resolve `FETCH_HEAD^{commit}` and verify it exactly equals the returned `baseRefOid`; if it differs, abort with both OIDs. Set `$BASE_REF=FETCH_HEAD` only after that verification.\n     - If a successful result does not contain exactly two non-empty tab-separated fields, abort with sanitized output and do not infer a base from malformed data. Never fall back to `origin\u002FHEAD` after an unexpected `gh pr view` failure.\n\n   If none of (a)–(c) yields a base, abort with:\n   > \"No PR found for the current branch and no explicit base provided. By default the skill requires an open PR (Issue #186 fix) so all specialists share the same base ref. Either create a draft PR first, provide an explicit base in your prompt, or pass `--allow-no-pr` \u002F set `ALLOW_NO_PR=1` to fall back to the default branch (residual scope-divergence risk acknowledged).\"\n\n   Sandbox compatibility by base path:\n   - Explicit immutable commit\u002FOID bases do not require network access or `.git` metadata writes after the initial clean-worktree check; this is the only supported offline\u002Fread-only invocation path.\n   - Explicit branch-name bases require network access and `git fetch` writing `FETCH_HEAD`; sandbox denial may use the bounded scoped retry above.\n   - `--allow-no-pr` requires network access, `git fetch`, and `git remote set-head origin --auto`; sandbox denial may use the same bounded scoped retry.\n   - Auto-PR base resolution requires `gh pr view`, network access, and a verified fetch of the reported base branch; sandbox denial may use the bounded scoped retry, but offline runs remain unsupported.\n   - If callers need offline\u002Fread-only review, they must supply an immutable base commit OID.\n\n3. **Base ref validation** — Pin the already resolved `$BASE_REF` to an immutable commit before collecting any diff:\n   - If `gh pr view` returned `baseRefOid`, keep `$BASE_REF=FETCH_HEAD` after the verified fetch\u002FOID comparison; do not resolve the OID against a possibly stale local object database without fetching the PR base branch first.\n   - If an explicit branch base was fetched, keep `$BASE_REF=FETCH_HEAD`; do not replace it with a local branch or local remote-tracking ref.\n   - If `--allow-no-pr` selected the default branch, keep `$BASE_REF` as the fetched `origin\u002F\u003Cbranch>` ref.\n   - Otherwise use the explicit immutable base as `$BASE_REF`.\n   - Run `BASE_COMMIT=$(git rev-parse --verify \"$BASE_REF^{commit}\")` immediately after assigning `$BASE_REF` and record the exact output for all later collection and specialist prompts. If it fails, abort with:\n     > \"Base ref `\u003Cbase>` does not resolve to a commit. Check the base name or fetch the ref, then retry.\"\n\n## Procedure\n\nAfter preconditions pass:\n\n1. **Collect the review inputs and classify the diff**:\n   - Run `git rev-parse HEAD` as an independent, preceding tool call and wait for it to complete before starting any other collection. Do not put HEAD recording in the same parallel tool call as status, log, file-list, or diff collection.\n   - Require that call to succeed and record its commit OID as immutable `$HEAD_REF`. If HEAD recording fails or does not return a commit OID, abort without starting collection.\n   - After recording `$HEAD_REF`, use that immutable OID for every later log, file-list, and diff command. Do not use symbolic `HEAD` for those commands.\n   - Run `git status --short`, `git log --no-decorate \"$BASE_COMMIT..$HEAD_REF\"`, `git diff --name-only \"$BASE_COMMIT\"...\"$HEAD_REF\"`, and `git diff \"$BASE_COMMIT\"...\"$HEAD_REF\"`.\n   - Require every command to exit successfully. If any collection command fails, abort loudly instead of reviewing partial input.\n   - If the diff is genuinely empty, run the Final worktree guard immediately, then say `No committed changes relative to \u003Cbase>; nothing to review.` and stop rather than emitting a normal green review. Do not skip the final worktree or HEAD checks on the empty-diff path.\n   - Always write the exact full diff to a temp file, compute its byte count and SHA-256, and include the path, byte count, and SHA-256 in the specialist prompt. Use a BSD\u002FGNU-compatible suffix-free `mktemp` template with the random `X`s at the end, such as `diff_packet=$(mktemp \"${TMPDIR:-\u002Ftmp}\u002Fpr-review-diff.XXXXXX\")`; do not use a suffixed template such as `pr-review-diff.XXXXXX.diff`, which can collide on BSD `mktemp`. Abort if `mktemp`, diff writing, byte counting, or hashing fails. The diff packet is authoritative; any inline diff text is only a convenience excerpt. If a specialist cannot read the referenced packet or the packet hash does not match, it must return a fatal coverage error.\n   - Use `git diff --name-only` only for path-based categories:\n     - `test_paths`: path components or basenames that are tests, such as `tests\u002F`, `test\u002F`, `__tests__\u002F`, `*.test.*`, `*.spec.*`, `*_test.go`, `*_spec.rb`, `*.bats`, or basenames beginning with `test_`; do not classify ordinary runtime files as tests merely because they contain `test` in a role name such as `pr-test-analyzer`\n     - `operational_paths`: review\u002Fruntime assets such as `private_dot_codex\u002Fskills\u002F**\u002FSKILL.md`, `private_dot_codex\u002Fagents\u002F*.toml`, `.github\u002Fworkflows\u002F**`, `.claude\u002Fhooks\u002F**`, `.chezmoiscripts\u002F**`, `dot_local\u002Fbin\u002F**`, and managed shell\u002Fconfig files whose content affects tool behavior\n     - `docs_paths`: passive prose docs such as `docs\u002F`, `*.md`, or `README*`, excluding any path already classified as `operational_paths`\n     - `code_paths`: changed paths that are not passive docs-only assets, plus all `operational_paths`\n   - Inspect the full diff hunks for content-based categories:\n     - `comment_changes`: any added or removed comment line in source files, including mixed code+comment hunks\n     - `docs_or_comments`: `docs_paths` non-empty or `comment_changes` non-empty\n     - `type_changes`: hunks introducing `class` \u002F `interface` \u002F `type` \u002F `struct` \u002F `enum` \u002F `trait` \u002F `dataclass` \u002F schema definitions, plus hunks modifying lines inside an existing type or schema definition block\n\n   When in doubt, include the specialist (over-coverage is cheaper than missed findings).\n\n2. **Build the Stage 1 specialist set and spawn it in parallel** via `spawn_agent`.\n   - Every specialist spawn **must** select the exact custom role with `agent_type = \"\u003Cspecialist-name>\"`; omission and generic\u002Fdefault role fallback are forbidden in either adapter.\n   - Do not set `model` or `reasoning_effort` unless intentionally overriding the parent's selection; those inherit from the parent when omitted.\n   - Record the complete `expected_stage1` set before spawning so completeness can be checked before aggregation. It contains the three always-on roles plus up to four conditional roles, for a maximum of 7.\n   - Pass each spawn the following structured prompt:\n     - Target description: `Pre-PR review of branch \u003Ccurrent> against \u003C$BASE>`\n     - The resolved `$BASE_REF`\n     - The recorded `$BASE_COMMIT`\n     - The recorded `$HEAD_REF`\n     - The list of changed files (categorized)\n     - `git status --short`\n     - `git log --no-decorate \"$BASE_COMMIT..$HEAD_REF\"`\n     - The diff packet path, byte count, and SHA-256 (always supplied)\n     - Optional inline excerpt from `git diff \"$BASE_COMMIT\"...\"$HEAD_REF\"`; the packet remains authoritative if output is truncated\n     - Scope contract: review only the orchestrator-provided `$BASE_COMMIT...$HEAD_REF` committed branch diff. Do not substitute unqualified `git diff`, unstaged changes, a PR re-detection, a different base commit, a different HEAD, or another inferred scope. If the diff, file list, base commit, HEAD ref, or packet hash is missing or inconsistent, return a fatal coverage error.\n     - Coverage sentinel contract: the first output line must be either `COVERAGE_OK \u003Cspecialist> $BASE_COMMIT...$HEAD_REF \u003Cpacket_sha256>` or `FATAL_COVERAGE_ERROR \u003Cspecialist>: \u003Creason>`. Missing, malformed, or non-first-line sentinels are unusable output.\n     - Review-only contract: do not edit files, create files, apply patches, run formatters that write files, or otherwise dirty the worktree. Return markdown findings or suggestions only.\n     - Control-plane contract: `Do not call any collaboration\u002Fsubagent tools; return only your final review response.`\n     - Finding quality contract: every finding must include `blocking: yes\u002Fno`, `impact_scope`, `verified_assumptions`, and `unverified_assumptions`. Use `blocking: yes` only for clear merge blockers in the committed diff. Machine-local or ignored state, local-only performance regressions, developer-workflow-only false-greens, advisory observability gaps, and assumption-dependent risks should be `blocking: no` unless the committed diff proves a wider blocker.\n\n   Always spawn:\n   - `code-reviewer`\n   - `security-reviewer`\n   - `adversarial-reviewer`\n\n   Conditionally spawn (based on categorization):\n   - `pr-test-analyzer` — if `code_paths` is non-empty, especially when `test_paths` is empty\n   - `comment-analyzer` — only if `docs_or_comments` non-empty\n   - `silent-failure-hunter` — if `code_paths` is non-empty (the hunter suppresses noise internally; default-on avoids heuristic false negatives such as shell `|| true`)\n   - `type-design-analyzer` — only if `type_changes` non-empty\n\n   Dispatch the recorded set through the selected adapter:\n   - **The V1 adapter** keeps `pending_stage1` in deterministic order, `running_stage1` keyed by returned `agent_id`, and `completed_stage1` keyed by role. Run at most 6 Stage 1 agents concurrently. When one yields a final usable result, record it, call `close_agent` for that ID, and fill the freed slot. Never omit a scheduled role because of capacity.\n   - **The V2 adapter** derives a lowercase alphanumeric `run_token` from the random suffix of the already-created diff-packet `mktemp` path; reject an empty or unsafe token. Name each task `prr_\u003Crun_token>_s\u003Cstage>_\u003Crole-with-hyphens-replaced-by-underscores>_a\u003Cattempt>`, and verify before spawning that the name is absent. Every spawn must set `fork_turns=\"none\"`. Keep deterministic pending, running, and usable maps and run a **maximum of 3** children concurrently.\n     - Save the exact canonical task path returned by each successful spawn; the local task name alone is never an identity. Before each spawn and after each wait notification, use `list_agents` to verify every non-usable canonical task and the tree shape.\n     - If `spawn_agent` reports an error, immediately list status. If exactly the requested new name now exists and it did not exist before the call, adopt its canonical path and track it. If it is absent and the result is an **explicit capacity error**, retry once, only after a slot is available, with a new `attempt` name. A pre-existing name, more than one match, an absent task after any other\u002Fambiguous error, or failure of the single retry is fatal. Never retry the same name.\n     - After each notification, run one ordered reconciliation cycle: harvest and validate **all** newly delivered run-owned finals; call `list_agents` for one successful full-tree snapshot; harvest every envelope delivered at that tool boundary; evaluate all tracked tasks and descendants; then refill only if no fatal evidence exists. Never refill between those steps. Fill every freed slot immediately after its child becomes usable under Step 3, even while two other children remain running; do not wait for the current batch to finish. A scheduled role that cannot be spawned after a usable child frees capacity makes the stage fail closed.\n\n3. **Await all Stage 1 specialists** before proceeding.\n   - Start one monotonic 30-minute Stage 1 deadline before the first spawn. Neither progress, an interim message, a retry, nor a wait call resets it.\n   - **The V1 adapter** treats targeted `wait_agent` as polling, not a barrier: keep the remaining `agent_id` set, call `wait_agent` with those IDs and `timeout_ms = min(600000, remaining stage budget)`, record only final usable results, close completed IDs, fill capacity, and repeat until all expected roles are complete.\n   - **The V2 adapter** follows this state machine for each canonical task:\n\n     | State | Evidence | Next action |\n     | --- | --- | --- |\n     | running | canonical path has running status | wait or inspect a delivered envelope |\n     | final-seen | one matched `FINAL_ANSWER` payload, no accepted lifecycle evidence | retain the payload and reconcile status |\n     | completed-seen | completed status, no final payload | allow a **60-second delivery grace**, bounded by the stage deadline |\n     | retired-seen | task is absent from a successful full-tree snapshot after either observed-running evidence or a valid matching final | allow the same bounded delivery grace when the final is still pending |\n     | usable | valid final payload plus completed status or qualified retirement | retain evidence and fill capacity |\n     | fatal | error\u002Finterrupted status, disappearance without observed-running or a valid matching final, parent-interrupted retirement, invalid evidence, or expired deadline\u002Fgrace | clean up and abort |\n\n     - `wait_agent is notification-only`; never treat its return as a task result or barrier. `list_agents is status-only`; never extract review text from it. The only authoritative review body is the `Payload` of a delivered envelope whose `Message Type` is `FINAL_ANSWER` and whose `Sender` exactly equals a saved canonical task path. The envelope's `Task name` identifies the recipient (normally `\u002Froot`), not the child, and must never be used as sender identity.\n     - Ignore interim `MESSAGE` envelopes and do not reset any deadline. Validate a matching final immediately: an empty body, malformed\u002Fmissing first-line sentinel, `FATAL_COVERAGE_ERROR`, role\u002Fscope\u002Fhash mismatch, or stated inability to verify the packet is fatal before refill. Record the first valid matching final payload byte-for-byte. Ignore an identical duplicate `FINAL_ANSWER`; a **conflicting duplicate** for the same canonical task is fatal. A final payload from an unknown or merely name-matched sender is not usable.\n     - Bound each notification poll to `min(60000 ms, remaining stage budget, earliest active delivery-grace budget)`, then run the ordered reconciliation cycle. Never make a blocking wait longer than 60 seconds. If the result is below the tool's 10000 ms minimum, do not issue a wait that would cross the budget; inspect already-delivered envelopes and current status, then fail when the applicable deadline expires if evidence is still incomplete.\n     - Treat `completed` as normal lifecycle evidence. As a V2 compatibility fallback, also accept **qualified retirement** when a successful full-tree snapshot omits the exact saved canonical task after either (a) that task was previously observed with `running` status or (b) a valid matching `FINAL_ANSWER` from that canonical sender was already recorded. The final-backed path is allowed only because the recognized V2 runtime delivers `FINAL_ANSWER` at child-turn completion. Both paths require that the parent has never called `interrupt_agent` on the task and that no run-global fatal evidence exists. A spawn result, a failed\u002Fincomplete list, mere name matching, or disappearance before both observed running and a valid matching final is not retirement evidence and is fatal. If the runtime's child-turn-completion semantics or schema is not established, fail closed instead of applying the fallback. Any descendant other than a saved, tracked top-level specialist is an **unexpected descendant** and is fatal.\n     - If completed status or qualified retirement arrives first, start one per-task grace at that earliest lifecycle-evidence timestamp. The valid final must arrive strictly before `grace_start + 60000 ms` and before the stage deadline; equality or later is fatal. If the final payload arrives first, keep reconciling until completed status, qualified retirement, or the stage deadline. Later evidence never resets grace.\n     - Retain the first valid payload, lifecycle evidence, and canonical identity even after a task becomes usable and until stage aggregation. Continue validating later run-owned envelopes and statuses: ignore a byte-identical duplicate final, but make a conflicting duplicate, later observed error\u002Finterrupted status, or any other fatal evidence abort the stage. Run one final ordered reconciliation cycle before aggregation.\n   - Fail closed before aggregation if any expected specialist fails to spawn, errors, times out, returns empty output, or produces unusable output. On any abnormal exit after a spawn, stop dispatching pending roles; cleanup start is monotonic fatal and a later final cannot restore usability. The V1 adapter closes every remaining running V1 ID. The V2 adapter performs one final notification\u002Fstatus drain without extending the applicable deadline, then calls `interrupt_agent` only on a still-running run-owned top-level task or a still-running unexpected descendant beneath one of its saved canonical paths. Never interrupt the orchestrator or an unrelated path. Finally list status again and require that no run-owned task or owned descendant remains running; if cleanup cannot be confirmed, report cleanup failure together with the original fatal reason. Do not aggregate any partial result during cleanup.\n   - Fail closed before Stage 2 or aggregation if any specialist output is missing a first-line `COVERAGE_OK ...` or `FATAL_COVERAGE_ERROR ...` sentinel, or if the `COVERAGE_OK` sentinel does not match the expected specialist name, `$BASE_COMMIT...$HEAD_REF` scope, and packet SHA-256.\n   - Fail closed before Stage 2 or aggregation if any specialist output reports a fatal coverage error, missing\u002Finconsistent scope, inability to read the diff packet, packet hash mismatch, or otherwise says it was unable to verify the packet or reviewed scope.\n   - **Partial aggregation is forbidden**: every required role must be usable and pass coverage validation. If a future workflow wants partial results, require an explicit opt-in plus a visible degraded-coverage banner.\n   - Each successful specialist returns the coverage sentinel followed by markdown findings.\n\n4. **Scan Stage 1 output and normalize severity before Stage 2**:\n   - Apply `references\u002Freview-criteria.md` before trusting specialist labels. Specialist labels are useful signals, but final severity must still satisfy the bundled criteria.\n   - Read `references\u002Fseverity-rules.json` and classify each finding with its escalation table. The table is shared verbatim with the Claude-side `\u002Fpr-review` skill; when the escalation rules change, edit the table, not skill prose.\n     - A finding is **Critical** when it matches any rule in the table's `critical.any_of` AND satisfies `critical.guard` (a concrete merge-blocking risk from the committed branch diff).\n       - Treat a specialist Critical label as a candidate, not final severity. Re-check `blocking`, `impact_scope`, `verified_assumptions`, and `unverified_assumptions`; do not keep Critical when the blocker depends on unverified assumptions.\n       - Downgrade local-only, ignored generated state, developer-workflow-only false-green, local-only performance, or advisory observability findings to Important or Suggestion unless the committed diff proves an authoritative gate or merge outcome will be wrong.\n     - A finding that did not qualify as Critical is **Important** when it matches any rule in `important.any_of` AND satisfies `important.guard`.\n     - Treat remaining advisory findings as Suggestions unless the specialist explicitly marks them as positive observations, per the table's `suggestion` rule.\n   - Do not promote nits, style preferences, speculative rewrites, or weakly grounded concerns into Critical or Important.\n   - If evidence is incomplete but the risk may be severe, keep the item with the missing verification stated explicitly instead of silently dropping it.\n   - Deduplicate findings that describe the same root cause while retaining all source-specialist names. From the remaining normalized Critical and Important findings, build the complete Stage 3 candidate list. Suggestions and positive observations are not verifier candidates.\n   - Give candidates deterministic IDs `f001`, `f002`, ... in this order: Critical before Important, then first source specialist's Stage 1 dispatch order, then that specialist's finding appearance order. Each candidate must contain all fields required by the finding-verifier contract. Record the complete expected candidate-ID set before Stage 2; do not change IDs or membership based on Stage 2 output.\n\n5. **Stage 2 — conditional `code-simplifier` pass**:\n   - If Stage 1 surfaced **no** Critical findings, record `expected_stage2 = {code-simplifier}`, then spawn `code-simplifier` with the same target description, `$BASE_REF`, `$BASE_COMMIT`, `$HEAD_REF`, changed-file list, `git status --short`, `git log --no-decorate \"$BASE_COMMIT..$HEAD_REF\"`, diff packet path, byte count, SHA-256, Scope contract, Coverage sentinel contract, review-only contract, and control-plane contract, plus a brief Stage 1 summary so it knows what's already flagged. Request advisory simplification findings only.\n   - Use the selected adapter without switching families and keep Stage 2 at one active specialist. The V1 adapter uses the returned `agent_id`, targeted waits, and `close_agent`. The V2 adapter uses the same `run_token`, a stage-2\u002Fattempt task name, exact custom `agent_type`, `fork_turns=\"none\"`, saved canonical identity, spawn-error reconciliation, matched `FINAL_ANSWER` payload, accepted lifecycle evidence, ordered tree reconciliation, and run-owned `interrupt_agent` cleanup from Steps 2–3.\n   - Apply the same first-line `COVERAGE_OK ...` \u002F `FATAL_COVERAGE_ERROR ...` sentinel validation, packet SHA-256 validation, and fatal coverage error handling to Stage 2 output before final aggregation.\n   - Start one monotonic 10-minute Stage 2 deadline before its spawn. The V1 adapter uses the existing targeted-wait\u002Fclose loop. The V2 adapter applies the same canonical-identity state machine, completed-or-qualified-retirement lifecycle evidence, ordered reconciliation, duplicate handling, 60-second delivery grace, and poll bound of `min(60000 ms, remaining stage budget, earliest active delivery-grace budget)`; none may extend the Stage 2 deadline.\n   - If the scheduled specialist fails to spawn, errors, times out, returns empty output, or produces unusable output, perform the selected adapter's run-owned cleanup and fail closed before final aggregation. Partial aggregation is forbidden here too.\n   - Otherwise, skip Stage 2 — polishing code with Critical issues is wasted effort.\n\n6. **Stage 3 — verify normalized Critical\u002FImportant candidates**:\n   - Stage 3 is evidence verification, not another review. Use `finding-verifier` with exactly one candidate per task. It must not discover new findings, reclassify severity, edit files, execute changed code, or use collaboration tools. Stage 2 output never adds candidates and Stage 2 is not re-run after verification.\n   - If the recorded candidate set is empty, spawn nothing and record an empty verification summary. Otherwise dispatch every candidate through the selected adapter with exact custom `agent_type = \"finding-verifier\"`; omission and generic\u002Fdefault fallback are forbidden. Pass the single complete candidate, `references\u002Ffinding-verifier-contract.json`, `$BASE_REF`, `$BASE_COMMIT`, `$HEAD_REF`, changed-file list, git log, authoritative packet path, byte count, and SHA-256, plus the immutable-scope, read-only, and control-plane contracts. Do not pass unrelated findings.\n   - The V1 adapter keeps deterministic pending\u002Frunning\u002Fcompleted candidate maps keyed by candidate ID, runs at most 3 verifier tasks concurrently, accepts only the returned `agent_id`, and uses the same targeted-wait and close rules as Stage 1. The V2 adapter uses the same `run_token`, a maximum of 3 children, `fork_turns=\"none\"`, and exact task names `prr_\u003Crun_token>_s3_finding_verifier_\u003Ccandidate_id>_a\u003Cattempt>`. It applies the same canonical sender, spawn reconciliation, lifecycle, ordered reconciliation, delivery-grace, duplicate, deadline, and owned-cleanup rules as Stage 1.\n   - Start one monotonic 30-minute Stage 3 deadline before the first spawn. Neither progress nor retries reset it. For V2, each notification poll remains bounded by `min(60000 ms, remaining stage budget, earliest active delivery-grace budget)`.\n   - Require exactly one usable result for the exact expected candidate-ID set. Each result's first line must match `VERIFICATION_OK finding-verifier \u003Ccandidate_id> $BASE_COMMIT...$HEAD_REF \u003Cpacket_sha256>`, followed by a single JSON object matching the contract. Every evidence item must contain exactly a non-empty repository-relative `path`, a positive integer or positive line-range `line`, and a non-empty `observation`; reject absolute\u002Ftraversal\u002Fcontrol-character paths, placeholder values, zero\u002Fnegative lines, and extra fields. `FATAL_VERIFICATION_ERROR`, unknown\u002Fduplicate\u002Fmissing candidate IDs, scope\u002Fhash mismatch, malformed JSON, invalid fields, invalid verdict shape, task failure, timeout, or partial delivery fails closed before aggregation.\n   - Before applying any verdict, serialize each parsed result JSON object to a dedicated temp file outside the worktree using a quoted heredoc delimiter, then run the bundled `scripts\u002Fvalidate_finding_evidence.py` with the repository root, exact recorded `$HEAD_REF`, and result-file path. The validator resolves each path as a literal entry in the immutable `$HEAD_REF` Git tree, accepts only regular text blobs, and requires the cited line or inclusive range to fit within that blob's logical line count. Require exit 0 and exact stdout `EVIDENCE_OK finding-verifier \u003Ccandidate_id> $HEAD_REF \u003Cevidence_count>`. A missing script, write or execution failure, nonzero exit, unexpected stdout, absent\u002Fnon-file\u002Fbinary path, out-of-bounds line, or evidence-count mismatch is fatal before verdict application. Never validate against the current worktree and never interpolate an evidence path into a shell command.\n   - Apply verdicts without changing finding identity: `confirmed` retains the normalized severity; `refuted` removes the candidate from the fix queue but keeps it visible under Refuted Findings; `needs-verification` requires non-empty `missingVerification`, downgrades Critical to Important, and retains Important as Important. `confirmed` and `refuted` require non-empty evidence and empty `missingVerification`. Any other combination is invalid and fails closed.\n\n7. **Final worktree guard**:\n   - Run `git status --porcelain --untracked-files=normal` again after all specialists complete and before aggregation, or before the empty-diff early exit.\n   - If the command fails, abort with the command output and do not aggregate against an unknown worktree state.\n   - If output is non-empty, abort with:\n     > \"Review subagents or concurrent tooling changed the worktree: \\\u003Clist\\>. These changes were not part of the reviewed committed diff. Revert, commit, or stash them, then retry.\"\n   - Run `git rev-parse HEAD` again and compare it with the recorded `$HEAD_REF`. If it differs, abort with:\n     > \"HEAD changed during review: started at `\u003Cold>`, now `\u003Cnew>`. The completed specialist results do not cover the current commit. Re-run the review.\"\n\n8. **Aggregate** all retained specialist findings into the Output Format below. Preserve the originating specialist name and candidate ID in each verified Critical\u002FImportant bullet so the reader can trace lineage. Include every refuted candidate and its verifier summary under Refuted Findings; refuted items do not count toward Critical or Important totals. Always include the stop condition in Recommended Action: `Critical 0 \u002F Important 0` means stop; Suggestions alone do not justify another gate run. On the second and later pass, focus on prior Critical\u002FImportant resolution. On the third and later pass, if Critical\u002FImportant findings keep appearing or changing without stable blocker evidence, call out possible review churn and return the decision to a human maintainer.\n\n## Output format\n\n```markdown\n# PR Review: \u003Cbranch> vs \u003Cbase>\n\n\u003Cdegraded-coverage line if applicable>\n\n## Verification Summary\n- Confirmed: X; Needs verification: Y; Refuted: Z\n\n## Critical Issues (X found)\n- [\u003Ccandidate-id> \u002F \u003Cspecialist>]: \u003Cdescription> [\u003Cfile>:\u003Cline>]\n  - Impact scope: ...\n  - Verified assumptions: ...\n  - Unverified assumptions: ...\n  - Why it matters: ...\n  - Suggested fix: ...\n\n## Important Issues (X shown, top 5)\n- [\u003Ccandidate-id> \u002F \u003Cspecialist>]: \u003Cdescription> [\u003Cfile>:\u003Cline>]\n  - Impact scope: ...\n  - Missing verification: \u003Cif any>\n\n## Suggestions (X shown, max 3)\n- [\u003Cspecialist>]: \u003Cdescription> [\u003Cfile>:\u003Cline>]\n\n## Refuted Findings\n- [\u003Ccandidate-id> \u002F \u003Cspecialist>]: \u003Coriginal description>\n  - Verifier summary: ...\n\n## Strengths\n- \u003Cpositive observations from specialists>\n\n## Recommended Action\n1. Fix Critical issues first\n2. Address Important issues\n3. Consider Suggestions\n4. Re-run review after fixes to verify prior Critical\u002FImportant findings\n5. Stop when Critical 0 \u002F Important 0; do not re-run for Suggestions only\n6. If this is the third or later pass and Critical\u002FImportant findings still churn, escalate to human judgment\n```\n\n## See also\n\n- Design Doc: `docs\u002Fdesign\u002Fcodex-pr-review.md` (dotfiles repo)\n- ADR 0020: clean-worktree invariant (Precondition 1 origin)\n- Issue #186: scope-alignment fix (Precondition 2 origin)\n- ADR 0023 (planned): final decision record\n","# pr-review\n\n## Goal\n\nRun a comprehensive specialist review of the current branch's changes against its base, then synthesize findings into a single actionable report.\n\n## Review Criteria\n\nUse the bundled `references\u002Freview-criteria.md` as the source of truth for severity normalization, output budgeting, and re-review behavior. The short global `AGENTS.md` \u002F `CLAUDE.md` policy explains when to choose built-in review versus heavy gates; this skill file and its bundled reference define how `$pr-review` gates a change once invoked.\n\nApply these high-level constraints throughout the Procedure:\n- Optimize for merge decisions, not finding count.\n- Do not put nits, style preferences, speculative rewrites, or weakly grounded concerns into the fix queue.\n- Important findings are capped at 5 in the final aggregation; Suggestions are capped at 3.\n- If evidence is incomplete but the risk may be severe, state the missing verification explicitly instead of silently dropping the finding.\n- Re-review verifies prior Critical\u002FImportant findings and should not extend the loop with new nits, style feedback, or optional refactors.\n- Critical findings require `blocking: yes`, `impact_scope`, `verified_assumptions`, and no `unverified_assumptions` needed for the blocker claim.\n- Post-verification `needs-verification` with non-empty `missingVerification` downgrades a Critical candidate to Important; it remains visible, but not as a proven blocker. Other verdicts carrying `missingVerification`, or `needs-verification` without it, are invalid verifier outputs and must fail closed.\n- Stop the review loop when Critical and Important are both 0; do not re-run only for Suggestions.\n\n## Preconditions\n\n**Environment note**: this skill must be invoked from a terminal directly (`codex exec ...`), not from within an enclosing Claude Code session. The nested-bwrap permission failure documented in `~\u002F.codex\u002Fhistory.jsonl` (2026-03) makes nested invocation infinite-spawn-retry. The skill cannot reliably self-detect this; the caller takes responsibility.\n\nRun these checks in order. If any fails, abort with the indicated actionable error and do not proceed to the Procedure section.\n\n0. **V1\u002FV2 runtime contract** — Before running any shell or Git command and before invoking any collaboration tool, inspect the tool definitions exposed to this session. Runtime contract sentinel: `PR_REVIEW_RUNTIME_CONTRACT_V1_V2`.\n   - If collaboration tools are deferred, use the runtime's tool-discovery mechanism to resolve and inspect their definitions. Tool discovery is allowed here; a probe spawn is not. Do not infer the contract from feature flags, model name, tool namespace, profile name, or a prior session.\n   - Admit exactly one coherent family and record the selected adapter for the entire run:\n     - **The V1 adapter** requires `spawn_agent(agent_type,message)` with both arguments required and an `agent_id` in the successful result, targeted `wait_agent(targets)`, and `close_agent(agent_id)`. Its `spawn_agent` must not accept `task_name` or `fork_turns`.\n     - **The V2 adapter** requires `spawn_agent(task_name,message,agent_type?,fork_turns?,model?,reasoning_effort?)` with `task_name` and `message` required, untargeted `wait_agent(timeout_ms?)`, `list_agents(path_prefix?)`, and `interrupt_agent(target)`. Its `wait_agent` must not accept `targets`; `close_agent` must not be part of this family. `send_message(target,message)` and `followup_task(target,message)` may also be present and do not make the schema mixed, but the orchestrator must not use them for review-result transport or synchronization, and specialists must not use them under the control-plane ban. Although `agent_type`, `fork_turns`, `model`, and `reasoning_effort` are optional in the tool schema, every pr-review specialist spawn must set the exact `agent_type` and explicitly set `fork_turns` to `\"none\"`; omit `model` and `reasoning_effort` to inherit the parent.\n   - Optional unrelated, non-discriminating fields may be present in either family and do not by themselves make it mixed. Admission is determined by the required and forbidden control fields above; any added field that conflicts with those discriminators, or changes result identity or wait\u002Fcleanup semantics, is unknown and incompatible.\n   - Missing, unresolved, incomplete, mixed, or unknown definitions are not compatible. Do not combine tools from different families or use a generic\u002Fdefault agent fallback.\n   - If no coherent adapter can be selected, abort before repository inspection with this exact message:\n\n     ```text\n     ERROR: $pr-review requires one coherent Codex multi-agent V1 or V2 schema, but this session exposes missing, mixed, incomplete, or unknown collaboration tools.\n\n     No specialist was spawned and no review was performed. Tool exposure is fixed for the lifetime of this session.\n\n     Start a new Codex process from the repository under review:\n\n       codex exec --profile review -C '\u003Crepo-root>' '$pr-review --base \u003Csame-base>'\n\n     If the review-profile command still does not expose one exact supported schema, stop and report compatibility drift. Do not fall back to default agents.\n     ```\n\n   - For both adapters, before repository inspection read `references\u002Fbase-resolution-runtime-contract.json`, require sentinel `PR_REVIEW_BASE_RESOLUTION_CONTRACT_V2`, and use its operation allowlist, classification precedence, retry limit, invocation-fingerprint, immutable-OID values, and `allow_no_pr` transition sequence as the machine-readable base-resolution contract. Record whether the shell tool exposes `sandbox_permissions=require_escalated`; absence does not invalidate the immutable-OID path, but any later sandbox-denied operation that needs escalation must fail closed before specialist spawn. Abort before repository inspection if the contract is missing, malformed, unsupported, or conflicts with this prose.\n   - For both adapters, before repository inspection read `references\u002Ffinding-verifier-contract.json`, require sentinel `PR_REVIEW_FINDING_VERIFIER_CONTRACT_V1`, and use its candidate, task, scope, output, verdict, and integrity values as the machine-readable finding-verifier contract. Abort before repository inspection if the contract is missing, malformed, unsupported, or conflicts with this prose.\n   - For V2 only, call `list_agents` immediately after selection and require a **fresh agent tree**: the current orchestrator entry may exist, but it must have no descendant. Abort before repository inspection if listing fails, a descendant already exists, or the current tree cannot be identified unambiguously. This prevents this run from adopting, interrupting, or confusing another run's tasks.\n   - For V2 only, before repository inspection read `references\u002Fv2-runtime-contract.json`, require sentinel `PR_REVIEW_V2_SCHEDULER_CONTRACT_V4`, and use its timing, spawn, result, reconciliation, cleanup, and aggregation values as the machine-readable scheduler contract. Abort before repository inspection if the file is missing, malformed, unsupported, or conflicts with this prose.\n\n1. **Clean worktree** — Run `git status --porcelain --untracked-files=normal`. If the command fails, abort with the command output and do not review an unknown worktree state. If output is non-empty (uncommitted tracked changes or untracked-non-ignored files), abort with:\n   > \"Worktree has uncommitted changes: \\\u003Clist\\>. The review covers committed branch diff only; uncommitted changes would be silently excluded. To inspect staged, unstaged, and untracked changes first, run `codex review --uncommitted`. Commit or stash all listed changes, then retry `$pr-review`. (See ADR 0020.)\"\n\n2. **Base ref resolution** — Determine `$BASE` from one of three sources, in priority order. For the allowlisted `gh pr view`, `git fetch`, and `git remote set-head origin --auto` operations below, always try the ordinary sandbox first. Retry only a sandbox\u002Ftransport denial (`socket: operation not permitted`, a sandbox-caused DNS\u002Fconnect denial, blocked TLS\u002Fservice access, or EROFS\u002FEACCES on required `.git` metadata) by reissuing the exact original executable, argv, cwd, and ordinary environment once with `sandbox_permissions=require_escalated`. Never request a persistent prefix approval. Approval metadata and the sandbox field are the only permitted fingerprint differences. Do not elevate an ordinary Git ref\u002Fremote\u002FSSH-auth error, a GitHub API error, or an ambiguous failure. If escalation is unavailable, denied, or fails, abort before specialist spawn and recommend an immutable base OID.\n   - (a) If the user prompt provides an explicit base (for example, `--base develop` or \"review against develop\"), use that verbatim and skip all `gh` checks below. If the explicit base is an immutable commit\u002FOID, set `$BASE_REF` to that value and do not run `gh`, fetch, or any elevated command. Otherwise treat it as an origin branch name only after it passes `git check-ref-format --branch \"$BASE\"` and does not start with `-` or `+`, contain `:`, or contain another refspec\u002Fcontrol separator; reject anything else before running `git fetch`. For a valid branch name, run `git fetch --quiet origin \"refs\u002Fheads\u002F$BASE\"` through the scoped retry policy before validation, abort if it still fails, set `$BASE_REF=FETCH_HEAD`, and resolve `$BASE_COMMIT` immediately before any later fetch can overwrite `FETCH_HEAD`. Do not pass `$BASE` as a raw refspec. Do not proceed from existing local refs alone. If the caller needs offline execution, pass an immutable base commit.\n   - (b) If the user prompt includes `--allow-no-pr` or `$ALLOW_NO_PR` is set to `1` \u002F `true`, skip `gh` entirely. Run `git fetch --quiet origin` through the scoped retry policy; if it still fails, abort instead of reviewing a possibly stale default branch. Run `git remote set-head origin --auto` through the same policy; if it still fails, abort instead of trusting a stale local `origin\u002FHEAD` symref. Run `git symbolic-ref --quiet --short refs\u002Fremotes\u002Forigin\u002FHEAD`; if it fails or returns an empty value, abort instead of guessing a base. Strip the leading `origin\u002F` from the captured value, use the result as `$BASE`, use the full captured `origin\u002F\u003Cbranch>` ref as `$BASE_REF`, and add a `**Degraded coverage**: no PR base, fell back to default branch` line to the Output.\n   - (c) Otherwise use the required PR lookup itself as the only GitHub auth\u002Fnetwork probe; do not run the origin-unscoped `gh auth status`:\n     - Run `gh pr view --json baseRefName,baseRefOid --jq '[.baseRefName,.baseRefOid] | @tsv'` in the ordinary sandbox.\n     - If it fails with the explicit \"no pull request found for the current branch\" result, treat only that as the no-PR case. Otherwise run the same operation once in the ordinary sandbox with only `GH_DEBUG=api` added as a discriminator.\n     - Give a proven sandbox\u002Ftransport denial precedence over credential-looking text. On such a denial, retry the original non-debug `gh pr view` invocation once with `sandbox_permissions=require_escalated`. If the discriminator or elevated attempt reaches GitHub and proves HTTP 401 \u002F bad credentials, abort with:\n       > \"Stale `gh` auth detected. Run `gh auth login` and retry — the skill cannot resolve PR base ref without authenticated gh.\"\n     - If the discriminator remains ambiguous, escalation is unavailable\u002Fdenied, or the elevated command fails for any other reason, abort with a sanitized classification and the immutable-OID escape hatch. Do not persist or reproduce raw debug headers, responses, credential text, or tokens.\n     - If the successful authoritative result contains exactly two non-empty tab-separated fields (branch name and base commit OID), use the branch name as `$BASE`. Validate it with the same explicit-branch safety rules (`git check-ref-format --branch \"$BASE\"`, no leading `-` \u002F `+`, no `:` or other refspec\u002Fcontrol separator). Then run `git fetch --quiet origin \"refs\u002Fheads\u002F$BASE\"` through the scoped retry policy. Resolve `FETCH_HEAD^{commit}` and verify it exactly equals the returned `baseRefOid`; if it differs, abort with both OIDs. Set `$BASE_REF=FETCH_HEAD` only after that verification.\n     - If a successful result does not contain exactly two non-empty tab-separated fields, abort with sanitized output and do not infer a base from malformed data. Never fall back to `origin\u002FHEAD` after an unexpected `gh pr view` failure.\n\n   If none of (a)–(c) yields a base, abort with:\n   > \"No PR found for the current branch and no explicit base provided. By default the skill requires an open PR (Issue #186 fix) so all specialists share the same base ref. Either create a draft PR first, provide an explicit base in your prompt, or pass `--allow-no-pr` \u002F set `ALLOW_NO_PR=1` to fall back to the default branch (residual scope-divergence risk acknowledged).\"\n\n   Sandbox compatibility by base path:\n   - Explicit immutable commit\u002FOID bases do not require network access or `.git` metadata writes after the initial clean-worktree check; this is the only supported offline\u002Fread-only invocation path.\n   - Explicit branch-name bases require network access and `git fetch` writing `FETCH_HEAD`; sandbox denial may use the bounded scoped retry above.\n   - `--allow-no-pr` requires network access, `git fetch`, and `git remote set-head origin --auto`; sandbox denial may use the same bounded scoped retry.\n   - Auto-PR base resolution requires `gh pr view`, network access, and a verified fetch of the reported base branch; sandbox denial may use the bounded scoped retry, but offline runs remain unsupported.\n   - If callers need offline\u002Fread-only review, they must supply an immutable base commit OID.\n\n3. **Base ref validation** — Pin the already resolved `$BASE_REF` to an immutable commit before collecting any diff:\n   - If `gh pr view` returned `baseRefOid`, keep `$BASE_REF=FETCH_HEAD` after the verified fetch\u002FOID comparison; do not resolve the OID against a possibly stale local object database without fetching the PR base branch first.\n   - If an explicit branch base was fetched, keep `$BASE_REF=FETCH_HEAD`; do not replace it with a local branch or local remote-tracking ref.\n   - If `--allow-no-pr` selected the default branch, keep `$BASE_REF` as the fetched `origin\u002F\u003Cbranch>` ref.\n   - Otherwise use the explicit immutable base as `$BASE_REF`.\n   - Run `BASE_COMMIT=$(git rev-parse --verify \"$BASE_REF^{commit}\")` immediately after assigning `$BASE_REF` and record the exact output for all later collection and specialist prompts. If it fails, abort with:\n     > \"Base ref `\u003Cbase>` does not resolve to a commit. Check the base name or fetch the ref, then retry.\"\n\n## Procedure\n\nAfter preconditions pass:\n\n1. **Collect the review inputs and classify the diff**:\n   - Run `git rev-parse HEAD` as an independent, preceding tool call and wait for it to complete before starting any other collection. Do not put HEAD recording in the same parallel tool call as status, log, file-list, or diff collection.\n   - Require that call to succeed and record its commit OID as immutable `$HEAD_REF`. If HEAD recording fails or does not return a commit OID, abort without starting collection.\n   - After recording `$HEAD_REF`, use that immutable OID for every later log, file-list, and diff command. Do not use symbolic `HEAD` for those commands.\n   - Run `git status --short`, `git log --no-decorate \"$BASE_COMMIT..$HEAD_REF\"`, `git diff --name-only \"$BASE_COMMIT\"...\"$HEAD_REF\"`, and `git diff \"$BASE_COMMIT\"...\"$HEAD_REF\"`.\n   - Require every command to exit successfully. If any collection command fails, abort loudly instead of reviewing partial input.\n   - If the diff is genuinely empty, run the Final worktree guard immediately, then say `No committed changes relative to \u003Cbase>; nothing to review.` and stop rather than emitting a normal green review. Do not skip the final worktree or HEAD checks on the empty-diff path.\n   - Always write the exact full diff to a temp file, compute its byte count and SHA-256, and include the path, byte count, and SHA-256 in the specialist prompt. Use a BSD\u002FGNU-compatible suffix-free `mktemp` template with the random `X`s at the end, such as `diff_packet=$(mktemp \"${TMPDIR:-\u002Ftmp}\u002Fpr-review-diff.XXXXXX\")`; do not use a suffixed template such as `pr-review-diff.XXXXXX.diff`, which can collide on BSD `mktemp`. Abort if `mktemp`, diff writing, byte counting, or hashing fails. The diff packet is authoritative; any inline diff text is only a convenience excerpt. If a specialist cannot read the referenced packet or the packet hash does not match, it must return a fatal coverage error.\n   - Use `git diff --name-only` only for path-based categories:\n     - `test_paths`: path components or basenames that are tests, such as `tests\u002F`, `test\u002F`, `__tests__\u002F`, `*.test.*`, `*.spec.*`, `*_test.go`, `*_spec.rb`, `*.bats`, or basenames beginning with `test_`; do not classify ordinary runtime files as tests merely because they contain `test` in a role name such as `pr-test-analyzer`\n     - `operational_paths`: review\u002Fruntime assets such as `private_dot_codex\u002Fskills\u002F**\u002FSKILL.md`, `private_dot_codex\u002Fagents\u002F*.toml`, `.github\u002Fworkflows\u002F**`, `.claude\u002Fhooks\u002F**`, `.chezmoiscripts\u002F**`, `dot_local\u002Fbin\u002F**`, and managed shell\u002Fconfig files whose content affects tool behavior\n     - `docs_paths`: passive prose docs such as `docs\u002F`, `*.md`, or `README*`, excluding any path already classified as `operational_paths`\n     - `code_paths`: changed paths that are not passive docs-only assets, plus all `operational_paths`\n   - Inspect the full diff hunks for content-based categories:\n     - `comment_changes`: any added or removed comment line in source files, including mixed code+comment hunks\n     - `docs_or_comments`: `docs_paths` non-empty or `comment_changes` non-empty\n     - `type_changes`: hunks introducing `class` \u002F `interface` \u002F `type` \u002F `struct` \u002F `enum` \u002F `trait` \u002F `dataclass` \u002F schema definitions, plus hunks modifying lines inside an existing type or schema definition block\n\n   When in doubt, include the specialist (over-coverage is cheaper than missed findings).\n\n2. **Build the Stage 1 specialist set and spawn it in parallel** via `spawn_agent`.\n   - Every specialist spawn **must** select the exact custom role with `agent_type = \"\u003Cspecialist-name>\"`; omission and generic\u002Fdefault role fallback are forbidden in either adapter.\n   - Do not set `model` or `reasoning_effort` unless intentionally overriding the parent's selection; those inherit from the parent when omitted.\n   - Record the complete `expected_stage1` set before spawning so completeness can be checked before aggregation. It contains the three always-on roles plus up to four conditional roles, for a maximum of 7.\n   - Pass each spawn the following structured prompt:\n     - Target description: `Pre-PR review of branch \u003Ccurrent> against \u003C$BASE>`\n     - The resolved `$BASE_REF`\n     - The recorded `$BASE_COMMIT`\n     - The recorded `$HEAD_REF`\n     - The list of changed files (categorized)\n     - `git status --short`\n     - `git log --no-decorate \"$BASE_COMMIT..$HEAD_REF\"`\n     - The diff packet path, byte count, and SHA-256 (always supplied)\n     - Optional inline excerpt from `git diff \"$BASE_COMMIT\"...\"$HEAD_REF\"`; the packet remains authoritative if output is truncated\n     - Scope contract: review only the orchestrator-provided `$BASE_COMMIT...$HEAD_REF` committed branch diff. Do not substitute unqualified `git diff`, unstaged changes, a PR re-detection, a different base commit, a different HEAD, or another inferred scope. If the diff, file list, base commit, HEAD ref, or packet hash is missing or inconsistent, return a fatal coverage error.\n     - Coverage sentinel contract: the first output line must be either `COVERAGE_OK \u003Cspecialist> $BASE_COMMIT...$HEAD_REF \u003Cpacket_sha256>` or `FATAL_COVERAGE_ERROR \u003Cspecialist>: \u003Creason>`. Missing, malformed, or non-first-line sentinels are unusable output.\n     - Review-only contract: do not edit files, create files, apply patches, run formatters that write files, or otherwise dirty the worktree. Return markdown findings or suggestions only.\n     - Control-plane contract: `Do not call any collaboration\u002Fsubagent tools; return only your final review response.`\n     - Finding quality contract: every finding must include `blocking: yes\u002Fno`, `impact_scope`, `verified_assumptions`, and `unverified_assumptions`. Use `blocking: yes` only for clear merge blockers in the committed diff. Machine-local or ignored state, local-only performance regressions, developer-workflow-only false-greens, advisory observability gaps, and assumption-dependent risks should be `blocking: no` unless the committed diff proves a wider blocker.\n\n   Always spawn:\n   - `code-reviewer`\n   - `security-reviewer`\n   - `adversarial-reviewer`\n\n   Conditionally spawn (based on categorization):\n   - `pr-test-analyzer` — if `code_paths` is non-empty, especially when `test_paths` is empty\n   - `comment-analyzer` — only if `docs_or_comments` non-empty\n   - `silent-failure-hunter` — if `code_paths` is non-empty (the hunter suppresses noise internally; default-on avoids heuristic false negatives such as shell `|| true`)\n   - `type-design-analyzer` — only if `type_changes` non-empty\n\n   Dispatch the recorded set through the selected adapter:\n   - **The V1 adapter** keeps `pending_stage1` in deterministic order, `running_stage1` keyed by returned `agent_id`, and `completed_stage1` keyed by role. Run at most 6 Stage 1 agents concurrently. When one yields a final usable result, record it, call `close_agent` for that ID, and fill the freed slot. Never omit a scheduled role because of capacity.\n   - **The V2 adapter** derives a lowercase alphanumeric `run_token` from the random suffix of the already-created diff-packet `mktemp` path; reject an empty or unsafe token. Name each task `prr_\u003Crun_token>_s\u003Cstage>_\u003Crole-with-hyphens-replaced-by-underscores>_a\u003Cattempt>`, and verify before spawning that the name is absent. Every spawn must set `fork_turns=\"none\"`. Keep deterministic pending, running, and usable maps and run a **maximum of 3** children concurrently.\n     - Save the exact canonical task path returned by each successful spawn; the local task name alone is never an identity. Before each spawn and after each wait notification, use `list_agents` to verify every non-usable canonical task and the tree shape.\n     - If `spawn_agent` reports an error, immediately list status. If exactly the requested new name now exists and it did not exist before the call, adopt its canonical path and track it. If it is absent and the result is an **explicit capacity error**, retry once, only after a slot is available, with a new `attempt` name. A pre-existing name, more than one match, an absent task after any other\u002Fambiguous error, or failure of the single retry is fatal. Never retry the same name.\n     - After each notification, run one ordered reconciliation cycle: harvest and validate **all** newly delivered run-owned finals; call `list_agents` for one successful full-tree snapshot; harvest every envelope delivered at that tool boundary; evaluate all tracked tasks and descendants; then refill only if no fatal evidence exists. Never refill between those steps. Fill every freed slot immediately after its child becomes usable under Step 3, even while two other children remain running; do not wait for the current batch to finish. A scheduled role that cannot be spawned after a usable child frees capacity makes the stage fail closed.\n\n3. **Await all Stage 1 specialists** before proceeding.\n   - Start one monotonic 30-minute Stage 1 deadline before the first spawn. Neither progress, an interim message, a retry, nor a wait call resets it.\n   - **The V1 adapter** treats targeted `wait_agent` as polling, not a barrier: keep the remaining `agent_id` set, call `wait_agent` with those IDs and `timeout_ms = min(600000, remaining stage budget)`, record only final usable results, close completed IDs, fill capacity, and repeat until all expected roles are complete.\n   - **The V2 adapter** follows this state machine for each canonical task:\n\n     | State | Evidence | Next action |\n     | --- | --- | --- |\n     | running | canonical path has running status | wait or inspect a delivered envelope |\n     | final-seen | one matched `FINAL_ANSWER` payload, no accepted lifecycle evidence | retain the payload and reconcile status |\n     | completed-seen | completed status, no final payload | allow a **60-second delivery grace**, bounded by the stage deadline |\n     | retired-seen | task is absent from a successful full-tree snapshot after either observed-running evidence or a valid matching final | allow the same bounded delivery grace when the final is still pending |\n     | usable | valid final payload plus completed status or qualified retirement | retain evidence and fill capacity |\n     | fatal | error\u002Finterrupted status, disappearance without observed-running or a valid matching final, parent-interrupted retirement, invalid evidence, or expired deadline\u002Fgrace | clean up and abort |\n\n     - `wait_agent is notification-only`; never treat its return as a task result or barrier. `list_agents is status-only`; never extract review text from it. The only authoritative review body is the `Payload` of a delivered envelope whose `Message Type` is `FINAL_ANSWER` and whose `Sender` exactly equals a saved canonical task path. The envelope's `Task name` identifies the recipient (normally `\u002Froot`), not the child, and must never be used as sender identity.\n     - Ignore interim `MESSAGE` envelopes and do not reset any deadline. Validate a matching final immediately: an empty body, malformed\u002Fmissing first-line sentinel, `FATAL_COVERAGE_ERROR`, role\u002Fscope\u002Fhash mismatch, or stated inability to verify the packet is fatal before refill. Record the first valid matching final payload byte-for-byte. Ignore an identical duplicate `FINAL_ANSWER`; a **conflicting duplicate** for the same canonical task is fatal. A final payload from an unknown or merely name-matched sender is not usable.\n     - Bound each notification poll to `min(60000 ms, remaining stage budget, earliest active delivery-grace budget)`, then run the ordered reconciliation cycle. Never make a blocking wait longer than 60 seconds. If the result is below the tool's 10000 ms minimum, do not issue a wait that would cross the budget; inspect already-delivered envelopes and current status, then fail when the applicable deadline expires if evidence is still incomplete.\n     - Treat `completed` as normal lifecycle evidence. As a V2 compatibility fallback, also accept **qualified retirement** when a successful full-tree snapshot omits the exact saved canonical task after either (a) that task was previously observed with `running` status or (b) a valid matching `FINAL_ANSWER` from that canonical sender was already recorded. The final-backed path is allowed only because the recognized V2 runtime delivers `FINAL_ANSWER` at child-turn completion. Both paths require that the parent has never called `interrupt_agent` on the task and that no run-global fatal evidence exists. A spawn result, a failed\u002Fincomplete list, mere name matching, or disappearance before both observed running and a valid matching final is not retirement evidence and is fatal. If the runtime's child-turn-completion semantics or schema is not established, fail closed instead of applying the fallback. Any descendant other than a saved, tracked top-level specialist is an **unexpected descendant** and is fatal.\n     - If completed status or qualified retirement arrives first, start one per-task grace at that earliest lifecycle-evidence timestamp. The valid final must arrive strictly before `grace_start + 60000 ms` and before the stage deadline; equality or later is fatal. If the final payload arrives first, keep reconciling until completed status, qualified retirement, or the stage deadline. Later evidence never resets grace.\n     - Retain the first valid payload, lifecycle evidence, and canonical identity even after a task becomes usable and until stage aggregation. Continue validating later run-owned envelopes and statuses: ignore a byte-identical duplicate final, but make a conflicting duplicate, later observed error\u002Finterrupted status, or any other fatal evidence abort the stage. Run one final ordered reconciliation cycle before aggregation.\n   - Fail closed before aggregation if any expected specialist fails to spawn, errors, times out, returns empty output, or produces unusable output. On any abnormal exit after a spawn, stop dispatching pending roles; cleanup start is monotonic fatal and a later final cannot restore usability. The V1 adapter closes every remaining running V1 ID. The V2 adapter performs one final notification\u002Fstatus drain without extending the applicable deadline, then calls `interrupt_agent` only on a still-running run-owned top-level task or a still-running unexpected descendant beneath one of its saved canonical paths. Never interrupt the orchestrator or an unrelated path. Finally list status again and require that no run-owned task or owned descendant remains running; if cleanup cannot be confirmed, report cleanup failure together with the original fatal reason. Do not aggregate any partial result during cleanup.\n   - Fail closed before Stage 2 or aggregation if any specialist output is missing a first-line `COVERAGE_OK ...` or `FATAL_COVERAGE_ERROR ...` sentinel, or if the `COVERAGE_OK` sentinel does not match the expected specialist name, `$BASE_COMMIT...$HEAD_REF` scope, and packet SHA-256.\n   - Fail closed before Stage 2 or aggregation if any specialist output reports a fatal coverage error, missing\u002Finconsistent scope, inability to read the diff packet, packet hash mismatch, or otherwise says it was unable to verify the packet or reviewed scope.\n   - **Partial aggregation is forbidden**: every required role must be usable and pass coverage validation. If a future workflow wants partial results, require an explicit opt-in plus a visible degraded-coverage banner.\n   - Each successful specialist returns the coverage sentinel followed by markdown findings.\n\n4. **Scan Stage 1 output and normalize severity before Stage 2**:\n   - Apply `references\u002Freview-criteria.md` before trusting specialist labels. Specialist labels are useful signals, but final severity must still satisfy the bundled criteria.\n   - Read `references\u002Fseverity-rules.json` and classify each finding with its escalation table. The table is shared verbatim with the Claude-side `\u002Fpr-review` skill; when the escalation rules change, edit the table, not skill prose.\n     - A finding is **Critical** when it matches any rule in the table's `critical.any_of` AND satisfies `critical.guard` (a concrete merge-blocking risk from the committed branch diff).\n       - Treat a specialist Critical label as a candidate, not final severity. Re-check `blocking`, `impact_scope`, `verified_assumptions`, and `unverified_assumptions`; do not keep Critical when the blocker depends on unverified assumptions.\n       - Downgrade local-only, ignored generated state, developer-workflow-only false-green, local-only performance, or advisory observability findings to Important or Suggestion unless the committed diff proves an authoritative gate or merge outcome will be wrong.\n     - A finding that did not qualify as Critical is **Important** when it matches any rule in `important.any_of` AND satisfies `important.guard`.\n     - Treat remaining advisory findings as Suggestions unless the specialist explicitly marks them as positive observations, per the table's `suggestion` rule.\n   - Do not promote nits, style preferences, speculative rewrites, or weakly grounded concerns into Critical or Important.\n   - If evidence is incomplete but the risk may be severe, keep the item with the missing verification stated explicitly instead of silently dropping it.\n   - Deduplicate findings that describe the same root cause while retaining all source-specialist names. From the remaining normalized Critical and Important findings, build the complete Stage 3 candidate list. Suggestions and positive observations are not verifier candidates.\n   - Give candidates deterministic IDs `f001`, `f002`, ... in this order: Critical before Important, then first source specialist's Stage 1 dispatch order, then that specialist's finding appearance order. Each candidate must contain all fields required by the finding-verifier contract. Record the complete expected candidate-ID set before Stage 2; do not change IDs or membership based on Stage 2 output.\n\n5. **Stage 2 — conditional `code-simplifier` pass**:\n   - If Stage 1 surfaced **no** Critical findings, record `expected_stage2 = {code-simplifier}`, then spawn `code-simplifier` with the same target description, `$BASE_REF`, `$BASE_COMMIT`, `$HEAD_REF`, changed-file list, `git status --short`, `git log --no-decorate \"$BASE_COMMIT..$HEAD_REF\"`, diff packet path, byte count, SHA-256, Scope contract, Coverage sentinel contract, review-only contract, and control-plane contract, plus a brief Stage 1 summary so it knows what's already flagged. Request advisory simplification findings only.\n   - Use the selected adapter without switching families and keep Stage 2 at one active specialist. The V1 adapter uses the returned `agent_id`, targeted waits, and `close_agent`. The V2 adapter uses the same `run_token`, a stage-2\u002Fattempt task name, exact custom `agent_type`, `fork_turns=\"none\"`, saved canonical identity, spawn-error reconciliation, matched `FINAL_ANSWER` payload, accepted lifecycle evidence, ordered tree reconciliation, and run-owned `interrupt_agent` cleanup from Steps 2–3.\n   - Apply the same first-line `COVERAGE_OK ...` \u002F `FATAL_COVERAGE_ERROR ...` sentinel validation, packet SHA-256 validation, and fatal coverage error handling to Stage 2 output before final aggregation.\n   - Start one monotonic 10-minute Stage 2 deadline before its spawn. The V1 adapter uses the existing targeted-wait\u002Fclose loop. The V2 adapter applies the same canonical-identity state machine, completed-or-qualified-retirement lifecycle evidence, ordered reconciliation, duplicate handling, 60-second delivery grace, and poll bound of `min(60000 ms, remaining stage budget, earliest active delivery-grace budget)`; none may extend the Stage 2 deadline.\n   - If the scheduled specialist fails to spawn, errors, times out, returns empty output, or produces unusable output, perform the selected adapter's run-owned cleanup and fail closed before final aggregation. Partial aggregation is forbidden here too.\n   - Otherwise, skip Stage 2 — polishing code with Critical issues is wasted effort.\n\n6. **Stage 3 — verify normalized Critical\u002FImportant candidates**:\n   - Stage 3 is evidence verification, not another review. Use `finding-verifier` with exactly one candidate per task. It must not discover new findings, reclassify severity, edit files, execute changed code, or use collaboration tools. Stage 2 output never adds candidates and Stage 2 is not re-run after verification.\n   - If the recorded candidate set is empty, spawn nothing and record an empty verification summary. Otherwise dispatch every candidate through the selected adapter with exact custom `agent_type = \"finding-verifier\"`; omission and generic\u002Fdefault fallback are forbidden. Pass the single complete candidate, `references\u002Ffinding-verifier-contract.json`, `$BASE_REF`, `$BASE_COMMIT`, `$HEAD_REF`, changed-file list, git log, authoritative packet path, byte count, and SHA-256, plus the immutable-scope, read-only, and control-plane contracts. Do not pass unrelated findings.\n   - The V1 adapter keeps deterministic pending\u002Frunning\u002Fcompleted candidate maps keyed by candidate ID, runs at most 3 verifier tasks concurrently, accepts only the returned `agent_id`, and uses the same targeted-wait and close rules as Stage 1. The V2 adapter uses the same `run_token`, a maximum of 3 children, `fork_turns=\"none\"`, and exact task names `prr_\u003Crun_token>_s3_finding_verifier_\u003Ccandidate_id>_a\u003Cattempt>`. It applies the same canonical sender, spawn reconciliation, lifecycle, ordered reconciliation, delivery-grace, duplicate, deadline, and owned-cleanup rules as Stage 1.\n   - Start one monotonic 30-minute Stage 3 deadline before the first spawn. Neither progress nor retries reset it. For V2, each notification poll remains bounded by `min(60000 ms, remaining stage budget, earliest active delivery-grace budget)`.\n   - Require exactly one usable result for the exact expected candidate-ID set. Each result's first line must match `VERIFICATION_OK finding-verifier \u003Ccandidate_id> $BASE_COMMIT...$HEAD_REF \u003Cpacket_sha256>`, followed by a single JSON object matching the contract. Every evidence item must contain exactly a non-empty repository-relative `path`, a positive integer or positive line-range `line`, and a non-empty `observation`; reject absolute\u002Ftraversal\u002Fcontrol-character paths, placeholder values, zero\u002Fnegative lines, and extra fields. `FATAL_VERIFICATION_ERROR`, unknown\u002Fduplicate\u002Fmissing candidate IDs, scope\u002Fhash mismatch, malformed JSON, invalid fields, invalid verdict shape, task failure, timeout, or partial delivery fails closed before aggregation.\n   - Before applying any verdict, serialize each parsed result JSON object to a dedicated temp file outside the worktree using a quoted heredoc delimiter, then run the bundled `scripts\u002Fvalidate_finding_evidence.py` with the repository root, exact recorded `$HEAD_REF`, and result-file path. The validator resolves each path as a literal entry in the immutable `$HEAD_REF` Git tree, accepts only regular text blobs, and requires the cited line or inclusive range to fit within that blob's logical line count. Require exit 0 and exact stdout `EVIDENCE_OK finding-verifier \u003Ccandidate_id> $HEAD_REF \u003Cevidence_count>`. A missing script, write or execution failure, nonzero exit, unexpected stdout, absent\u002Fnon-file\u002Fbinary path, out-of-bounds line, or evidence-count mismatch is fatal before verdict application. Never validate against the current worktree and never interpolate an evidence path into a shell command.\n   - Apply verdicts without changing finding identity: `confirmed` retains the normalized severity; `refuted` removes the candidate from the fix queue but keeps it visible under Refuted Findings; `needs-verification` requires non-empty `missingVerification`, downgrades Critical to Important, and retains Important as Important. `confirmed` and `refuted` require non-empty evidence and empty `missingVerification`. Any other combination is invalid and fails closed.\n\n7. **Final worktree guard**:\n   - Run `git status --porcelain --untracked-files=normal` again after all specialists complete and before aggregation, or before the empty-diff early exit.\n   - If the command fails, abort with the command output and do not aggregate against an unknown worktree state.\n   - If output is non-empty, abort with:\n     > \"Review subagents or concurrent tooling changed the worktree: \\\u003Clist\\>. These changes were not part of the reviewed committed diff. Revert, commit, or stash them, then retry.\"\n   - Run `git rev-parse HEAD` again and compare it with the recorded `$HEAD_REF`. If it differs, abort with:\n     > \"HEAD changed during review: started at `\u003Cold>`, now `\u003Cnew>`. The completed specialist results do not cover the current commit. Re-run the review.\"\n\n8. **Aggregate** all retained specialist findings into the Output Format below. Preserve the originating specialist name and candidate ID in each verified Critical\u002FImportant bullet so the reader can trace lineage. Include every refuted candidate and its verifier summary under Refuted Findings; refuted items do not count toward Critical or Important totals. Always include the stop condition in Recommended Action: `Critical 0 \u002F Important 0` means stop; Suggestions alone do not justify another gate run. On the second and later pass, focus on prior Critical\u002FImportant resolution. On the third and later pass, if Critical\u002FImportant findings keep appearing or changing without stable blocker evidence, call out possible review churn and return the decision to a human maintainer.\n\n## Output format\n\n```markdown\n# PR Review: \u003Cbranch> vs \u003Cbase>\n\n\u003Cdegraded-coverage line if applicable>\n\n## Verification Summary\n- Confirmed: X; Needs verification: Y; Refuted: Z\n\n## Critical Issues (X found)\n- [\u003Ccandidate-id> \u002F \u003Cspecialist>]: \u003Cdescription> [\u003Cfile>:\u003Cline>]\n  - Impact scope: ...\n  - Verified assumptions: ...\n  - Unverified assumptions: ...\n  - Why it matters: ...\n  - Suggested fix: ...\n\n## Important Issues (X shown, top 5)\n- [\u003Ccandidate-id> \u002F \u003Cspecialist>]: \u003Cdescription> [\u003Cfile>:\u003Cline>]\n  - Impact scope: ...\n  - Missing verification: \u003Cif any>\n\n## Suggestions (X shown, max 3)\n- [\u003Cspecialist>]: \u003Cdescription> [\u003Cfile>:\u003Cline>]\n\n## Refuted Findings\n- [\u003Ccandidate-id> \u002F \u003Cspecialist>]: \u003Coriginal description>\n  - Verifier summary: ...\n\n## Strengths\n- \u003Cpositive observations from specialists>\n\n## Recommended Action\n1. Fix Critical issues first\n2. Address Important issues\n3. Consider Suggestions\n4. Re-run review after fixes to verify prior Critical\u002FImportant findings\n5. Stop when Critical 0 \u002F Important 0; do not re-run for Suggestions only\n6. If this is the third or later pass and Critical\u002FImportant findings still churn, escalate to human judgment\n```\n\n## See also\n\n- Design Doc: `docs\u002Fdesign\u002Fcodex-pr-review.md` (dotfiles repo)\n- ADR 0020: clean-worktree invariant (Precondition 1 origin)\n- Issue #186: scope-alignment fix (Precondition 2 origin)\n- ADR 0023 (planned): final decision record\n",{"name":5,"description":7},"main","dad20ea2a4096fe9379fdbee5efcec3ef838ab9e","private_dot_codex\u002Fskills\u002Fpr-review",0,"https:\u002F\u002Fgithub.com\u002Ftoku345\u002Fdotfiles","https:\u002F\u002Fgithub.com\u002Ftoku345","2026-11-14 16:35:03",{"source":9,"skillName":5,"commands":64,"prompt":74,"zipAvailable":75},[65,68,71],{"tool":66,"command":67},"npx","npx skills add toku345\u002Fdotfiles --skill pr-review",{"tool":69,"command":70},"bunx","bunx skills add toku345\u002Fdotfiles --skill pr-review",{"tool":72,"command":73},"pnpm","pnpm dlx skills add toku345\u002Fdotfiles --skill pr-review","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Ftoku345\u002Fdotfiles\u002Fblob\u002Fmain\u002Fprivate_dot_codex\u002Fskills\u002Fpr-review\u002FSKILL.md",true,[77,83,87,91,95,99],{"path":78,"resourceType":79,"resourceTypeDesc":80,"sizeBytes":81,"sourceHtmlUrl":82},"references\u002Fbase-resolution-runtime-contract.json","REFERENCE","参考文档",2403,"https:\u002F\u002Fgithub.com\u002Ftoku345\u002Fdotfiles\u002Fblob\u002Fmain\u002Fprivate_dot_codex\u002Fskills\u002Fpr-review\u002Freferences\u002Fbase-resolution-runtime-contract.json",{"path":84,"resourceType":79,"resourceTypeDesc":80,"sizeBytes":85,"sourceHtmlUrl":86},"references\u002Ffinding-verifier-contract.json",3917,"https:\u002F\u002Fgithub.com\u002Ftoku345\u002Fdotfiles\u002Fblob\u002Fmain\u002Fprivate_dot_codex\u002Fskills\u002Fpr-review\u002Freferences\u002Ffinding-verifier-contract.json",{"path":88,"resourceType":79,"resourceTypeDesc":80,"sizeBytes":89,"sourceHtmlUrl":90},"references\u002Freview-criteria.md",4659,"https:\u002F\u002Fgithub.com\u002Ftoku345\u002Fdotfiles\u002Fblob\u002Fmain\u002Fprivate_dot_codex\u002Fskills\u002Fpr-review\u002Freferences\u002Freview-criteria.md",{"path":92,"resourceType":79,"resourceTypeDesc":80,"sizeBytes":93,"sourceHtmlUrl":94},"references\u002Fseverity-rules.json",4232,"https:\u002F\u002Fgithub.com\u002Ftoku345\u002Fdotfiles\u002Fblob\u002Fmain\u002Fprivate_dot_codex\u002Fskills\u002Fpr-review\u002Freferences\u002Fseverity-rules.json",{"path":96,"resourceType":79,"resourceTypeDesc":80,"sizeBytes":97,"sourceHtmlUrl":98},"references\u002Fv2-runtime-contract.json",1919,"https:\u002F\u002Fgithub.com\u002Ftoku345\u002Fdotfiles\u002Fblob\u002Fmain\u002Fprivate_dot_codex\u002Fskills\u002Fpr-review\u002Freferences\u002Fv2-runtime-contract.json",{"path":100,"resourceType":101,"resourceTypeDesc":102,"sizeBytes":103,"sourceHtmlUrl":104},"scripts\u002Fvalidate_finding_evidence.py","SCRIPT","脚本",7695,"https:\u002F\u002Fgithub.com\u002Ftoku345\u002Fdotfiles\u002Fblob\u002Fmain\u002Fprivate_dot_codex\u002Fskills\u002Fpr-review\u002Fscripts\u002Fvalidate_finding_evidence.py",[106,126,157,177,203,221],{"skillNo":107,"name":108,"nameZh":109,"description":110,"descriptionZh":111,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":112,"sourceHtmlUrl":113,"categories":114,"keywords":119,"publishedAt":51},"01M6BVHMWSZMNVE2HDN10GFDQ8","teach","代码原理讲解","Explain code, changes, and subsystems by investigating how they work and why they were designed that way, then teach at the user's pace. Use for explicit teach requests, teach me this, help me understand this implementation, この実装を教えて, 仕組みと設計背景を知りたい, and understanding before review or modification. Do not trigger for every factual question or primarily implementation requests.","通过探究代码、变更与子系统的工作原理及其设计原因来进行讲解，并按用户的节奏施教。适用于明确的教学请求（teach me this、help me understand this implementation、この実装を教えて、仕組みと設計背景を知りたい），以及评审或修改前的理解需求。不要对每个事实性问题或以实现为主的请求都触发。","https:\u002F\u002Fgithub.com\u002Ftoku345\u002Fdotfiles\u002Fblob\u002Fmain\u002Fdot_agents\u002Fskills\u002Fteach\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Ftoku345\u002Fdotfiles\u002Fblob\u002Fmain\u002Fdot_agents\u002Fskills\u002Fteach\u002FSKILL.md",[115,118],{"categoryNo":116,"categoryName":117,"taxonomyType":28,"taxonomyTypeDesc":29},"01M8BQ6TM27KFNXBV69GEXBTVN","学习引导",{"categoryNo":21,"categoryName":22,"taxonomyType":23,"taxonomyTypeDesc":24},[108,33,120,121,122,123,124,125],"teach me","why","how","explain code","help","code",{"skillNo":127,"name":128,"nameZh":129,"description":130,"descriptionZh":131,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":132,"categories":133,"keywords":136,"publishedAt":51},"01M6BVHZNFQBVQPV3NA8DA373N","pr-review-coach","PR 审查教练","Japanese-only PR understanding coach. Use when the user wants to prepare their own review, understand a branch diff, identify questions to ask, or build review judgment before running a merge gate. Requires an explicit --base \u003Cref-or-commit> for the first turn, then resumes from local state on answer turns. Asks at most one question at a time and stores resumable local state outside the target worktree. Single-agent only; does not spawn specialist reviewers, does not produce Critical\u002FImportant\u002FSuggestions gate findings, and does not decide merge readiness.","仅支持日语的 PR 理解教练。当用户想要准备自己的审查、理解分支差异、梳理要提出的问题，或在执行合并门禁前建立审查判断力时使用。首轮需显式提供 --base \u003Cref-or-commit>，后续回答轮次从本地状态恢复。每次最多提出一个问题，并将可恢复的本地状态存储在目标工作树之外。仅限单智能体；不派生专项审查员，不产生 Critical\u002FImportant\u002FSuggestions 门禁发现项，也不决定是否可以合并。","https:\u002F\u002Fgithub.com\u002Ftoku345\u002Fdotfiles\u002Fblob\u002Fmain\u002Fprivate_dot_codex\u002Fskills\u002Fpr-review-coach\u002FSKILL.md",[134,135],{"categoryNo":21,"categoryName":22,"taxonomyType":23,"taxonomyTypeDesc":24},{"categoryNo":26,"categoryName":27,"taxonomyType":28,"taxonomyTypeDesc":29},[33,31,32,137,138,38,139,140,141,142,143,144,34,145,146,147,148,149,150,151,152,153,154,43,45,155,156],"pr review coach","coach","answer","for","single","merge","running","commit","local","time","prepare","japanese","state","produce","only","worktree","first","merge gate","decide","question",{"skillNo":158,"name":159,"nameZh":160,"description":161,"descriptionZh":162,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":163,"categories":164,"keywords":171,"publishedAt":51},"01M6BVHXZYDT858V8GQEJHKMPC","writing-proofreader","日语文章校对","日本語ブログ・技術記事の校正スキル。Fumitakaの文体ガイドラインに基づいて表現・構成・トーンをチェックし、改善提案を行う。「校正して」「レビューして」「文章チェックして」「書いた記事を見て」「ブログ見てもらえる？」「おかしいところない？」「公開前に確認して」「この記事どう思う？」など、記事やブログの品質チェックに関するリクエスト全般で使う。Markdownやテキストの文章校正を依頼されたら必ずこのスキルを参照する。記事の「推敲」「添削」「赤入れ」といった表現でも発動すること。","日语博客与技术文章的校对技能。基于 Fumitaka 的文体指南，检查表达、结构与语气，并提出改进建议。适用于「校对一下」「审查一下」「检查文章」「看看我写的文章」「能帮我看看博客吗」「有没有哪里不对」「发布前确认一下」「这篇文章你觉得怎么样？」等与文章或博客质量检查相关的各类请求。当用户要求对 Markdown 或纯文本文章进行校对时，务必参考此技能。文章中的「推敲」「修改」「批改」等表述同样会触发本技能。","https:\u002F\u002Fgithub.com\u002Ftoku345\u002Fdotfiles\u002Fblob\u002Fmain\u002Fprivate_dot_claude\u002Fskills\u002Fwriting-proofreader\u002FSKILL.md",[165,168],{"categoryNo":166,"categoryName":167,"taxonomyType":23,"taxonomyTypeDesc":24},"01M8BVB0FJ0RR8KXYVFTKEA3XX","技术文档工程师",{"categoryNo":169,"categoryName":170,"taxonomyType":28,"taxonomyTypeDesc":29},"01M8BZBNYC0854523N0JJSZGK3","内容质量审核与优化",[172,173,174,175,176],"writing","writing proofreader","proofreader","文章","提案",{"skillNo":178,"name":5,"nameZh":179,"description":180,"descriptionZh":181,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":182,"categories":183,"keywords":186,"publishedAt":51},"01M6BVHTTDAY7CYFMFR0HZX1YJ","PR 前评审质量闸门","Claude-side pre-PR review gate. Resolves the branch's base ref (gh PR view or explicit --base), pins an authoritative diff packet, then launches the pr-review dynamic workflow (~\u002F.claude\u002Fworkflows\u002Fpr-review.js) which fans out up to 8 review specialists (code-reviewer, security-reviewer, adversarial-reviewer, pr-test-analyzer, comment-analyzer, silent-failure-hunter, type-design-analyzer, code-simplifier), fails closed on coverage, and verifies Critical\u002FImportant findings. Use before creating a pull request as a quality gate for thick changes — especially where the Codex CLI `$pr-review` skill is unavailable. Triggers: \"pre-PR review\", \"PR 前レビュー\", \"レビュー gate を回して\", \"run the pr-review gate\".","Claude 侧的 PR 前评审闸门。解析分支的 base ref（gh PR view 或显式 --base），固定一份权威的 diff 包，然后启动 pr-review 动态工作流（~\u002F.claude\u002Fworkflows\u002Fpr-review.js），该工作流最多分派 8 位评审专家（code-reviewer、security-reviewer、adversarial-reviewer、pr-test-analyzer、comment-analyzer、silent-failure-hunter、type-design-analyzer、code-simplifier），覆盖不足则失败关闭，并核验 Critical\u002FImportant 级别的发现。在创建拉取请求前用作大型变更的质量闸门——尤其适用于 Codex CLI 的 `$pr-review` 技能不可用的情况。触发词：「pre-PR review」「PR 前レビュー」「レビュー gate を回して」「run the pr-review gate」。","https:\u002F\u002Fgithub.com\u002Ftoku345\u002Fdotfiles\u002Fblob\u002Fmain\u002Fprivate_dot_claude\u002Fskills\u002Fpr-review\u002FSKILL.md",[184,185],{"categoryNo":21,"categoryName":22,"taxonomyType":23,"taxonomyTypeDesc":24},{"categoryNo":26,"categoryName":27,"taxonomyType":28,"taxonomyTypeDesc":29},[32,31,33,187,188,5,38,189,190,45,191,192,193,47,125,194,48,49,195,196,197,198,199,200,201,202],"request","which","up","coverage","test","gh pr","js","run","codex cli","workflows","reviewer","workflow","security","codex","cli","design",{"skillNo":204,"name":205,"nameZh":206,"description":207,"descriptionZh":208,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":209,"categories":210,"keywords":215,"publishedAt":51},"01M6BVHRPQ77P9BF94T0VQ871E","codex-usage","Codex CLI 计划评审指南","Codex CLI による実装計画レビューの条件と手順、および `\u002Fcodex:adversarial-review` \u002F `\u002Fcodex:rescue` の使い分け。厚い変更の計画完成時や、調査委譲・別案試行・バックグラウンド実行を検討するときに参照する。","介绍使用 Codex CLI 进行实现计划评审的条件与步骤，以及 `\u002Fcodex:adversarial-review` \u002F `\u002Fcodex:rescue` 的区分使用。在大型变更的计划完成时，或考虑调查委派、尝试其他方案、后台执行时参考。","https:\u002F\u002Fgithub.com\u002Ftoku345\u002Fdotfiles\u002Fblob\u002Fmain\u002Fprivate_dot_claude\u002Fskills\u002Fcodex-usage\u002FSKILL.md",[211,212],{"categoryNo":21,"categoryName":22,"taxonomyType":23,"taxonomyTypeDesc":24},{"categoryNo":213,"categoryName":214,"taxonomyType":28,"taxonomyTypeDesc":29},"01M8BRN0DBCRG4XGJMB6QQEP11","编码任务委派",[216,217,200,201,33,195,218,219,220],"usage","codex usage","adversarial","adversarial-review","rescue",{"skillNo":222,"name":223,"nameZh":224,"description":225,"descriptionZh":226,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":227,"sourceHtmlUrl":228,"categories":229,"keywords":234,"publishedAt":51},"01M6BVHQ1QDEZJN8FFZ62X5PSV","brainstorming","苏格拉底式设计头脑风暴","ソクラテス式対話で要件と設計を詰めてから実装方針を固めるブレインストーミングスキル。「ブレスト」「設計を考えたい」「どう実装すべきか」「アーキテクチャを相談したい」「設計相談」「実装の前に整理したい」「方針を決めたい」などのリクエストで発動する。Triggers Socratic-dialogue design refinement before implementation; surfaces 2-3 approaches and records key decisions as ADRs.","通过苏格拉底式对话敲定需求与设计，再确定实现方针的头脑风暴技能。在「头脑风暴」「想考虑设计」「该怎么实现」「想咨询架构」「设计咨询」「实现前先梳理」「想确定方针」等请求时触发。在实现前通过苏格拉底式对话细化设计；提出 2～3 个方案，并将关键决策记录为 ADR。","https:\u002F\u002Fgithub.com\u002Ftoku345\u002Fdotfiles\u002Fblob\u002Fmain\u002Fprivate_dot_claude\u002Fskills\u002Fbrainstorming\u002FLICENSE.superpowers","https:\u002F\u002Fgithub.com\u002Ftoku345\u002Fdotfiles\u002Fblob\u002Fmain\u002Fprivate_dot_claude\u002Fskills\u002Fbrainstorming\u002FSKILL.md",[230,231],{"categoryNo":21,"categoryName":22,"taxonomyType":23,"taxonomyTypeDesc":24},{"categoryNo":232,"categoryName":233,"taxonomyType":28,"taxonomyTypeDesc":29},"01M8C0NK9M473EJ7H1916WKHM9","头脑风暴与创意构思",[223,235,236,237,238,239,39,240,241,242,243,202],"surfaces","socratic","refinement","整理","records","triggers","dialogue","implementation","decisions"]