If you let an AI agent write your code, who checks it?
For most setups the answer is: the same model, or another instance of the same family, asked politely to "review the changes." It finds a few nits, says the code looks good, and you merge. That is not a review. It is the author reading their own draft.
I ran into this building with coding agents, and it is why I wrote CodeReview, an open-source review gate for AI-written code. Here is the reasoning behind it, including where it falls short.
Three problems with self-review
1. Shared blind spots. A model that wrote a bug usually believes the bug is correct. Reviewers from other providers were trained on different data and fail in different ways, so they catch different things. Independence is the point.
2. An opinion is not a gate. "LGTM" from a model is text. Nothing stops a flaky or flattering reviewer from waving a change through. A gate needs a rule: structured findings go in, a verdict comes out, and the same findings always give the same verdict.
3. Claims without evidence. Models invent problems and invent fixes. If a finding has to quote the diff verbatim, you can check that quote with plain string matching. A finding that cannot be tied to the actual code should go to a human, not silently block or silently pass.
How CodeReview works
builder --diff--> deterministic checks --> reviewer A (correctness/security)
(secrets, injection, |
data-loss, your tests) v
reviewer B (operations/reliability)
|
gate <-----------------+
PASS / BLOCKED / INCONCLUSIVE
- A panel of models from different providers (OpenAI, Gemini, Anthropic, DeepSeek and others, or any OpenAI-compatible endpoint) reviews the diff.
- Findings are merged across reviewers. Agreement raises confidence but never lowers severity.
- A fixed rule decides: PASS, BLOCKED, or INCONCLUSIVE. The builder cannot approve its own work.
- A blocker raised by one vendor family is put to a reviewer from another family. A refutation only counts if it carries a validated quote.
- Your tests, lint and static analysis run in a sandbox and the results are stored with hashes, so the verdict does not rest on what a model claims.
- Everything is recorded: failed providers, fallback seats, degraded runs. Nothing is quietly swapped.
It ships as a CLI and an MCP server, so your coding agent can submit its own work to the gate before merge.
pip install codereview-loop
export GEMINI_API_KEY=...
export OPENAI_API_KEY=...
codereview --repo . --staged --provider gemini --provider openai
echo $? # 0 = PASS, 1 = BLOCKED, 2 = INCONCLUSIVE
You bring your own keys and pick your own models. Your code goes to the providers you chose and nowhere else.
The honest numbers
The repo ships a labelled benchmark corpus (36 cases, public and holdout splits) and the harness to score any panel. The headline metric is the escaped-defect rate: defects the gate would have shipped.
The default strict profile caught all 7 of 7 seeded defects in registered confirmation testing. That is a small sample: the 95% interval is [0.646, 1.000]. It also blocked 32 of 34 clean changes (95% interval [0.809, 0.984]), and that registered confirmation failed its clean-change threshold. That is a real cost. Strict is for code you cannot afford to get wrong, and it has a documented waiver path. A balanced profile exists, and an opt-in corroborated profile failed its registered confirmation, so it is marked dev-only. The record is in the repo under bench/generation-v2/RESULTS-2026-11-05.md.
I would rather publish that trade-off than a flattering number. If you work on solo or small-team projects, the false-positive rate is the thing I most want feedback on.
Where it fits
- Solo developers and small teams shipping code that an agent wrote.
- A pre-merge step your agent calls through MCP.
- A GitHub PR reviewer:
--postadds the report as a PR review comment (it never auto-approves) and sets a commit status. - SARIF export, so findings show up in GitHub code scanning.
Try it
- Repo: https://github.com/PHPatch/codereview
- PyPI:
pip install codereview-loop - MCP registry:
io.github.PHPatch/codereview - License: MIT
If you try it on a real change, I would like to hear what it blocked that it should not have, and what it let through. Open an issue or leave a comment below.
Disclosure: this article was written with AI assistance and reviewed before publishing. The benchmark figures come from the project's own repo.
Top comments (0)