TL;DR #
We built an automated code review and approval agent that now approves over 78% of PRs merged in Fin’s core product repos, with no additional human approval. Since the rollout in April 2026, our monthly PR volume has doubled, while the rate of “bad” changes (PRs that caused a problem in production) fell 3.5x (1.7x fewer in absolute terms) and the revert rate more than halved (the number of reverts stayed flat) – all while reinforcing our culture of shipping fast in small, safe increments. These are observational before/after numbers, not a controlled experiment. This post covers how it works, how we iterate on it, why an agent that approves PRs needs a higher bar than one that only reviews them (precision matters along with recall), and the socio-technical side effects of putting an ogre in our CI/CD.
Motivation #
In early 2025, we started a deliberate push to modernize our software development lifecycle with AI automation (we published our progress so far here). As our PR throughput went up, code review quickly became the bottleneck. AI-generated PRs were larger and noisier. As a result, our most tenured engineers had to spend even more time on code reviews just to protect the quality of the codebase.
We strongly believe code written by AI agents has to be validated by an independent AI as well, so we built an LLM-based code review and approval agent designed to review code the way our senior engineers would. To push ourselves, we set an ambitious target: get at least 50% of our PRs approved by the agent. Staying compliant with all our existing frameworks was non-negotiable – you can read more about it in our earlier blog post.
Architecture #
Review steps
Our code review agent is composed of multiple steps simulating the process of reviewing a PR from different angles:
- Quality of the problem statement: What is the customer problem we are going after in this PR and why? We don’t need a plain-language narration of the diff. We want to preserve the high-level intent behind the change instead.
- Alignment of the problem statement and the diff: Does the diff address the problem as stated or does it accidentally increase the scope with unrelated changes?
- Logical correctness: Are there any bugs in the code? Will it conflict with existing code? Does it make sense logically?
- Expert guidance review : Does the diff adhere to all the patterns and best practices codified by our experts in the agent skills? Skills cover specific areas of the product as well as cross-cutting concerns like database migrations, our front-end library stack, observability, security, etc.
- Safety: No amount of code review can surface the unknown unknowns. Production is the only objective reality, and this sub-agent’s job is to flag risky changes that can’t be auto-approved, forcing a human reviewer to eyeball them before they hit real customers. Every repo has its own safety criteria that spell out what types of changes should never be auto-approved (e.g. changes to critical data handling logic). On top of that, certain file paths are never auto-approved, regardless of what the agent thinks (e.g. framework config).
- Size gate: The agent approves changes only under a certain size. The current LoC limit for main product repos is 150 lines (additions + deletions). Our culture of safe shipping is built around shipping fast in small increments, de-risking every change in production. Our agent is reinforcing this culture by incentivizing people to split PRs into smaller pieces, with fast agent approval being a carrot on a stick.
Implementation
Our agent reviews a PR after every commit. A GitHub webhook triggers a container that runs a Python script. The first step is deterministic preparation: we fetch everything the agent needs and store it on the container’s filesystem. That includes PR data (title, description, diff), the codebase checked out at the PR’s head commit, a snapshot of live feature flags, and the expert code review skills.
With the input package ready, we kick off the LLM calls. Logical correctness, expert guidance review and safety are agentic harness runs (e.g. Codex or Claude Agent SDK). All the steps run in parallel, and once they finish, deterministic code sets the final verdict (approve/reject) and a single LLM call summarizes the findings. Every step blocks approval – a PR needs a ✅ from all of them and has to fit under the LoC limit to get an approval.
The agent writes a JSON file with all the output and the verdict. We keep that file on S3 for audit, observability, etc. Deterministic code then produces the human-readable artifacts on GitHub: the approval (if granted) and review comments. The human-visible summary is short, while the “wall of text” version is collapsed by default (it is mostly for the agents):
Effectively, the agent is a “pure function” (minus the LLM non-determinism), receiving an input state (a JSON file plus files on the filesystem) and outputting another JSON file. Every agentic call is limited to simple read-only tools (e.g. Grep, Read) and has no network access. Hence, running it on a historical PR is easy – we only need to pass the same input package. That is what makes backtesting possible (more on that later). The downside is the lack of run-time context: anything the agent might need has to be fetched upfront and included in the input.
Logical correctness sub-agent
This sub-agent deserves a separate section as our engineers value its findings the most. But it is also the most problematic one, as its false positives sometimes make the agent frustrating to deal with (more on that in the socio-technical outcomes section). It is an agentic Codex call with a system prompt aimed at finding arbitrary issues in the code. Based on our backtests, GPT models are the best at finding bugs. Moreover, most of our code is written by Claude, so a review from a different model family makes a lot of sense – it is less likely to share the blind spots of the model that wrote the code.
Our first version was a single turn asking the agent to find bugs in the diff. It scored well on evals but wasn’t great at finding multiple issues at once when several were present in the same PR. We tried to force the agent to find more issues with a prompt change, but it wasn’t effective. Our intuition here is that when an agent finds 1–2 glaring issues, it becomes anchored on them, unwilling to find more bugs regardless of how hard we prompt it to go deeper. Then we tried asking it for more bugs in subsequent turns of the same session. Eventually, we settled on up to three fresh agentic calls one after the other, where the user prompt contains the findings identified in the previous run: We identified X, Y, Z issues already. Try to find something else (simplified prompt just to get the idea):
Due to increased cost and latency, we do not run logical correctness steps in this “thorough” multi-pass mode all the time – only for the first review to surface non-obvious issues lurking in the deep.
Socio-technical outcomes #
Early on, building a code review agent was only part of the goal – we wanted to change how Fin’s R&D works as a socio-technical system. We wanted to preserve the culture of safe shipping while increasing our PR throughput. That meant we wanted to continue encouraging people to ship in small increments. With AI models getting better, it became easy to generate code and the temptation to just ship it all to production in one go is strong. We wanted to counter that with fast agentic review and approval, but only for small changes, fighting back against AI slop. Any cultural change requires humans to participate – we wanted our engineers to pay attention to our agentic code reviews. To cut through the noise of low-quality AI automation and inevitable human fatigue, we named our agent Shrek. We wanted Shrek to stand out from the pack and be a little “out there, in your face” to draw human attention in a funny, engaging way.
Quickly enough, we observed the first-order effects of the agent. Shrek gained popularity thanks to the real bugs it was catching and the time it was saving on reviews and approvals. But it also gained a personality as a grumpy, complaining ogre from the swamp, a living creature people would joke about in person and on Slack. This was exactly the outcome we were hoping for – engineers engaging with the agent and paying attention, effectively making Shrek part of the team. Moreover, people started building skills for their agents to interact with Shrek, read and address its findings, and, in particular, keep PRs small to have a chance of approval!
However, as with any complex socio-technical system, we observed unexpected second-order effects. It became de facto required to get a PR to a “terminal” state with Shrek before presenting it for human review. Some PRs couldn’t fit under the LoC limit or were flagged as risky, requiring a human review. It became an implicit expectation to make sure all other steps gave ✅ before asking another engineer to review the code. Here’s an example of a “terminal” PR flagged as a risky change requiring human review:
Unfortunately, as with any AI tooling, not all of Shrek’s findings were real bugs. Some of them were issues unlikely to happen in the real world, nitpicks, or outright plausible-looking hallucinations. Any false positive like that would make it harder to get a PR to a terminal state, creating friction and frustration for engineers and agents arguing with Shrek on their behalf. It became clear that what matters is not a single review but the whole process of getting a PR merged: fixing the real findings and pushing back on nits and hallucinations. Here’s an example of a PR where the author struggled to appease Shrek, resulting in many reviews (Shrek marks the previous review as outdated when it posts a fresh one):
An agent’s ability to find real issues, while impressive, doesn’t mean much if it also produces a barrage of false positives. A noisy reviewer is annoying, but a noisy approver blocks every PR. Code review agents that also approve PRs have to be optimized for precision as much as recall.
To save human attention, we encourage our engineers to have their agents drive PRs to a terminal state with Shrek. We built a set of in-house skills for that, notably /donkey, which reads Shrek’s verdict and findings over our MCP server and helps the author’s agent address them autonomously. This doesn’t take the human out of the loop though – the author is still on the hook for the PR and responsible for shipping it safely.
How we iterate #
Backtests
From day 1, we started working on our agent evaluation system to iterate on Shrek by running it against historical PRs and tuning the prompts. To do so, we roll back the PR state (including title and description) to the point where it still had a known issue Shrek should catch, rather than using the final diff. Since everything the agent needs is in its input, we just need to provide the same input and check out the codebase on the filesystem at the commit of interest. Every production Shrek run preserves both input and output artifacts – so we know exactly what the PR state was at any point in time. In backtests, Shrek is executed in “silent” mode – the only difference is that at the end we don’t publish anything to GitHub. Instead we invoke an LLM judge that semantically compares the output to established ground truth (e.g. expected issues, validity of the problem statement, etc.). To curate ground truth, we built a web app that renders the PR state at any point in time in its history and allows humans (or agents!) to record expected verdicts per step, true positives (issues/bugs in the PR), and false positives (non-issues Shrek is not supposed to surface):
Sourcing PRs for backtesting is non-trivial. Early on we curated ground truth on several dozen PRs – that became our “golden” dataset. But different types of changes need different datasets, so a lot of the time we source a fresh historical set of PRs relevant to a specific change we want to backtest. PRs that were reverted and/or rolled back in production are a great source of good candidates with real issues. Sourcing false positives is trickier as every model produces different classes of them, so a dataset built from model X’s false positives can make model Y look cleaner while missing the new noise it adds. That said, measuring precision in backtests is still useful to filter out clear degradations like in this backtest comparing two versions of the same OpenAI model, GPT Sol 6.1 (baseline) and 6.2 (treatment). Here the newer model surprisingly performed worse on precision while being clearly better on recall:
Our domain experts use the same engine to backtest their skills before we enable them in Shrek: we generate every inline comment Shrek would have left on historical PRs, so they can eyeball them and tune their prompts before confusing our engineers with subpar review comments.
A/B tests
In late June, we had a painful quality degradation that slipped past our recall-focused backtests. We downgraded the logical correctness model from GPT-5.5 to the cheaper GPT-5.4, which found real issues at the same rate but was 26% noisier. For a whole week, our engineers suffered until we reverted the model. That’s when we realized that evals are not enough. So we introduced A/B testing, and from then on no prompt or model change gets rolled out without an A/B test splitting our PR traffic equally between control and treatment arms.
To enable A/B tests, we established a large set of engineer-centric signals. We measure most of them at the PR level rather than per individual review. Here are some of the signals we monitor and A/B test on:
-
Latency and cycles: Ideally, every PR needs up to 2 reviews that are blazingly fast. We make sure our changes do not degrade individual review speed or increase the total number of reviews per PR.
-
Rate of PRs merged despite a logical correctness rejection: As people/agents work really hard to get approval from Shrek, a PR merging despite Shrek rejecting it often points to a false positive. It can also be an accepted risk or a real issue the human missed, so we audit samples of these PRs.
-
Rate of PRs where Shrek changed its verdict on the same diff: We can’t get rid of intrinsic LLM non-determinism, but we do want to know when Shrek flips its opinion on the same code.
-
Issue drip rate: The rate of PRs where Shrek surfaced several issues over multiple reviews, even though all the issues were present in the original diff and could have been surfaced straight away.
-
Fix/revert rate: PRs where Shrek surfaced an issue in the area of the code that was just fixed by the previous commit in response to another issue Shrek surfaced in that area. This one catches the “whack-a-mole” case where Shrek and the author get into a loop on the same piece of code, fixing/undoing things over and over again. Most of these signals fell sharply in Sep/Oct after a successful A/B test where we rolled out a new prompt and model for our logical correctness sub-agent.
-
Lines of code added: Another second-order effect is that PRs often increase in size as the author addresses Shrek’s findings and gets to a terminal state. In some pathological cases, it can result in PR bloat when Shrek surfaces many blocking nits or plausible but unlikely-to-happen issues that the author rushes to address just to get an approval.
-
Cost: Obviously our budget is limited, so we have to carefully observe changes to the cost per PR in every A/B test. Calculating the cost per PR, however, is non-trivial – we’ll cover this in the next section.
Cost #
Naively, one might focus on cost per review as the main unit of cost. However, optimizing cost per review can result in unexpected cost increases. Downgrading the models or simplifying the architecture might result in fewer good findings or more false positives, with PRs needing more review cycles or re-work later on. Moreover, LLM tokens spent by Shrek are only the visible part of the actual cost. Our engineers also spend tokens in their agent sessions while arguing with Shrek and addressing its findings – we consider that an indirect cost of Shrek. We built a deterministic script that attributes the token usage of agent session turns to the PR they were spent on. The token cost of those session turns is added on a per-PR basis to the LLM cost of Shrek reviews – this constitutes the total cost per PR:
For a long time, the cost of session tokens spent iterating with Shrek dominated the cost of LLM calls in Shrek. That created an interesting incentive to optimize for reducing the overall number of reviews per PR rather than the direct cost of the review itself. As we improved the precision of logical correctness and drove the reviews per PR down, the indirect session cost went down and is now roughly the same as the direct cost. Overall any change is a careful balance between quality (good findings/false positives) and total cost per PR.
Impact #
As we rolled out Shrek at Fin, we noticed a few positive changes. Everything in this section is observational – we obviously can’t claim causation, as better models and new ways of working were rolling out all through 2026 in parallel with Shrek adoption. But the time correlation makes us strongly believe that Shrek not only became a critical lever to increase our throughput but indeed positively contributed to our safety.
Shrek started approving PRs in April 2026, and by November we’ve reached 78% on our core product repos:
We track every “bad” change – a merged PR that caused a problem in production, from a minor bug that never reached customers to a declared incident. From November 2025 to April 2026, 0.82% of merged PRs turned out to be “bad” changes. From June to October 2026, it went down to 0.23%, while the number of merged PRs doubled (5.1k → 10.5k per month). That is 3.5x fewer bad changes per merged PR and ~1.7x fewer in absolute terms:
The revert rate went down as well. For PRs under the LoC cap, it was 1.3–2.1% for over a year. Since June 2026 it has been ~0.6%. The number of reverts per month stayed flat, while the overall number of PRs more than doubled.
One change we can attribute to Shrek directly is PR size. In 2026, 5.3% of merged PRs landed at 141–150 changed lines, versus only 1.6% at 151–160, a difference of 3.3x. For comparison, in 2025 there was only a difference of 1.4x. Our engineers (or agents working on their behalf) are deliberately splitting their work into smaller chunks to benefit from approvals, helping us continue shipping in small increments. One might suspect people just squeeze PRs under the cap to get an approval at the cost of quality, but we don’t see that. PRs landing just under the cap are reverted no more often than smaller ones (0.44% for 141–150 lines vs 0.54% for 101–140 lines, June to October 2026).
Our time to merge held up under the load of increased throughput. The median time from the first commit to merge for PRs under the LoC limit peaked at 2.4 hours in May 2026 and is 1.2 hours now:
Takeaways #
Over the last year we’ve learned what it really takes to build a high-quality code review agent. Here are some of the most important insights:
- Optimize for precision as much as recall: Every false positive finding results in friction and frustration. PRs merged while the agent is still blocking are the quickest way to spot them.
- Measure the PR, not the review: Reviews per PR, issue drip, and fix/revert loops show the friction that per-review metrics miss.
- Count the author’s tokens too: For a long time the agent sessions arguing with Shrek cost us more than Shrek itself.
- Don’t stop at backtests: They are great for recall but less reliable for precision, as a dataset of false positives only tells you about the model that produced them. A/B tests on live traffic close that gap.
And last but not least: your internal engineering culture is by far the most important thing – whatever tooling or agents you build amplify the culture you already have, for better or worse. Every good tool that gets enough usage creates strong incentives and ultimately results in second-order socio-technical side effects. You have to be constantly on the lookout for those!