Reviewing AI output like a PR
Understand the idea
Rubber-stamping tidy AI output is how subtle bugs ship. Review it the way a careful engineer reviews a junior pull request.
The review stance
is where this track becomes a habit. AI output arrives looking mergeable. Your stance is the same one you owe a junior teammate: curious, skeptical, specific. Ask what the change claims to do, then try to break that claim.
AI Lab · compare fixes
Two AI patches after an error-handling block moved
A refactor moved the error-handling block. The comment still says "continue to next file," but the code uses break. Production stopped processing the rest of a batch after the first bad file. Two chat suggestions disagree.
Fix A - trust the comment
// On parse error, continue to next file
for (const file of files) {
try {
process(file);
} catch (error) {
log(error);
continue; // AI: comment said continue, so change break → continue
}
}Fix B - keep abort semantics, fix the comment
// On parse error, abort the batch (fail fast)
for (const file of files) {
try {
process(file);
} catch (error) {
log(error);
break; // intentional: one bad file stops the batch
}
}
// Tests and runbook require fail-fast; update the stale comment instead.Questions that catch AI-shaped mistakes
What assumption does this encode? Which never appears in the snippet? What do existing tests and callers require? Did the model solve a neighboring problem with a familiar helper? Those questions catch substring identity checks, silent catches, and comment-driven control-flow edits.
| Lens | Glance | PR-grade |
|---|---|---|
| Syntax | Parses, formats cleanly | Necessary, not sufficient |
| Intent | Comment sounds right | Matches tests and runbook |
| Edges | Demo input works | Boundary input chosen by you |
| Risk | Diff is small | Behavior change is understood |
Edge cases and callers
Read the call sites. A helper that returns 0 on failure may be fine in a chart and disastrous in a charge. AI often optimizes the local file. Review zooms out to the contract the callers already rely on.
When comments and code disagree
After refactors, comments drift. A model that "fixes" code to match a stale comment can invert product behavior while making the file locally consistent. Prefer the intentional source of truth - tests, runbook, product rule - then update the stale artifact.
Hold the same standard you hold a teammate
If you would request changes from a junior engineer, request them from the model. If you would demand a test for a control-flow change, demand it here. The author being non-human is not a reason to lower the bar. It is a reason to keep it.
Mental model
FOLLOW THE VALUE
Shape is not intent.
01 / 03Trace the transformation
Live example
A stale comment says continue while the keyword remains break - review trusts tests, not drifted prose.
Your console output appears here.
Guided challenge
Pick the review instinct
The third log says trust-comment. Change it to trust-tests.
Your console output appears here.
EXPECTED CONSOLE OUTPUT
continue to next file break trust-tests not-rubber-stamp reviewed
Hints 0/2
Use all hints or make 3 failed runs (0/3).
Free sandbox
Make a variation, test an assumption, or break the example on purpose. This draft is saved separately.
Your console output appears here.
Quiz
A quick check for understanding. Retry as often as you like; your learning path stays open.
Ready to call this one understood?
Mark this lesson complete to earn 200 XP. You can always revisit it.