Field notes / Code review
Understand a pull request before you review it
A teammate's pull request touches 24 files. You know some of the code, not all of it. Before you can judge the change, you have to work out what it is: what it does, why, and which of the 24 files matter.
aictrl now does that first pass for you. Open the pull request in aictrl and select Generate on the What this change does card. An agent reads the change in a clean container, checks its claims against the code, and writes an explanation you can read in a couple of minutes.
Transcript
I'm going to briefly show you a feature in aictrl that explains the change in a pull request. The focus here is not on finding bugs, but on making the change easy to understand.
Here is the What this change does section. If I click Generate, the process starts.
Now we're back on the pull request, and the What this change does section has been filled in. If we expand the explanation, we see the diagram, and this diagram is interactive. You can explore what happens in this change by clicking the nodes of the diagram, and each node has the code from the change. So you can see where this node comes from, and which part of the code is responsible for it. You can also open it on GitHub.
You can share the explanation directly on GitHub, so everyone reviewing gets the same context.
Right now we have flowcharts, sequence, entity, state and Gantt diagrams. Interactive class diagrams are coming next.
For an interactive example, setup choices, limits and a comparison, see explain a pull request with AI.
What you get
What it does and why, first. The summary says it in plain words. The full explanation teaches the change to someone new to this code, and only then gets to Reviewer notes: the reading order, the files to open first and what to probe.
Diagrams you can explore. The explanation draws the diagram the change needs:
- a state diagram when something moves through a lifecycle,
- an ER diagram when the schema changes,
- a sequence diagram when components call each other,
- a Gantt chart when work overlaps in time,
- a flowchart for decisions.
Select any step and the Step inspector shows the code that does it, at the explained commit, and what this pull request changed in it. Pick an ending, such as "retries exhausted", and Trace numbers the steps that lead there; Walk through it goes one step at a time. References in the text are linked to the same steps, and every other file reference links to the exact lines on GitHub.
Pinned to a commit. The card says which commit the explanation was written for, and tells you when new commits have made it out of date.
Share on GitHub. When it's useful to the other reviewers, post it on the pull request as one comment. Refresh it after new commits and share again: Post update edits the same comment instead of adding another. The diagrams travel as static figures; the clicking stays in aictrl.
See one on a real pull request
The pull request in the video is aictrl-dev/cli#129 in our open-source CLI: 24 files and more than 2,000 changed lines, adding validated output schemas with a bounded number of corrective retries. Its explanation is shared on the pull request, so you can read it without an account.
It opens with the four terms you need, then the problem, the idea, and the parts that look easy and aren't, such as two calls in the same step or a provider retry halfway through a response. One flowchart shows the loop: check the schema, ask the model, validate its answer, retry while the budget lasts, and exit with a different code for each way it can end. The Reviewer notes come last, with a reading order, five questions to probe and the tests that cover them.
aictrl.dev · Explain Change
Click through the explanation yourself.
Built from the explanation of cli#129 in the video. Select any step in the diagram to see the code behind it, then switch between what the pull request changed and the code at the explained commit.
Example: aictrl-dev/cli#129, which makes the CLI enforce a JSON Schema on the model's final answer. The flowchart follows aictrl's explanation of that pull request; the sequence and state views are illustrations. Every code excerpt is the pull request's own code.
How we got here
Two weeks ago we read the last ten explanations aictrl had written. They were mostly accurate. They were also written for someone who already knew the code: file lists, risks and probe points from the first paragraph. Half of them had no working diagram, and most of those had none at all.
So we changed the order. An explanation now teaches before it reviews. Before the agent finishes, a lint check fails broken diagrams and missing references, and a second pass rereads the draft as a newcomer would and flags anything that assumes too much. The agent fixes what they find before it submits, and names anything it couldn't fix in the Reviewer notes.
The diagrams became explorable because a picture of a flow only helps if you can get from a box to the code behind it. Each diagram now comes with a map from every step to the file and lines that implement it, and the lint checks that map too.
Then we hit the next problem. The agent defaulted to a flowchart. A status that moves from queued to running to done is a state machine; a migration is a schema; two jobs racing each other are a timeline. A flowchart of any of them hides the point.
A larger model wasn't the fix. Before drawing anything, the agent now answers four questions from signs in the code:
- Does something move between states?
- Do things overlap in time?
- Do several parties exchange messages?
- Is there a decision?
The answers go on one line in the Reviewer notes, and the lint fails the run if a "yes" has no diagram of that type. We tested it on real pull requests where we knew the right diagram, and the agent now picks it far more often, on the same model and with no slower runs. When it picks wrong, the answer line shows why, so the mistake is easy to spot.
What it doesn't do
It doesn't approve anything, and it can be wrong. Each explanation counts the claims it could tie to code and the ones it couldn't, so you know how much to trust it. Use it to decide where to start reading, then read the code.
An explanation takes about a quarter of an hour, so start it when you're assigned the review, not when you sit down to do it.
Try it
Open a pull request in a connected repository and select Generate. The Explain PR guide walks through reading, exploring and sharing an explanation.
We'd like to know what you read first when you open a teammate's pull request, and what you'd want an explanation to tell you. Tell us on Discord or reply on LinkedIn.