Code Review Pre-Merge Gate
Use this workflow when a PR or MR is close to merge and needs the shared
delivery specialist review gate without handing provider actions to the
code-review skill itself.
Contract
Prereqs:
- Run inside the target git repository with
git available on PATH.
review-specialists is installed from the released nils-cli package and
available on PATH.
- The mandatory and risk lenses run through the managed read-only reviewer
subagents dispatched by the shared specialist gate on hosts that spawn
subagents without an explicit per-run request (e.g. Claude Code). On hosts that
only spawn subagents on explicit request (e.g. Codex), review the lenses inline
by default — the expected path, not a waiver — and dispatch only on explicit
opt-in; record a waiver only when an intended dispatch genuinely fails.
- The PR/MR base branch or merge-base is known.
- Local validation and provider check evidence are available or explicitly
marked pending by the owning delivery workflow.
- Keep this workflow read-only: it does not fix code, post PR/MR comments,
mark reviewables ready, merge, close issues, or clean branches.
Inputs:
- PR/MR identifier or reviewable summary, base ref, head ref, validation
evidence, and optional linked issue context.
- Optional provider-side review evidence collected read-only by the owning
delivery workflow: reviews and review threads already posted on the PR/MR
(typically by bot reviewers). When supplied, classify those findings with
the same delivery outcome vocabulary as local lens findings.
- Optional forced risk lenses beyond the mandatory minimum:
--security, --performance, --data-migration, --api-contract, or
--red-team.
Outputs:
- Scope JSON from
review-specialists scope with at least --testing and
--maintainability forced.
- Gate result:
pass, request-followup, blocked, or accepted-risk.
- Concrete findings, accepted tradeoffs, residual risks, and validation gaps.
- A delivery review outcome body suitable for the owning PR/MR delivery
workflow to post.
Failure modes:
- Base ref is missing, ambiguous, or not the PR/MR target base.
- Required validation/check evidence is absent and no explicit pending status is
acceptable.
- Concrete specialist findings remain unresolved and are not explicitly
accepted by the owning delivery workflow.
- Caller tries to use this workflow to merge, close, post provider comments, or
replace
deliver-pr or review-dispatch-lane-pr.
Entrypoint
Run the shared gate's mandatory scope detection:
review-specialists scope \
--base "$BASE_REF" \
--testing \
--maintainability \
--format json
Add risk lenses when warranted:
review-specialists scope \
--base "$BASE_REF" \
--testing \
--maintainability \
--security \
--api-contract \
--format json
Workflow
- Resolve reviewable metadata and confirm the base ref is the actual PR/MR
target branch or merge-base.
- Follow the shared delivery gate in
skills/code-review/code-review-specialists/references/DELIVERY_SPECIALIST_REVIEW_GATE.md.
- Run
review-specialists scope --base "$BASE_REF" --testing --maintainability --format json. Do not skip small diffs.
- Add risk lenses for security, API contract, migration, performance, or
red-team conditions when the scope warrants them. Include red-team when
diff_lines > 200, any first-wave specialist produces a critical finding,
the reviewable changes safety/security-sensitive behavior, or the caller
forced --red-team.
- Review the first-wave lenses read-only by dispatching the matching managed
reviewer subagents (
reviewer-testing, reviewer-maintainability, and any
forced risk lens such as reviewer-security, reviewer-api-contract, or
reviewer-performance); collect their JSONL findings, validate and merge them,
and classify each item using the shared delivery outcome vocabulary. (On hosts
that only spawn subagents on explicit request, such as Codex, review these
lenses inline by default.)
- Dispatch
reviewer-red-team only after the first-wave lenses, and only when
the scope warrants it. On explicit-only hosts such as Codex, run the same
red-team lens inline from references/specialists/red-team.md unless the
user explicitly opted into subagents. Hand it the merged first-wave findings
so it can probe cross-cutting failure modes, then validate its JSONL and merge
the combined first-wave plus red-team JSONL before folding it into the result.
- Classify every meaningful first-wave and red-team item using the shared
delivery outcome vocabulary.
- Treat evidence-backed concrete findings as blocking until repaired, accepted
by the owner, or converted into an explicit follow-up.
- Produce a compact gate result and delivery review outcome body. The owning
delivery skill posts comments, reruns checks, merges, or stops.
Boundary
code-review-pre-merge-gate owns the read-only review gate,
reviewer-subagent dispatch when used, inline lens execution on explicit-only
hosts, and the review outcome recommendation. Each dispatched reviewer subagent
owns only its read-only lens. Provider delivery skills own PR/MR comments, ready
transitions, checks, merge/close calls, issue closeout, and repair execution.
References
- Delivery specialist review gate:
skills/code-review/code-review-specialists/references/DELIVERY_SPECIALIST_REVIEW_GATE.md
- Delivery review outcome comment:
skills/code-review/code-review-specialists/references/DELIVERY_REVIEW_OUTCOME_COMMENT.md
- Delivery review outcome schema:
skills/code-review/code-review-specialists/references/DELIVERY_REVIEW_OUTCOME_SCHEMA.md
- PR/MR delivery workflow:
skills/pr/deliver-pr/SKILL.md
- Dispatch PR review workflow:
skills/dispatch/review-dispatch-lane-pr/SKILL.md
Source: graysurf/agent-runtime-kit — distributed by TomeVault.
1---2name: code-review-pre-merge-gate3description: Use this workflow when a PR or MR is close to merge and needs the shared4---56# Code Review Pre-Merge Gate78Use this workflow when a PR or MR is close to merge and needs the shared9delivery specialist review gate without handing provider actions to the10code-review skill itself.1112## Contract1314Prereqs:1516- Run inside the target git repository with `git` available on `PATH`.17- `review-specialists` is installed from the released nils-cli package and18 available on `PATH`.19- The mandatory and risk lenses run through the managed read-only reviewer20 subagents dispatched by the shared specialist gate on hosts that spawn21 subagents without an explicit per-run request (e.g. Claude Code). On hosts that22 only spawn subagents on explicit request (e.g. Codex), review the lenses inline23 by default — the expected path, not a waiver — and dispatch only on explicit24 opt-in; record a waiver only when an intended dispatch genuinely fails.25- The PR/MR base branch or merge-base is known.26- Local validation and provider check evidence are available or explicitly27 marked pending by the owning delivery workflow.28- Keep this workflow read-only: it does not fix code, post PR/MR comments,29 mark reviewables ready, merge, close issues, or clean branches.3031Inputs:3233- PR/MR identifier or reviewable summary, base ref, head ref, validation34 evidence, and optional linked issue context.35- Optional provider-side review evidence collected read-only by the owning36 delivery workflow: reviews and review threads already posted on the PR/MR37 (typically by bot reviewers). When supplied, classify those findings with38 the same delivery outcome vocabulary as local lens findings.39- Optional forced risk lenses beyond the mandatory minimum:40 `--security`, `--performance`, `--data-migration`, `--api-contract`, or41 `--red-team`.4243Outputs:4445- Scope JSON from `review-specialists scope` with at least `--testing` and46 `--maintainability` forced.47- Gate result: `pass`, `request-followup`, `blocked`, or `accepted-risk`.48- Concrete findings, accepted tradeoffs, residual risks, and validation gaps.49- A delivery review outcome body suitable for the owning PR/MR delivery50 workflow to post.5152Failure modes:5354- Base ref is missing, ambiguous, or not the PR/MR target base.55- Required validation/check evidence is absent and no explicit pending status is56 acceptable.57- Concrete specialist findings remain unresolved and are not explicitly58 accepted by the owning delivery workflow.59- Caller tries to use this workflow to merge, close, post provider comments, or60 replace `deliver-pr` or `review-dispatch-lane-pr`.6162## Entrypoint6364Run the shared gate's mandatory scope detection:6566```bash67review-specialists scope \68 --base "$BASE_REF" \69 --testing \70 --maintainability \71 --format json72```7374Add risk lenses when warranted:7576```bash77review-specialists scope \78 --base "$BASE_REF" \79 --testing \80 --maintainability \81 --security \82 --api-contract \83 --format json84```8586## Workflow87881. Resolve reviewable metadata and confirm the base ref is the actual PR/MR89 target branch or merge-base.902. Follow the shared delivery gate in91 `skills/code-review/code-review-specialists/references/DELIVERY_SPECIALIST_REVIEW_GATE.md`.923. Run `review-specialists scope --base "$BASE_REF" --testing93 --maintainability --format json`. Do not skip small diffs.944. Add risk lenses for security, API contract, migration, performance, or95 red-team conditions when the scope warrants them. Include red-team when96 `diff_lines > 200`, any first-wave specialist produces a `critical` finding,97 the reviewable changes safety/security-sensitive behavior, or the caller98 forced `--red-team`.995. Review the first-wave lenses read-only by dispatching the matching managed100 reviewer subagents (`reviewer-testing`, `reviewer-maintainability`, and any101 forced risk lens such as `reviewer-security`, `reviewer-api-contract`, or102 `reviewer-performance`); collect their JSONL findings, validate and merge them,103 and classify each item using the shared delivery outcome vocabulary. (On hosts104 that only spawn subagents on explicit request, such as Codex, review these105 lenses inline by default.)1066. Dispatch `reviewer-red-team` only after the first-wave lenses, and only when107 the scope warrants it. On explicit-only hosts such as Codex, run the same108 red-team lens inline from `references/specialists/red-team.md` unless the109 user explicitly opted into subagents. Hand it the merged first-wave findings110 so it can probe cross-cutting failure modes, then validate its JSONL and merge111 the combined first-wave plus red-team JSONL before folding it into the result.1127. Classify every meaningful first-wave and red-team item using the shared113 delivery outcome vocabulary.1148. Treat evidence-backed concrete findings as blocking until repaired, accepted115 by the owner, or converted into an explicit follow-up.1169. Produce a compact gate result and delivery review outcome body. The owning117 delivery skill posts comments, reruns checks, merges, or stops.118119## Boundary120121`code-review-pre-merge-gate` owns the read-only review gate,122reviewer-subagent dispatch when used, inline lens execution on explicit-only123hosts, and the review outcome recommendation. Each dispatched reviewer subagent124owns only its read-only lens. Provider delivery skills own PR/MR comments, ready125transitions, checks, merge/close calls, issue closeout, and repair execution.126127## References128129- Delivery specialist review gate:130 `skills/code-review/code-review-specialists/references/DELIVERY_SPECIALIST_REVIEW_GATE.md`131- Delivery review outcome comment:132 `skills/code-review/code-review-specialists/references/DELIVERY_REVIEW_OUTCOME_COMMENT.md`133- Delivery review outcome schema:134 `skills/code-review/code-review-specialists/references/DELIVERY_REVIEW_OUTCOME_SCHEMA.md`135- PR/MR delivery workflow:136 `skills/pr/deliver-pr/SKILL.md`137- Dispatch PR review workflow:138 `skills/dispatch/review-dispatch-lane-pr/SKILL.md`139140---141> Source: [graysurf/agent-runtime-kit](https://github.com/graysurf/agent-runtime-kit) — distributed by [TomeVault](https://tomevault.io).142<!-- tomevault:4.0:skill_md:2026-06-16 -->