# Your AI Code Reviewer Doesn't Know Your Codebase. Give It a Rulebook.

> Source: <https://oioannou.com/blog/automated-code-review/>
> Published: 2026-12-02 00:00:00+00:00

**Recommendation:** Write codebase-specific MUST/SHOULD review rules into a rulebook your AI reviewer loads on every pull request, and convert each bug the reviewer misses into a new rule, as Bold.org did after a sensitive-data leak passed two reviewers.
More in the playbook "Working with AI coding agents": <https://wpnews.pro/playbooks/coding-agents>

# Your AI Code Reviewer Doesn't Know Your Codebase. Give It a Rulebook.

In late November, a pull request at Bold.org almost exposed support staff’s internal notes to students. OpenAI’s Codex reviewer and our team’s Sherlog review both passed it. Sherlog is the [in-house AI](https://oioannou.com/blog/internal-company-agent-lessons/) everyone at Bold.org works with, and it also reviews every pull request. A second Sherlog pass I run on [the PRs I review](https://oioannou.com/blog/ai-engineering-setup-15-months-later/) flagged it, and I confirmed it by reading the code.

The next day it became a rule in the codex, the rulebook Sherlog reviews against: when a change writes sensitive data into existing storage, check every reader of it. Now every Sherlog review checks for it. That loop, catching what the reviewers miss and turning it into rules, is what this post is about.

An off-the-shelf reviewer can tell whether a change looks correct. It doesn’t know our quirks, and it doesn’t notice when a “correct” suggestion is about to turn the codebase into [slop](https://oioannou.com/blog/i-still-read-the-code/). Below: what’s in the rulebook, how a review runs, and why I still approve every change to it myself.

## Why an off-the-shelf reviewer is not enough

We tried CodeRabbit and similar tools. They check whether code is correct in general. OpenAI’s Codex reviewer goes further and checks the impact of a change on existing code. None of them know our rules, and that is where they fall short.

An off-the-shelf reviewer fails in two ways.

The first is bugs it misses. The leak above is one. Another was a production bug where a mutation invalidated a cache key that no live query uses, so stale recommendations stayed on screen. A generic “did you invalidate the cache?” check passes that. You only see both if you know how this codebase works.

The second is code it makes worse. In late November, off-the-shelf reviewers suggested locks, retries, fallbacks and version pins, and I removed them. Each one made sense on its own. None of them were needed, and the next agent would have read them as requirements.

## So we wrote the rules down

The codex is the list of review rules for our codebase that Sherlog loads on every review. Each rule is either MUST or SHOULD. A MUST rule is one we would want fixed before merge. A SHOULD rule is a default we want followed. As of late November 2026 there are 35 rules, 25 MUST and 10 SHOULD.

Most of them are about how this codebase is built, down to details a reviewer would have to be told. A few examples, some trimmed:

- **`BOLD-LEDGER-001` Ledger writes (MUST).** Anything that credits or debits points, balances or payouts checks the balance, the cap and eligibility in the same transaction as the write, carries a durable idempotency key, and reverses the debit if the downstream transfer fails.
- **`BOLD-DATA-006` Migrations and rollout (MUST).** Migrations run before the new backend rolls out. A schema change must not break the version still serving (e.g. new NOT NULL columns without a default, newly required columns old code doesn’t write). Existing rows must read correctly under the new defaults.
- **`BOLD-MOBILE-001` Installed mobile apps (MUST).** Backend contracts, enum changes, deep links, and payload changes consumed by mobile must remain compatible with installed supported app versions. Normalize legacy values at the boundary instead of immediately rejecting payloads that supported clients can still send.
- **`BOLD-ARCH-004` Feature gating (MUST).** Choose the feature-gating mechanism according to experimentation, access, and operational requirements. Experiments requiring cohort analysis or experiment attribution must use PostHog. Features restricted to specific users that also affect backend behavior must use`FeatureService` . When both are needed, keep their responsibilities explicit: experiment assignment does not replace backend feature access.
- **`BOLD-ARCH-001` Simplicity (SHOULD).** Use the simplest design that fits the requirements and the patterns already around it. No abstractions or defensive branches without a real need. Refactors that are only a preference are not findings.

The sensitive-data rule from the opening is in there, and so is the cache rule, which now asks whether a live query actually uses the key. The review instructions around the codex also changed: a suggested fix must be the smallest change that solves the problem. The file is JSON with a schema, and every rule has an owner and a revision.

Cloudflare describes the same idea at a much larger scale in [How Cloudflare enforces engineering standards using AI](https://blog.cloudflare.com/engineering-standards-enforcement/). Its standards are RFCs with MUST and SHOULD requirements and an owner for each domain, and its AI code reviewer checks merge requests against them. This is what that looks like for a small team.

I wish more of these rules could be enforced in code through linting, but I have not found a way to do that. They need judgment, like whether a fix is the smallest one that works, which a lint rule cannot express, so for now the reviewer enforces them.

## How a review runs

Every pull request that is ready for review goes through Sherlog. The worker checks out the pull request, loads the review skill and the whole codex, and reads the diff along with the code around it. It only reads. It cannot install anything, run tests or change files.

The reviewer runs on Astra. I find it more thorough at review than Opus, and most of the team is using Opus daily, so we also get a different model’s eyes on our PRs.

The result comes back as a summary, inline comments, and the IDs of the rules each comment is based on. Those IDs let us see which rule fired, which one is noisy, and which one needs a revision. Sherlog posts it as a normal GitHub review, and it is always a comment. It never approves or requests changes, so it cannot block a merge. People decide, even when the finding is a MUST.

Sherlog has reviewed 778 pull requests since June, nearly all of them since August, when the codex landed.

## Keeping the rules good

The codex does not rewrite itself, and that is on purpose.

Until the rules are fine-tuned, there are a lot of false positives, and a lot of findings that are simply not relevant. So the rules need regular tuning.

Every Thursday a research pass reads the week’s Sherlog reviews, every other reviewer’s comments on our PRs, recent bug tickets and their fix PRs, and how I reacted to the reviews. It proposes numbered changes, each with evidence and a confidence level, and it is told to avoid overengineering.

I approve or reject each proposal. In the late November pass there were 7 proposals, and I approved 4. Only the approved ones become a codex PR, with revisions bumped, the schema validated and tests run. It merges like any other code, and the change gets announced to engineering. Of the 35 rules, 12 have already been revised at least once.

A system that updated itself from its own reviews would have been happy to turn “add retries” into a rule. That is exactly the judgment I am trying to correct. So I keep the approval step.

## How we started

1. I had an agent collect the pull requests merged in a recent window of days, along with the comments human reviewers left on them. It checked which comments were generic and suggested a first codex from the rest. I also gave it the recent production bugs and the fixes that came with them.
2. I read every suggested rule and added the ones I already knew mattered in our codebase.
3. I had an agent pull each PR as a full worktree, so it reviewed the whole codebase and not only the diff, and I told it to [ignore the other reviewers](https://oioannou.com/blog/orpc-contract-migration-factory/) so it would not take shortcuts. It posted its review as comments. It did not approve or request changes, and it still does not.
4. I set up the weekly proposals and approvals described above in “Keeping the rules good”.
5. I iterated.

OpenAI’s Codex reviewer and other tools will often post the same finding as your own reviewer. That is fine: it is a cross-check, not wasted effort.

At the start it will probably be trigger-happy and annoy engineers. Keep iterating, and tell engineers to react to the comments. There is an adjustment period, but it is worth it.

## Where that leaves me

I am happy we caught the leak, and that the next one like it will be caught by the rule rather than by luck. I am also aware that the same kind of reviewer, left to its own taste, will keep adding locks and retries we do not need. So I still approve the rules our reviewer is allowed to follow, and I still reject a lot of what it wants to add. I have not found a way to skip that, and I am not sure I want to.

**A note on how this article was written:** AI helped me draft and revise this article, including a pass on structure and clarity. The experience, decisions and opinions are mine.
