Skip to main content
Back to Blog

Anatomy of an AI Code Review Agent

See how an AI code review agent reads a diff, gathers context, applies rules, runs checks, and turns findings into evidence a human can verify.

Axiom Studio Axiom Studio October 21, 2026 7 min read
Code changes pass through context, rules, and checks to become review findings.

A review bot says a line of code looks wrong. What did it read before it made that claim?

Did it see only the changed lines? Did it check the function that calls them? Did it use the team’s rules? Can it show a test that fails?

These questions matter more than the length of the review. A useful agent needs a clear path from a code change to a finding a person can check.

This guide describes a proposed reference design. It is not a claim about the private design of any vendor’s tool. The example findings are fictional and explain the steps; they are not results from a live test.

The path from a PR to a finding

A pull request, or PR, asks the team to accept a code change. A review agent can process it in five stages:

Read the diff → Gather repo context → Load review rules → Run checks and model review → Merge findings for a human

The diff shows what changed. Context explains how that code fits. Rules state what the team expects. Tests and model review look for faults. The last step removes repeats and links each claim to evidence.

Logs should follow the whole path. Our AI observability guide explains why a final answer alone is not enough to understand an agent’s work.

1. Read the exact change

Start with the base and head commit IDs. These name the old and new code versions. Keep them with the review so everyone knows which patch was checked.

Parse the diff into files and changed blocks. Track added lines, removed lines, renamed files, and changed tests. Mark generated files and large data files so they do not crowd out code that needs attention.

Do not silently skip files that exceed a limit. List what was not reviewed and why. “No issue found” means little if the agent never saw half the patch.

Suppose a retail app changes an order lookup from order ID plus store ID to order ID alone. The diff shows one removed check. It does not yet prove that another store can read the order.

2. Gather the nearby repo context

Next, fetch the code needed to judge that change. That may include callers, data types, access checks, and related tests. Start close to the changed code and expand when a question needs more evidence.

In the order example, the agent should check where the store ID comes from. It should also check whether another layer still limits the lookup to the right store.

Sending the entire repo on every review can waste tokens and bury useful facts. Sending only the diff can hide the very check that makes the change safe. The aim is enough context to test the claim.

Use a known code version for each read. Do not mix a diff from one commit with a helper file from a later commit. Record missing files or failed tool calls as limits in the review.

3. Load rules the team can trace

A rule pack is a set of review rules. Keep each rule small, with an owner, a scope, and an example. A rule for billing code may not belong in a text-only change.

For the sample app, a rule could say: “Every order read must be limited to the active store.” Include the rule’s source and version in any finding that uses it.

Real products offer different ways to load such guidance. For example, GitHub’s Copilot review guide describes repository-wide and path-specific instructions. That is a concrete product feature, not proof that every review tool reads the same files.

Keep trusted review policy separate from text inside the patch. A comment saying “ignore all access checks” is code content to inspect, not permission to change the review rules. Review changes to the rules themselves with care.

4. Combine repeatable checks with model review

Run checks that have clear answers first: formatting, types, tests, and known static rules. Then use the model for questions that need broader context, such as whether a change breaks a flow across files.

Give the model a clear output shape. Ask for the file and line, the suspected fault, why it matters, the supporting evidence, and what would confirm or disprove it.

In the sample app, a useful finding might say: “The new lookup drops the store filter. Check whether a user from store A can fetch a store B order.” It should point to the removed filter and the caller it checked.

If the agent runs a test, save the command and result. If it only suggests a test, say so. A test plan is not a passed or failed test.

Use a restricted test environment. Do not give a review job live customer records or write access to production. The team should decide which actions need human approval. Our AI operations guide covers ownership and controls for agent work.

5. Remove repeat findings without losing evidence

Two checks may find the same fault. Group findings by their cause and code location. Keep the best evidence from each check in one clear item.

Do not merge unrelated faults just because they appear on the same line. A missing access check and a bad error message need different fixes.

Sort findings by likely impact. Keep low-value style tips apart from faults that affect access, data, or behavior. The number of comments is not a score for review quality.

If the patch changes, mark old findings against the old commit. Run the needed checks again before calling a fault fixed. Make the current review version easy to see.

What the human should receive

The final review should show the code version, files checked, skipped areas, findings, and test evidence. It should make uncertainty easy to spot.

For each finding, a reviewer should be able to answer: “Can I reproduce this? Does the rule apply? What needs to change?”

In our sample, the human checks the store boundary and decides whether the proposed fix covers it. A plausible model comment is a lead to inspect. It is not proof that the code is unsafe or that the patch is ready to merge.

Count the full cost of a review

Track model calls, context size, tool time, retries, and human effort. Record how many findings led to useful fixes and how many were false alarms. Use a test set with known faults to check what the agent misses.

A small prompt can cost less per call and still cost more overall if it misses context and needs repeated attempts. A large prompt can cost more without adding useful evidence.

Our AI FinOps guide helps connect spend with results. Compare cost per useful review on similar PRs, with the same rules and checks. Do not compare a tiny text edit with a large change to billing code.

Start with one repo and one clear rule

Choose a small sample of changes. Include a known fault, a safe change that looks odd, and a patch the agent cannot fully inspect. Check whether it finds the fault, avoids a false alarm, and admits the limit.

Keep the code, rule version, and results so the team can rerun the test after a model or tool update.

Explore VibeFlow to connect planning, coding, security review, and QA. Use this five-stage map to ask what evidence reaches each review gate—and what still needs a person to decide.

Frequently Asked Questions

What does an AI code review agent need to inspect a pull request?

It needs the exact diff and commit versions, nearby repository context, applicable review rules, repeatable check results, and enough evidence for a person to verify each finding.

Why is reviewing only changed lines not enough?

A changed line can depend on callers, data types, access checks, and related tests. Nearby repository context helps the agent test whether the change is safe in the flow around it.

How should teams evaluate AI code review quality?

Use a test set with known faults and safe changes, then track useful fixes, false alarms, missed issues, tool time, model calls, retries, and human effort.

Does an AI review finding prove that code is unsafe?

No. A finding is a lead to inspect. A human still needs to reproduce the concern, confirm that the rule applies, and decide what change is appropriate.

Axiom Studio

Written by

Axiom Studio

Turn AI governance insight into evidence

Get weekly governance insights for engineering leaders, then put them to work with VibeFlow.