Code review
Approve a change once it clearly improves code health, not when it's perfect: keep changes small, respond within a business day, review design before style, and use comments to teach.
How it works
- Technical facts and the style guide beat personal preference; a change needn't match how you'd write it.
- Review design first; if the approach is wrong, say so now instead of reviewing every line.
- Keep changes small: ~100 lines is usually reasonable; ~1,000 is usually too large to review well.
- Response time matters most: reply within one business day, even if full approval takes longer.
- Comment on the code, explain why, label Nit/Optional/FYI, and turn repeated comments into lint rules.
Check yourself
Answer to mark it learned; your answers aren't scored.
You open a 1,200-line PR that adds a cache. In the core file you see the cache key ignores the tenant id, so tenants could read each other's data. You have 15 minutes. What do you do?
Go deeper
Full explanation
Code review is a second engineer reading a change before it merges. Its main jobs are keeping code health improving and spreading knowledge; catching bugs is only part of it.
Google's published engineering practices are a solid baseline:
- The bar: approve once the change definitely improves overall code health, even if it isn't perfect. Technical facts and the style guide beat personal preference.
- Order: read the description (should this change exist at all?), then the core files. Design comes first; if it's wrong, send that comment now, because the rest may be rewritten. Then functionality, complexity (watch for over-engineering), tests and naming. Style last, ideally left to linters.
- Small changes: ~100 lines is usually reasonable, ~1,000 usually too large.
- Speed: respond within one business day at most. Slow responses cut the whole team's velocity.
- Tone: comment on the code, not the person; explain why; label severity (
Nit:,Optional:,FYI:); praise what's good.
At Staff level you set the norms: automate style, review the design before a 2,000-line PR exists, and turn repeated comments into checklists or lint rules.
Code Review comments that teach
# Same finding, two tones (Google's example)
About the person:
"Why did you use threads here when there's obviously
no benefit to be gained from concurrency?"
About the code, with the why:
"The concurrency model here is adding complexity to the
system without any actual performance benefit that I can see."
# Label severity so the author knows what blocks the merge
(no label) Must change: "This runs one query per user (N+1);
batch it with get_users(ids)."
Nit: Polish, fine to skip.
Optional: Good idea, not required.
FYI: Not for this change; worth knowing.
# Praise specifically, so the pattern repeats
"Nice: the table-driven tests cover every error path."Real example
A teammate sends a 1,400-line PR that adds a payment provider, rewrites the shared retry helper and renames a config key. You don't review it line by line. Within the day you send one design comment (the retry change alters behavior for every caller) and ask for three PRs: the rename, the retry helper with tests, then the provider behind a flag. Each is reviewed the same day. You leave the junior author an FYI: about idempotency keys, then add it to the team's review checklist so you never write it again.
Trade-offs +3 · −3
+ You gain
- Catches design flaws while they are cheap, before other code depends on them.
- Spreads knowledge: at least two people understand every change.
- Teaches at scale: one well-explained comment shapes many future changes.
− You pay
- Adds latency to every change; slow reviews cut the whole team's velocity.
- Rubber-stamp approvals give false confidence and catch nothing.
- Style debates burn time and goodwill when no linter or style guide settles them.
Use it when
Every change to shared production code. Go deep on public APIs, data models, security and concurrency; skim mechanical changes like renames and generated code.
Avoid it when
Don't use review as the first place to question an approach: agree on it in a design doc before a large PR exists. Don't hold throwaway prototypes to production standards.
Numbers to know 4
- Google's guide: respond within one business day at most.
- Google's guide: ~100 lines is usually a reasonable change; ~1,000 is usually too large.
- Google study (2018, 9M changes): median change of 24 lines, median of 1 reviewer, median review latency under 4 hours.
- Same study: developers spent ~3 hours a week reviewing (mean 3.2, median 2.6).
Common pitfalls 4
- Unlabeled comments: the author can't tell a nit from a blocker and treats everything as mandatory.
- Reviewing every line of a change whose design is wrong; send the design comment first.
- Enforcing style by hand instead of with formatters and linters.
- Becoming the bottleneck: if every PR waits for the Staff engineer, grow other reviewers.
Interview questions 3
Answer out loud first, then reveal.
What do you look for first in a code review, and why?Show answer
Whether the change should exist and whether the design fits, because everything else is wasted if the design is wrong. I read the description, then the files with the core logic. If there's a design problem, I send that comment immediately instead of finishing the review. Then functionality, complexity and tests. Style I leave to the formatter and linter; humans arguing about formatting is the most expensive lint there is.
Reviews on your team take three days and people complain. What do you do?Show answer
I measure first: time to first response, PR size and rounds per PR. The fix is usually two norms: a first response within one business day, which is Google's maximum, and smaller PRs, closer to 100 lines than 1,000. I add code owners so requests reach someone who can approve, and automate style. The trade-off is interruptions, so reviewers respond at natural breaks, not mid-task.
How do you use code review to grow engineers?Show answer
I explain the why in every non-trivial comment, label severity so a Nit or FYI doesn't feel like a blocker, and praise specific good choices so they repeat. With juniors I ask questions rather than dictate fixes. When I write the same comment three times, I turn it into a checklist item or a lint rule. And I pair senior reviewers with newer ones, so I'm not the bottleneck.