Code review and documentation

How to give and receive review, what reviewers look for, and the lightweight documents (README, ADRs, runbooks) that keep a codebase understandable.

L1 · Junior engineer≈ 5 min read
Key points · the two-minute version
  1. Keep PRs small, single-purpose, described (what, why, how tested, risk) and self-reviewed first.
  2. Review in priority order: correctness → security and data → failure behaviour → tests → design → readability. Leave style to tools.
  3. AI changes add checks: versioned prompt, validated output, data separated from instructions, cost limits, fallback.
  4. ADR: context → decision → consequences, half a page.
  5. READMEs must state current reality and known gaps.
You should be able to
  • Prepare a pull request that's easy to review
  • Review others' code for correctness, not taste
  • Write an ADR and a runbook

Why this matters

Review is how a team shares knowledge and catches mistakes before users do. Documentation is how decisions survive the people who made them. Both are visible in your public repositories, and interviewers read them.

Preparing a pull request

  • Small: under ~400 changed lines when possible. Large PRs get rubber-stamped.
  • One purpose: don't mix a refactor with a feature.
  • Description: what changed, why, how you tested it, anything risky, screenshots for UI.
  • Self-review first: read your own diff in the PR view before asking anyone.

What a reviewer checks, in priority order

  1. Correctness: does it do what it claims, including edge cases and errors?
  2. Security and data: auth checks, input validation, secrets, injection, data leaks.
  3. Failure behaviour: timeouts, retries, what the user sees when it breaks.
  4. Tests: do they prove the change works, and would they catch a regression?
  5. Design: does it fit existing patterns? Is something duplicated that already exists?
  6. Readability: names, structure, comments that explain why.
  7. Style: leave this to linters and formatters.

Phrase comments as questions or suggestions, label nits ("nit:"), and approve once blocking issues are fixed.

Add these checks: Is the prompt versioned and covered by an eval case? Is model output validated before use? Is untrusted text (user input, documents, tool results) kept separate from instructions? Are cost and token limits set? Is there a fallback? See the prompt checklist C5.

Documentation that earns its keep

Document Purpose Length
README What it is, how to run it, how to test it, status and known gaps 1–2 screens
ADR (architecture decision record) One decision: context, options, choice, consequences Half a page
Runbook How to diagnose and fix a known failure A checklist
API reference Generated from code (OpenAPI) where possible Generated

An ADR template:

# ADR 0011: The model returns segment numbers, never timestamps
Status: accepted
Context: Clip cut points must fall on word boundaries; models invent plausible timestamps.
Decision: Number transcript segments; the model may only answer with segment numbers.
Consequences: Hallucinated timestamps become impossible; cut precision is limited by segmentation.

That's a real decision from a casebook project (P1, S4).

Common mistakes

  • Review comments about taste while a missing auth check goes unnoticed.
  • READMEs that describe the plan, not the current reality.
  • Decisions living only in chat threads that disappear.

Interview follow-ups

  • "You disagree with a reviewer's comment." Discuss the trade-off with evidence (benchmarks, docs, precedent in the codebase); if it's a preference, defer to the codebase convention; escalate only for real risk.
  • "What do you look for first when reviewing AI-generated code?" Correctness on edge cases, invented APIs or packages, missing error handling, security (injection, secrets), and whether tests actually assert behaviour.

Check yourself

What should a reviewer look at before style?

Correctness, security and data handling, failure behaviour, and whether the tests actually prove the change.

What four parts does an ADR have?

Context, the decision, the options considered (often inside context), and the consequences, plus a status.

Build it

Write two ADRs for decisions in a project of yours, and a README section called "Known gaps" that lists what isn't finished or verified.

What comes next

2.5 CI/CD and releases.

Build it to remember

Two hands-on projects that exercise this lesson. Pick one, build it end to end, and keep it in your portfolio.

Project 1

ADR log for a real project

Write five ADRs for decisions in a project you own, including one you'd now reverse.

  • Markdown
  • adr-tools or a docs folder

Practises Making trade-offs explicit and durable.

Project 2

PR review bot (rules only)

Fail PRs over 400 lines, with no tests touched, or with an empty description; post a checklist comment.

  • GitHub Actions
  • Danger.js or a Python script

Practises Encoding review norms as automation.

Can you answer every check-yourself question out loud without opening the answer?