Code review is a teaching tool, not a gate
A gate catches this defect; a lesson prevents the next one. How we run code review at NetPy: comment templates that hand over context, a ranking convention so blocking concerns aren't buried in nits, four loop metrics worth watching, and the anti-patterns we banned.
A new engineer's first pull request at NetPy is usually small — a bug fix, forty lines, one test. The code review that comes back decides what happens over the next six months more than any onboarding doc will. Reviewed as a gate, it produces forty-seven comments, three days of silence, and a person who learns that asking for help is expensive. Reviewed as a lesson, it produces six comments in an afternoon and a second PR that already knows the house rules.
We have run both kinds of review. The gate version looks rigorous in a retro and costs you a year of someone's confidence. What follows is the version we settled on, including the comment templates, the ranking convention, the metrics we actually watch, and the anti-patterns we banned by name.
A gate stops this defect; a lesson stops the next one
The mental model matters because it changes what you consider a good review. If review is a gate, the metric is defect escape rate — how much bad code got past you. If review is teaching, the metric is the quality of the next pull request from the same person. The first is a property of the reviewer's attention on one Tuesday. The second is a property of the team.
Studies of inspection consistently put human review at catching somewhere between half and two-thirds of defects, and the number moves far more with reviewer context than with reviewer diligence. The practical read: you cannot out-review a broken design or an unfamiliar codebase, and you should stop trying. What review is genuinely excellent at is transferring the reasons behind a decision — the incident that made a table append-only, the payment provider that retries webhooks for seventy-two hours, the reason this service does not cache.
That is context, and context is the only thing that compounds.
What a code review comment is actually for
Here is a real pair from an early review of ours. A junior engineer wrapped a payment call in a retry.
The gate comment was: "add an idempotency key." Correct, terse, and useless. It fixes this line. It teaches nothing, and the same mistake reappears four weeks later in a webhook handler where nobody caught it.
The teaching comment:
The gateway retries for 15 minutes on a timeout, so this retry can charge the customer twice — we had exactly that in Feb and refunded 40 orders by hand. Any mutating call inside a retry loop needs a key derived from the request, not a fresh UUID per attempt, or the duplicate is treated as a new charge. Here's the adapter we already use: payments/gateway.py::charge_idempotent. Please switch to it.Same correction. Different outcome. The second one hands over a rule ("mutating call inside a retry loop"), the evidence (the incident, with a number), and the tool that makes the rule cheap to follow. Three parts, in that order. Almost every good review comment is those three parts, and almost every unhelpful one is missing the evidence.
The rule generalises: never leave a comment the author cannot act on without asking you a follow-up question. If the comment requires a conversation, say so and offer the conversation in the same breath.
Rank comments, or nobody reads any of them
Comment volume is not review effort, it is noise. A PR with thirty comments where twenty-six are formatting teaches the author to skim all thirty, including the one about the race condition.
We use a prefix convention, and enforce it in the PR template:
<!-- .github/pull_request_template.md -->
## What changed, and why
## How I verified it (command output, not vibes)
### Reviewer conventions
- **blocking:** must change before merge. Say what breaks if it doesn't.
- **should:** I think this is wrong but I may be missing context.
- **nit:** style or preference. Author may ignore without argument.
- **question:** I don't understand this; answering it may be the point.
- **praise:** one line, specific, no adjectives. "The retry backoff here
is better than what I wrote" beats "nice work".
Two effects, both measurable. Authors stop arguing about nits, because ignoring them is explicitly allowed. And reviewers stop hiding a blocking concern inside a list of preferences, which used to cost us days — the author would fix fifteen nits and reasonably conclude the review was satisfied.
The praise line is not decoration. It is how a reviewer calibrates: it tells the author which of their instincts to keep. A review that only names faults teaches avoidance, not taste.
Automate the gate so humans can afford to teach
Every comment a machine could have made is a comment a human did not spend teaching. We audited three months of review threads and found roughly six in ten comments were things a linter, formatter, type checker or secret scanner would have caught — import order, unused variables, missing return types, a hardcoded token that made it into a diff.
Those now fail before a human sees them:
# .github/workflows/review.yml
name: review
on: [pull_request]
jobs:
static:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: ruff format --check . && ruff check .
- run: mypy --strict app/ || true # advisory until the baseline is clean
- run: detect-secrets scan --baseline .secrets.baseline
- run: pytest -q --maxfail=1
The mypy || true is deliberate and temporary. Making types advisory for the first month gets the baseline to a place where blocking is not a full-time job; blocking from day one on an untyped codebase just trains people to bypass CI.
Two things stay human, permanently: whether this is the right change to make at all, and whether the reasoning in the PR description matches the code. No linter has an opinion on either.
Measure the loop, not the reviewer
Review speed is a team property, and it decays silently. Four numbers, all cheap to compute:
- Time to first review, p50. Ours is a four-working-hour budget; past a day, authors context-switch and the PR gets worse while it waits.
- PR size, p50 and p90. Defect detection falls off sharply past roughly 400 changed lines — reviewers skim, and they skim the part that needed reading. A 900-line PR is a design review wearing a code review's clothes.
- Rework rate. Lines changed within fourteen days of merge, as a fraction of lines merged. This is the honest measure of whether review caught what mattered; it is also brutally fair, because it counts your misses, not the author's.
- First-PR latency for new hires. Days from first PR opened to second PR merged. If this is over a week, the problem is your review culture, not their ability.
A thirty-line script with the GitHub CLI gets you all of it weekly:
gh pr list --state merged --limit 60 --json number,createdAt,mergedAt,additions,deletions,reviews \
| jq -r '.[] | [.number, .additions + .deletions,
((.mergedAt|fromdate) - (.createdAt|fromdate)) / 3600] | @tsv' \
| awk '{n++; s+=$2; if ($2>400) big++} END {
printf "PRs: %d median size: %d lines over 400: %d%%\n", n, s/n, 100*big/n}'
Numbers like these are diagnostic, not disciplinary. When median PR size climbs, the fix is usually a design conversation earlier, not a stricter reviewer.
Anti-patterns we banned by name
- Review by rewrite. Pushing a commit that replaces the author's approach, then approving. It ships the code and destroys the lesson; if the approach is wrong enough to rewrite, say so on the PR and close it.
- "Why didn't you…" as a complete comment. It is a question with an accusation embedded. Ask what constraint they were working under, or state the requirement.
- Silent approval on a large PR. An approval with no comment on 800 changed lines is not a review, it is a liability transfer.
- The three-day review. Letting a PR sit until it is stale, then reviewing it against a base branch that has moved. Reviewed code is not the code that merges.
- Style comments as blocking. Formatting belongs in the formatter. If a human is arguing indentation, the machine is misconfigured.
None of these are rare. All are cheap to name once, in writing, in the PR template — which is where a convention actually lives.
The thirty-day rollout
If you want to try this, the sequence that worked for us:
- Week one: add the PR template with the ranking prefixes and the verification section. Change nothing else. Watch how many comments arrive unranked.
- Week two: turn on the machine checks that are already green, blocking. Leave the rest advisory.
- Week three: set the four-hour first-review budget. Whoever is on review duty owns it, and the duty rotates weekly so it does not become one senior person's permanent tax.
- Week four: compute the four metrics once, as a baseline, and put the numbers in the team channel with no commentary attached. Repeat monthly.
The measure of success is not fewer comments. It is the same person's third PR needing two comments instead of six, and a new hire who asks a question in review instead of guessing — which is the whole thing you were trying to buy. If you are hiring engineers or running an internship cohort, this is also the review discipline we teach in the FDE program, because it is the skill that transfers fastest into a working team.
Get that loop right and the gate takes care of itself.
Header image: two developers reviewing code together. Vajrapani666, Wikimedia Commons, CC BY-SA 3.0.