review-gate-mcp
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
review-gate
Deterministic boundary & review gate for multi-model AI coding agents.
CLI · MCP Server · Pi Native Extension · 3 Intent-Driven Skills · Zero-Build TypeScript (Node ≥ 24) · Windows / WSL / macOS / Linux
Stop unbounded plan/code review ping-pong, weak-implementer scope drift, and silent prompt-cache tax.
review-gatemoves loop caps, Git-tree diff slicing, scope enforcement, and regression circuit breakers out of fragile prompts and into deterministic code — shared seamlessly across Claude Code, Codex CLI, T3 Code, and Pi.
Why review-gate?
LLM-driven review loops fail predictably without hard code boundaries:
Diminishing returns & over-refinement: quality gains peak in rounds 1–2; unbounded rounds introduce regressions and goalpost shifting.
Weak-refiner ping-pong: letting a weaker model repeatedly guess at a stronger critic's complex feedback degrades code instead of fixing it.
Silent drift & tampering: implementers weaken test assertions, tweak
package.json, or ignore soft prompt limits.Prompt-cache invalidation & client timeouts: dynamic timestamps in prompt prefixes bust KV caches, and 2–4 minute deep reviews trip 60s MCP client timeouts.
review-gate solves all four with one lightweight TypeScript core storing tamper-resistant state inside <git-dir>/agent-gate/ (no .gitignore edits, naturally isolated per git worktree).
Related MCP server: Orchestrator Python MCP Server
Two Governed Workflows
flowchart LR
subgraph M1["Mode 1 · advisor_impl (Strong Plan/Advisor -> Weak Implementer)"]
direction LR
P1["Strong Init Contract"] --> W1["Weak Implements"]
W1 --> S1["Git-Tree Scope Check"]
S1 -->|"Repeated Fail / Conflict / Final Check"| A1["Strong Advisor (max 2 calls)"]
A1 -->|"coach"| W1
A1 -->|"amend_contract"| M1A["Orchestrator Amends"]
A1 -->|"takeover_now / Same Fingerprint / Cap"| T1["TAKEOVER_REQUIRED"]
end
subgraph M2["Mode 2 · final_review (Single Model Impl -> Strong Final Review)"]
direction LR
P2["Init Spec + Verify Cmd"] --> I2["Implement + Pass verify_cmd"]
I2 --> R1["Round 1 Full Diff Review"]
R1 -->|"0 P0 + approve"| OK["APPROVED"]
R1 -->|"ambiguity"| H1["ESCALATE_HUMAN"]
R1 -->|"P0 > 0"| F2["Fix P0s Only"]
F2 --> R2["Round 2 Verify-Only (r1..r2 Diff)"]
R2 -->|"All R1 P0 Resolved + 0 Regressions"| OK
R2 -->|"Regression or P0 Increased"| RB["ROLLBACK_ESCALATE"]
R2 -->|"Unresolved Non-Regressing P0"| T2["TAKEOVER_REQUIRED (No R3)"]
endDimension | Mode 1: | Mode 2: |
Role Split | Strong model writes contracted plan & advises; weaker model implements | One model plans & implements; independent stronger model reviews diff |
Hard Caps |
|
|
Pre-Checks | Authoritative | Mandatory |
Review Scope | Structural triggers only ( | R1: full |
Escalation |
|
|
Architecture: One Core, Four Clients
flowchart TD
CC["Claude Code"] --> MCP["review-gate-mcp (stdio + progress heartbeat)"]
CX["Codex CLI"] --> MCP
T3["T3 Code"] --> MCP
T3 -.->|"gate_only + native async delegate_task"| CORE
PI["Pi Coding Agent"] --> EXT["extensions/pi/review-gate.ts (tool_call guard + native tools)"]
SK["~/.agents/skills/ (3 Intent-Driven SKILL.md)"] -.-> CC
SK -.-> CX
SK -.-> T3
SK -.-> PI
MCP --> CORE["src/core/ · Single TypeScript Engine"]
EXT --> CORE
CORE --> STATE["{git-dir}/agent-gate/ (tasks, active.json, metrics.jsonl)"]
CORE --> REFS["refs/agent-gate/{task_id}/* (immutable write-tree snapshots)"]
CORE --> RUN["Hardened Backends: codex exec | claude -p | gate_only"]Quick Start
Requires Node ≥ 24 (runs .ts natively with erasableSyntaxOnly: true — zero build step).
1. Clone, Test & Link Globally
git clone https://github.com/hua0512/review-gate.git review-gate
cd review-gate
pnpm install
pnpm run typecheck
pnpm test
pnpm add -g link:. # exposes `review-gate` and `review-gate-mcp` on PATH (or: npm link)On Windows,
pnpmglobal bins generate.cmdwrappers; when registering MCP servers in clients that spawn withshell: false, usecommand: "node"withargs: ["<path/to/review-gate>/src/mcp.ts", "--role", "orchestrator"].
2. Install Shared Skills (+ Native Pi Extension)
# Installs 3 skills to ~/.agents/skills/ and links ~/.claude/skills/ & ~/.pi/agent/skills/
# (unprivileged NTFS junctions on Windows; POSIX symlinks on macOS/Linux/WSL)
review-gate install-skills --force
# Include the native Pi extension shim (~/.pi/agent/extensions/review-gate.ts):
review-gate install-skills --force --with-pi-extensionUsing both Windows native and WSL on the same machine? Run
install-skillsonce in Windows and once inside WSL so each$HOMEkeeps native links.
3. Connect Your Clients
Client | Setup | Recommended Mode |
Claude Code |
| Unified backend ( |
Codex CLI |
| Unified backend ( |
T3 Code | Add MCP server | Mode 1: Strong main thread + |
Pi | Run | Native |
In ~/.pi/agent/mcp.json (or .pi/mcp.json), then /reload:
{
"mcpServers": {
"review-gate": {
"command": "review-gate-mcp",
"args": ["--role", "orchestrator"],
"exposure": "direct"
}
}
}When mounting MCP for an isolated weak-implementer session, pass --role implementer. This hides privileged lifecycle and approval tools (gate_init, gate_amend, gate_takeover, gate_approve, gate_close, gate_prepare_review, gate_record_review, gate_metrics, gate_prune) so implementers can never self-approve or rewrite contracts.
Everyday Usage
Once Skills and MCP/Extension are installed, just express your intent naturally — no CLI syntax to memorize:
Mode 1 (Strong Plan/Advisor → Weak Implementer)
“Design a contracted plan to refactorsrc/auth/**, protecttests/auth/**, verify withpnpm test, initializereview-gatein advisor mode, and delegate implementation.”Mode 2 (Implement → Strong Final Review)
“Initializereview-gatein final-review mode withcodex(gpt-5.4, high effort) andpnpm test, implement the feature, and pass final review.”Metrics & Model Comparison
“Show recent review effectiveness across models” or “Export and open the review dashboard”T3 Code:
gate_metrics(format="html")→html_preview→html_renderrenders the interactive SVG dashboard inline in your thread.Claude Code / Codex / Pi: renders a Markdown table in terminal, or runs
gate_metrics(format="html", open=true)to write a standalone dark/light-adaptive HTML dashboard to the OS temp dir and open your default browser automatically.
Maintenance
“Clean up stale review-gate tasks older than 7 days” → previews withdry_run=true, then prunes old task files & orphan refs while preservingmetrics.jsonl, the active task, and sibling worktrees' live refs.
Optional: PreToolUse Fast-Fail Scope Hooks
Authoritative vs. Fast-Fail: The engine's Git-tree scope check (
git diff --name-status <base_tree> <current_tree>) is always the single authoritative guard across all 4 clients. Adding aPreToolUsehook is optional — it catches out-of-scope file edits before they happen during Mode 1 (advisor_impl+in_progress), and stays completely silent otherwise.
Claude Code (~/.claude/settings.json or .claude/settings.json):
{
"hooks": {
"PreToolUse": [
{
"matcher": "Edit|Write|MultiEdit",
"hooks": [
{
"type": "command",
"command": "review-gate hook-pre-tool-use --client claude"
}
]
}
]
}
}Codex CLI (~/.codex/hooks.json or .codex/hooks.json):
{
"hooks": {
"PreToolUse": [
{
"matcher": "Edit|Write",
"hooks": [
{
"type": "command",
"command": "review-gate hook-pre-tool-use --client codex"
}
]
}
]
}
}Note: Codex CLI does not currently fire
PreToolUseonapply_patch, and T3 Codedelegate_taskdoes not run localPreToolUsehooks; in both cases the engine's Git-tree scope check still enforces the contract at every gate transition. Pi gets interactivetool_callinterception natively viaextensions/pi/review-gate.ts.
Systems Engineering & Hardening
Area | What |
Tamper Resistance | State lives under |
Zero-Commit Snapshots | Snapshots uncommitted edits, deletions, and untracked files using a temporary |
Implicit Manifest Protection | Blocks edits to |
Windows + WSL Hardening | Resolves |
Anti-Recursion & Real CLI Auth | Sets |
Prompt Cache & Timeout Hygiene | Static instructions, |
RCO Telemetry & Safe Prune | Appends privacy-safe records to |
CLI & MCP Reference
# Mode 1: Strong Plan/Advisor -> Weak Implementer
review-gate init --task-id feat-1 --mode advisor_impl \
--spec "Add auth refresh helper" --verify "pnpm test" \
--allow "src/auth/**" --protect-test "tests/auth/**" \
--backend codex --model gpt-5.4 --effort high
review-gate check-scope --file src/auth/refresh.ts
review-gate check-scope --git
review-gate advisor --trigger repeated_verify_failure --question "TS2345 persists"
review-gate amend --allow "src/auth/**" --allow "src/types.ts"
review-gate takeover
review-gate approve
review-gate close
# Mode 2: Single Model Impl -> Strong Final Review
review-gate init --task-id fix-2 --mode final_review \
--spec "Fix parser edge case" --verify "pnpm test" \
--backend claude --model claude-opus-4-6 --effort high
review-gate review
# Mode 2 Gate-Only (e.g. T3 Code delegate_task; pipe verdict via stdin to keep working tree untouched)
review-gate prepare
review-gate record --round 1 --tree <sha> --nonce <nonce> --review-file - < /tmp/verdict.json
review-gate close
# Telemetry & Maintenance
review-gate status
review-gate metrics --format markdown
review-gate metrics --format html --open
review-gate prune --older-than-days 7 --dry-run
review-gate prune --older-than-days 7
# Installation & Adapters
review-gate install-skills --force [--with-pi-extension]
review-gate install-pi
review-gate mcp --role orchestrator|implementerTool | Role | Purpose |
|
| Inspect active task state, worktree pointer, and Git scope summary |
|
| Validate a file path or full working-tree diff against the contract |
|
| Mode 1 bounded advisor call with fingerprint stagnation detection & MCP heartbeat |
|
| Mode 2 unified backend review ( |
|
| Initialize task, snapshot |
|
| Update contract or runner config without resetting round/advisor history |
|
| Transition to |
|
| Mode 1: verify |
|
| Record telemetry to |
|
| Gate-Only: run pre-checks, snapshot tree, issue |
|
| Gate-Only: verify tamper-binding token, validate schema + R2 partition, advance state |
|
| Return |
|
| Prune stale tasks & orphan refs across worktrees (preserves |
Research Foundations
review-gate's boundaries are directly grounded in multi-agent & LLM-refinement research:
Bounded 1–2 Round Gains & Over-Refinement: Self-Refine (arXiv:2303.17651)
External Truth & Soundness vs. Style Critics: Cannot Self-Correct (arXiv:2310.01798), When Can LLMs Actually Correct Their Own Mistakes? (arXiv:2406.01297), LLM-Modulo (arXiv:2402.01817)
Nitpicking vs. Recall & Human Escalation: CriticGPT (arXiv:2407.00215)
Clean-Slate Independence & Deterministic State Machines: Degeneration-of-Thought (arXiv:2305.19118), MAST (arXiv:2503.13657), Talk Isn't Always Cheap (arXiv:2509.05396)
Weak-Refiner Degradation & Direct Takeover: Asymmetric Capacity Allocation in Self-Refinement Pipelines (arXiv:2608.21345)
Stall Circuit Breakers & Non-Destructive Rollback: Magentic-One (arXiv:2411.04468), PerFine (arXiv:2510.24469)
Critique Utility Telemetry: RCO (arXiv:2506.22157)
Prompt Cache Prefix Discipline: Don't Break the Cache (arXiv:2601.06007), Silent and Costly (arXiv:2610.34817), Context Has a Price (arXiv:2611.22238)
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Pre-execution governance for AI agents. Deterministic PASS/FAIL/REVIEW verdicts, replayable proof.
Governance and control for agentic software development. Trust AI written code.
Guardian agent for AI coding: four frontier models review risky diffs and commits before they ship.
Shared control plane for AI coding agents — tasks, memory, decisions, file locks. 12 tools.
Related MCP Servers
- AlicenseNot gradedqualityCmaintenanceDeterministic AI code review with audit records, providing stack-specific rulesets and governance for coding agents.6MIT
- FlicenseBqualityDmaintenanceEnables AI coding assistants to run a machine-verified DESIGN→PLAN→EXECUTE→VERIFY→COMPLETE workflow with human approval gates, state integrity checks, and DAG task scheduling.7-
- AlicenseNot gradedqualityBmaintenanceEnables Claude Code, Cursor, and Codex users to orchestrate plan/build/review workflows across host or CLI models with a spec gate, tool vetting, hard per-run and per-day cost/token limits, safe defaults, and clear logs.15 npmMIT
- AlicenseNot gradedqualityBmaintenanceEnables AI coding agents to scaffold, verify, audit, and safely modify software projects across 11 technology stacks, with rollback checkpoints, session continuity, and an evidence-based learning loop.928 npmMIT