Code review best practices for authors and reviewers

How to make code reviews fast, kind and genuinely useful, including reviews of AI-generated code.

Key takeaways

  • Small PRs get better reviews, faster.
  • Review for correctness, design and clarity. Let tools handle style.
  • Be kind and specific, and distinguish "must fix" from "nit".

Code review is where quality, knowledge sharing and team culture meet. Done well, it's the best learning tool a team has. Done badly, it's a bottleneck and a source of friction.

1Small PR< 400 lines2Self-reviewread your diff3Automated checksCI green4Peer review< 1 day5Mergeand deploy
A healthy review flow: small, self-reviewed, automated, then a timely human review.

#For authors

  1. Keep it small: under ~400 changed lines, one purpose.
  2. Write a good description: what, why, how to test, and screenshots for UI.
  3. Self-review first: read your own diff as if it were someone else's.
  4. Point reviewers to the tricky parts: "The retry logic in queue.ts is the part I'm least sure about."
  5. Don't take it personally. Feedback is about the code.

#For reviewers

Review in this order:

  1. Does it solve the right problem?
  2. Is it correct? Edge cases, errors, concurrency, security.
  3. Is the design reasonable? Fits the architecture? Duplicates something?
  4. Is it clear? Names, structure, tests that explain intent.
  5. Style: only if tooling doesn't already enforce it.

#Comment like a teammate

  • Be specific: "This will run N+1 queries for each order; could we batch-load customers?"
  • Ask, don't command: "What happens if items is empty?"
  • Label severity: blocking:, suggestion:, nit:, question:.
  • Praise good work. "Nice, this test makes the rule very clear."

#Speed matters

Aim to respond within one working day, ideally a few hours. Slow reviews create huge PRs, context switching and frustration. Many teams reserve two short daily review slots.

#Reviewing AI-generated code

  • Hold it to the same standard as human code, or a higher one.
  • Watch for plausible but wrong logic, invented APIs and silent error swallowing.
  • Check for duplication of existing utilities, which AI often reinvents.
  • The author must be able to explain every line. "The AI wrote it" isn't an answer.

Tip: Use AI as a first reviewer to catch obvious issues before a human looks. It doesn't replace the human review.

#Team agreements to write down

  • Max PR size and review turnaround time.
  • Who must approve what (e.g. security-sensitive code).
  • When it's OK to merge with comments outstanding.

Keep reading

Best practices

A testing strategy that works: the pyramid, TDD and beyond

How many tests of which kind, how to write tests that catch real bugs, and how AI changes testing.

AI-era lifecycle

Quality gates for AI-generated code

A practical, layered defense so that faster code generation doesn't mean more production incidents.

Best practices

The SOLID principles in plain English

Five principles for code that is easy to change, each explained with a short example and a warning about overuse.