AI Code Review
Building a Principal Engineer Compatible With Every AI Agent

There’s a special kind of chaos that happens when you ask a frontier model to review code. It’s not wrong in the way a compiler is wrong. It’s worse. It’s confidently helpful. It’s a well-structured review that routinely cites no evidence, invents intent, overlooks the one change that will page you at 2:07 AM, and then politely suggests you add more comments.
I got tired of that.
So I built a tool that generates what I kept wishing the model already had: the same contextual awareness a senior engineer builds in their head before they say anything out loud. Then I made it pipeable, because of course I did.
The result is an open-source tool I call AI Code Review. It doesn’t review the code by itself. It assembles review packets: high-fidelity, security-aware prompt inputs that let Claude Code, Codex CLI, and Gemini do what they’re actually good at when you stop starving them of reality, and give them an accurate and consistent foundation to work from.
And yes, some agents (hint: Gemini CLI) can be overly literal. So I stopped hoping it would infer what I meant and started writing prompts that establish a clear contract for how the agent will perform.
The Problem
The real problem here wasn’t asking an AI to review code, the problem was context collapse.
Most AI review workflows are either vibes or a copy/paste of a generic “review” prompt. Typically this will cause the agent to diff the code changes, then analyze them. While a diff is necessary, it’s not sufficient. Diffs don’t carry the invariants, the patterns, the “we do it this way because prod taught us pain,” the tests that define expected behavior, the runtime constraints, the security posture, the deployment shape, or the parts of the codebase that quietly turn your change into a distributed system.
A good reviewer doesn’t just read changes. They load a mental model. They scan the blast radius. They sanity-check assumptions against the codebase. They look for tests and configs. They read the surrounding files. They prove, not guess.
So I built a tool that forces the agent to do the same.
Review Packets
The core idea is simple: if you want a professional-quality code review, you need to give the reviewer professional-quality context. Instead of preparing a light snack for the agent, I wanted to give it a healthy meal.
AI Code Review generates a packet that includes the diff, but also compresses structure in a token-efficient way. In Python it uses AST extraction to capture signatures and docstrings without paying for implementation bodies. In JS/TS it uses heuristic parsing, with optional tree-sitter support when you want higher fidelity. It flags sensitive paths. It redacts secrets before anything ever leaves your machine. It chunks large changesets so you don’t get an “I stopped reading at token 7,891” non-review.
Then it wraps all of that in a SYSTEM prompt that behaves like a principal engineer who’s seen too many postmortems and has developed a healthy allergy to hallucination.
The Evidence Gate
Models will happily output a gorgeous review with zero grounding unless you force them to pay rent.
So the SYSTEM prompt includes an Evidence Requirement with explicit citation formats. If the packet provides line annotations, the agent must cite them. If it doesn’t, it must cite diff hunks. If it wants to reference anything outside the packet, it must actually open files in the repo and cite those reads.
That last part matters. A lot.
Because once you tell the agent “you have full repo access, and you’re required to use it when the packet isn’t enough,” you stop getting speculative advice and start getting the kind of review that says: I checked the lifecycle in the client, I inspected the app config, I traced the call sites, and here’s the exact line where your update handler quietly became O(N) per change.
Which is precisely the kind of feedback that prevents your UI from turning into a strobe light when the room gets busy.
Taking Agents from Literal to Lethal
Here’s the moment that made me grin like an idiot at my terminal.
I ran the AI code review against a real commit and piped it straight into Gemini CLI. I wasn’t looking for eloquence. I was looking for proof that the agent would actually do the job: read context, cite evidence, and call out real risk.
It did.
It identified a performance blocker with a concrete, repo-cited snippet. It flagged missing tests for complex synchronization logic. It found an architectural hazard involving a static singleton dependency that would make isolation testing miserable. It asked the right questions about serialization intent. It even annotated rollout risks and re-render loop monitoring.
This wasn’t the usual “seems good, consider adding docs” fluff. This was a review that reads like someone who actually ships.
And the funny part is, nothing magical happened. The model didn’t get smarter. The prompt got stricter, the context got richer, and the workflow got closer to how real engineers reason.
That’s the entire thesis of agentic tooling in a sentence: intelligence is not the bottleneck, integration is.
Review Orchestrator, not a Reviewer
AI Code Review isn’t trying to replace human judgment. It’s trying to standardize the inputs that make judgment possible, whether the reviewer is human or silicon.
If you’ve ever onboarded a new teammate and watched them do their first review, you’ve seen the same pattern. They comment on surface-level issues because they don’t yet know what’s important. They miss the landmines because the landmines live in context. They can’t cite the real constraints because they haven’t found them.
A review packet is onboarding, compressed.
It gives the agent enough architectural awareness to be useful, and enough procedural discipline to be safe.
Why Open Source?
Because this is glue code the ecosystem needs.
We’re all building with multiple agents now. Claude Code is great at a certain kind of reasoning. Codex CLI is great at another. Gemini has its own strengths and its own literalism. The win isn’t picking one. The win is having a consistent, high-quality input format you can pipe into any of them and get review output that’s grounded, defensible, and actionable.
Also, selfishly, I want the community to break it. If you can find a way for a model to sneak a hallucination past an evidence contract, I want to know. That’s how this becomes a real tool instead of a clever demo.
The project is MIT licensed, because friction is the enemy of adoption.
Give it a Try
If you want to feel the difference immediately, run it against a non-trivial commit and pipe the prompt into the agent you already use.
# Generate a review prompt for the last commit
ai_review prompt /path/to/repo -base HEAD~1 -head HEAD -max-diff-lines 2000 -read-only | gemini
# Working tree review, i.e. uncommitted changes
ai_review prompt /path/to/repo -mode working -read-only | gemini
# Chunk large diffs for token limits
ai_review prompt /path/to/repo -base main -head feature-branch -chunked -read-only | gemini
And if you’re the type of person who reads README files like they’re product strategy, here’s the repo:
https://github.com/josh-english-2k18/ai-code-review
The Punchline
The best AI code review isn’t the one with the fanciest model. It’s the one that refuses to speak without evidence, knows how to interrogate the codebase when it’s missing context, and treats runtime reality as a first-class input.
In other words, it’s the one that behaves like a principal engineer.
So I built one you can pipe into your terminal.
Josh English is a member of the Applied AI Association (AAIA) gaming council, and can be followed on X (@JoshSeriesAI)