Fighting Slop — Ankit Jain, Aviator
Read full transcript 23 segments
-
All right. So I will be sharing some of our battles with the code reviews in the last one year. But we also sell a tool that we ended up with. So please be suspicious of me. I'll start with this. Many of you already are familiar with latent space. I wrote an article for this in March, which is like 10 months ago. So like, you know, in AI years it's like 10 years. I talked about like how to kill code reviews. We talked about building multiple layers. I will not go too far into details. If you're interested, you can scan the QR code. But the reason I'm sharing this is a big part of what I'm sharing today is going to be some of the learnings in the last 10 months once beyond what we shared here. So the year we went 4x. So we are a very small team. We are nine engineers. A year ago we were merging about 100 PRs per week and now we are doing about 400.
-
So one of the main things which has changed, which everyone already is familiar with, we moved from human written code with AI assistance to now predominantly AI written code with human assistance. So let's start with the battle. So what did we try first? This is sort of like I'm guessing most of you are already using an AI reviewer. We started kind of like, you know, testing how the AI reviewers work. You know, you're seeing vast majority of the comments come from bots, some from humans. The reality is a lot of comments from bots we got were sort of like nice to have. But it did find bug, but whenever you find bug, you feel excited. It's like, okay, this is actually working. An interesting observation we had was once we started using AI reviewer, most of the comments that humans are providing are actually not about bugs or correctness. It's about decisions. Then our second one was, okay, let's just write specs, the spec driven development. This was back in January.
-
You know, we write the specs and then most of the code gets generated by AI. We just review the specs instead of the diffs. So it kind of like reduces creates one better proxy. The reality was when you're writing specs, there's a lot of assumptions you make. Eventually, when things get implemented, a lot of this gets stale. But the bigger issue is now if you stop reading the code, there are drifts that nobody flags. And because of this, we ended up going back to the reviews. The intent was written down, but nothing really checked whether we were actually still consistent with the spec. And then our third attempt. This was probably the most interesting and useful one. We actually created our own review skill. So instead of us doing a review after creating a pull request, we essentially had a skill which is like everyone go review your own code before you even submitted as a pull request. And we added hooks and stuff so it kind of like happened beforehand.
-
So we found better findings than the bot. Now because it's actually very contextual, we have added more context specific to our codebase into the skill. But the reality was we were still reading the diffs. But it was after the fact, which means obviously there were lesser bugs, there were lesser concerns. You can move a little bit faster, but we still are, you know, having to read the diff. And the other thing was any findings that the agent found in this review skill sort of like got lost with the sessions. We kind of like really never even back to it. So it was a better reviewer, but we were still reading the diffs. So but this kind of like provided us with a little bit of like, you know, sense of where we can go with this. But before we get into it, let's quickly talk about why do we even do code reviews today? This is a study done like back in 2013 by Microsoft. 44% of people asked why did they do code reviews? They said to find bugs. But only 14 % of analyzed comments actually were bugs.
-
So this 30 % gap is the real gap that we're going to talk about today. Code review is not about the code. It's not about finding bugs. It's for us to build mental models. Unless you're white coding a single project by yourself, please don't care. In that case, you don't even need a code review. But if you're working on teams, you want to build your mental models. You need to understand how things work. Code review is about knowledge sharing. It is about knowledge sharing. It's not about finding bugs. So human code reviews also find real issues. So they are still valuable. However, we are really really bad at it. If you think you are a really good reviewer, please go back and check how many times an incident happened because you missed something. And that's because beyond 400 lines, your quality of reviews drops significantly. And this is not me saying this is a study done back in 2006 long before AI became a thing.
-
And with AI, now we are generating every PR, a median PR is over 600 lines. So what does that mean for our AI quality? You know, even though we are reviewing code today, but are we really reviewing the code today? And the reason is diff was always a bad place to the review. You have one reviewer reading from memory one time. Diff only tells you what was changed, but never why. So what a review actually contains? This is sort of like another example where we provided I provided some reviews. This is I me reviewing PR our own and they were like half of them from the bot. As you can see, what we started doing was like let's try to categorize what kind of review comments do we make? Not all reviews are not all review comments are the same. There are bugs, some of them are noise, some of them are nice to have. But there are also rules kind of like, okay, this is what our code started standards are. How do we like you know enforce those standards? And there's also decisions which is like how do we really understand the concepts? Are we actually doing architectural conversations?
-
So in 14 threads eight were bug threads only one was real bug. Three were rules that we have also repeated in the past and two were actual decisions. So again there are two kind of reviews primarily. One is about the quality, the code quality which is like is it correct? Is it following our standards? And the second is decision which is an opinion of a developer. If you automate the entire review you miss the decision part entirely. Which brings us to our framework. Okay, so I'll share a little bit about you know how we think about reviews. Take it or leave it. Everything I share here you can actually do it yourself. You don't need to use Aviator or any other product for that. So it's a lot. We have six steps. It's like okay we're killing one thing and we're creating six. But hear me out. What we're trying to do here is like break it down into different parts of what a value review provides and build it back back up again.
-
So we first start with argue. Argue is now you have multiple coding agents arguing with each other. We have capture. By the way all of these things will go in detail so don't need to you know take too many notes. We have capture which is about like actually being able to capture what's going on in a session. Codify is about repeating capturing everything that can be automatically tech checked like linters but like smarter. Prove is like actually proving everything that the change is supposed to do is working. And debate is where humans participate the most which is like really seeing are we making the right decisions? Are we building the right thing? And own is the ownership you know models cannot really own anything so unfortunately humans will not still responsible on the line to when things go So, let's start with the argue. Let the agents argue before a PR exist. This is sort of like similar to some of the things I mentioned from my attempt three where we created a self-review skill.
-
Now, we argue with our authors agent. So, essentially we created a skill which works independently. You can also use a third-party model. You don't have to use the same model. But essentially what you're doing is creating this argument where a coding agent and a review agent are arguing with each other with different goals. And this goals part is important. This is why kind of like having two different agents is useful because now the goals is for coding agent to hold its ground versus the review agent to find defects. And this is the most important thing. Everything that they disagree about we should write it down. Today, so in this case here's what we disagreed about and sort of like we started writing it down. In this case you can see we're not just writing down the decisions, but we're also writing down what was decided. So, for instance, if there are things where we are saying this is an accepted risk, we won't fix it. And it's okay because agents will always go and try to fix everything. Sometimes you don't need to fix it because you don't need that complexity.
-
But there are also certain things where we say, oh, we'll actually follow up in a separate fix. All of this information today gets lost in your sessions. And what I'm proposing is to be able to read these things, which brings us to capture. We should capture the why and the how. A very common answer is spec. We also tried that. This was our attempt number two. The problem with specs is it requires time. I'm not saying specs are wrong, but it requires a certain discipline. As I mentioned, one of the our failure with specs was that we never went and corrected it once it was broken. So, what we are suggesting is if your specs are broken, you have to fix it. If you don't, then you're using a waterfall model. This is something we, you know, moved away from over 20 years ago. So that's why it's important to have a discipline of specs. In our case, we were not able to maintain it. So what can replace spec?
-
We talk about intent. Intent is why are we making a particular change? And an acceptance criteria, which is how it should behave. Some of you might be familiar with behavioral driven development and sort of like these are the concepts taken from there. It's nothing new. This was again 20 years old concepts. The beauty is it works for a single line change and it works for a 1,000 line feature. You have the intent for everything. You have the acceptance behavior for everything. And these already live in your sessions. You don't need to go and write it yourself. Intent is what you start with. Maybe it's a Jira ticket. Maybe it's something you tell your agent to get started working on. Maybe it's a spec file you provide. And acceptance criteria is every time you your agent stops to make a decision, every time you're kind of describing the behavior, that's the acceptance criteria you should capture. Today we throw these away and we lose this information. Okay, codify. I'm going to go a little bit faster. I think I'm running a little on time. Uh turn repeated comments into rules.
-
So as we mentioned, there are like two different kinds of comments. One is about correctness, one is about behavior. So what we did was we ended up mining one year of our previous comments and then started doing reduce, which is essentially identifying the comments which are more useful, extracting, classifying them, how many of them can be turned into rules, and eventually distilling it, which is merging similar rules to create these guidelines. Now these become your invariance. Essentially, what came out of those is out of 200 candidates, we got 64 rules automatically created. This was only one scan. Imagine if you start doing this on a regular basis. So these are some of the examples of the rules. You can see many of them are rules you can imagine can be linters, but some things can get more complex. The beauty of all of this is it creates one way to define the rules in English and you can maintain them over time even if your code changes.
-
So what goes in an invariant? It's a rule which describes what it's supposed to check, a scope where it's like when does this rule apply, verified by it's like how do you actually prove that this is working? Provenance, which is just tracking where this came from. So if you have to correct you kind of like go back to the source. And owner and this is the most important one. If you don't have an owner for a rule, this rule will become stale. So it's make sure you always define ownership for these things. And the beauty of this is invariants get cheaper over time. You define an invariant one time. Um what an agent can do now is take this rule and try to convert it into a in a script which is can be detected and checked in deterministically. You run this in shadow mode where you're kind of like validating it with a model and validating with a deterministic script and finally you promote it. So what you've done here is essentially use AI to build more deterministic systems to check these rules.
-
So here's an example of one of the rules that we converted. As you can see, this is an AST grep if you folks are familiar with which kind of like automatically detects that every request call we make has a timeout. So out of the 64 rules we had, we were able to convert 19 of them to deterministic and now it runs predictably. It's easy to verify. So every comment your team repeats is a guard rail you haven't written. Every comment your team repeats is a guard rail you haven't written. Okay, how do we prove that this actually works? So this is kind of like where some of our system comes in. We kind of like take the acceptance criteria, create a plan, spin up a server and then drive the agent to capture the evidence. What ends up happening is we based on the type of rule, based on the type of behavior, you can capture different evidence. All you're doing here is sort of like somewhat similar to how we used to do QA, but now you're giving a plan to the agent to run it themselves and our goal now is to make sure that the evidence looks correct.
-
So in this particular example, you can see kind of for a specific rule there is like screenshot captures, request captures responses. This is sort of like how an agent can convert a rule into automatic steps and depending on what kind of criteria there is, you can also define different types of behavior of verification. You can take screenshots, you can request response, you can check request response, network activity, AST grips as I mentioned, as well as test runs and traces. Okay, debate. This is where we come in. We as in humans. You know, this is something which I want one thing if you take away from here is that humans are always important in this loop. Do not completely remove that if you work in teams. You will lose your knowledge and this is where we talk about how humans can participate in this cycle. So where do decisions come from? When you build your agent is talking to you, most cases, if you're running dot factories, this might not be true, but most of you, if you're working on interact successions, you're working with your agent, you're providing feedback, you're making corrections.
-
These are places where you're making these micro decisions. When agents argue, which I already mentioned, if you're running a coding agent and a review agent, this is sort of like where the arguments are happening and then when a verification fails, which is like all these rules that you were written down, all these criteria that you wrote down, if it fails, your agent is making certain behavioral changes, whether it's updating the requirements or updating the code change, in both cases, there are decisions being made and these are the things which are worth surfacing. So here's an example like one particular file where we have bunch of these decisions um on a particular PR. As you can see, I already shared some of these examples. Some things are decided, some things are fixed, but some things may require human judgment as well. We'll kind of like flag that so it becomes something you need review. So, we capture all of these decisions, but what do we do with them? We can skim what is settled, settle what the agent could not where they kind of require a human judgment.
-
And you reopen any call you would make differently. So, there is a decision that something may like an agent made or a human made. Now you can actually argue with it. The main thing you're doing here is as a reviewer, you're having a discussion with the author and this is where the collaboration becomes important. This is where you're learning about how systems work. This is where you're actually arguing with the decisions and not just with the bot, but also with humans who are actually authoring the code. So, decisions outlive a pull request. You can analyze weekly. Now you have all of these decisions. You can say, okay, for this particular feature, this particular code change, give me all the decisions that were made for this week. Maybe there were some things that you might see as concerning and go back and visit why these decisions were made. You give it to your agent. Now agent knows these past decisions. This is sort of like the tribal knowledge we talk about. Now your agents have access to these micro decisions sort of like a context which continues building automatically.
-
And follow-ups become easier to track all of these decisions that you make as follow-up that we'll do it in a separate pull request now can be easily surfaced and tracked. And finally, this is where you can continue making better and better rules which now essentially become the standards of your code change. Ownership. You know, models unfortunately still today cannot own the code or mistakes they make. So, the responsibility has moved. As authors, we used to own the code. It's like, okay, we wrote it, we are going to own anything that happens to it. Now we don't even know what's written. And then we talked about the reviewers. They're sort of like the gearing factors. They are the code owners. They're the ones who effectively still will own the code if somebody else from outside the team submits a review. But think about ownership from a team. Now we can actually own the rules that verify whether the code works.
-
So instead of thinking about owning the code, own the guardrails, own the rules, own these frameworks. So as humans, now our responsibility is not the line-by-line review. We can't keep up. If you are still reading the code, I'm sure it still is working, but like imagine the quality degradation that is happening, more reviews you have to deal with every day. You we have to now own the rules that check the code. Instead of owning the code own what is verifying the code and maintain your understanding of the system. If we lose this understanding of the system, we don't know what we are building, we don't know how things work. This is where it creates our context debt. Okay, so a quick review of a year later. And the numbers kind of like where we are. So as I already mentioned, kind of like we have for xed our changes. Our median time to merge has gone down drastically.
-
It's 3.4 hours where it used to be 2.1 days. And also interestingly, the number of threads in the PRs have decreased. Now we are kind of like not finding as many correction mistakes, as many issues in the PRs. What we're doing is having these discussions in the in the decisions we make. So our surface area itself has changed. We're still discussing many of these things, but they're happening at a different surface level. It's not on line-by-line code. And the number of reverts have dropped. So that means our quality has now improved over a year ago even though we are doing lesser reviews. So don't need to read all of this. I kind of like already shared. This is an example of a pull request. Used to be open five days. It's like two and a half hours. I think the most important thing is now we also have all of these proofs. We capture all of these screenshots. We have these requests citations, which means now we have better auditability than we had before. We can actually go to our auditors and show like all of these things were verified and we have enough evidence that this works.
-
And one of the most important things is we have changed our surface from being the diff to reviewing the evidence, to reviewing the decisions. So where our time goes now, we spend a lot of time refining these rules, these invariance. We debate a lot on the decisions and we figure try to learn more about how do we improve our verification systems. Everything that we manually do testing, QA, anything today, we always go back every week and try to figure out how do we automate that. And this is not something which you can do immediately. This is something you have to build over time. First 90 days are the hardest. First month we are just doing double work. We are kind of reviewing the curve. We are reviewing the rules. We are making sure everything is working. Second is kind of like where you start seeing okay like you know the the the rules are working. We are kind of like making lesser and lesser changes. By the end of month three, you will start seeing sort of like the intent and evidence is actually more valuable and more useful to review.
-
So we start tomorrow mine your last 1,000 review comments, take the top 20 out of those and write them as checks. You don't need to do it all of this manually. You can just ask your agent to do all of it. I'm sure it will come up with rules. The main thing is just throw that in your CI. Let these rules run for every change. So please stop reading the def. Read these instead. The intent is why we why the change exists. Acceptance criteria is how you know it actually how it's supposed to behave invariance or the guardrails of the how so difference between acceptance criteria and invariance or invariance are code quality rules acceptance criteria is a behavior change. And decisions is one of the most important things which is your opinions, the trade-offs, all the things that we are doing and evidence is the proof that we make. Here's a quick plug of verify experience where we capture the intent, the evidence and the decisions. You can always go check it out.
-
And we are all under this together. We can outsource your thinking you can't outsource your understanding. Thank you.
Summary
The speaker shares lessons learned from scaling code reviews in a small engineering team that shifted from human-written code with AI assistance to predominantly AI-generated code. Key references include a Latent Space article published ten months prior, Microsoft's 2013 study on code review motivations, and a 2006 study on review quality degradation beyond 400 lines of code. The practical takeaway is that code reviews are ultimately about team knowledge sharing and building mental models rather than merely finding bugs, and since diffs are a poor medium for understanding code intent, teams must rethink how they handle quality versus architectural decisions in the age of AI.