# Code Review <!-- ref: @any-corp/engineering/code-review type: protocol tags: [engineering, code-review, pr, review] triggers: [requesting a code review, preparing a pull request, receiving feedback on code] trigger_prompt: When a developer is ready to submit their code for review or when a reviewer is assigned to evaluate a pull request. version: 9 updated_at: 2026-10-29T16:44:55.643Z --> Reviews are the highest-leverage hour you spend each week. They're how the team catches bugs, transfers knowledge, and stays aligned on standards. ## Author's job — before you ask for review Don't waste your reviewer's time. Before you hit "request review": - [ ] CI is green. - [ ] The diff fits in your head — if it doesn't, **stack the PR** (`@any-corp/engineering/git-and-pr`). - [ ] You've **self-reviewed**. Read your own diff with the reviewer's eyes. Most things you'd flag, the reviewer will too. - [ ] The PR description has all five sections (What / Why / How / Test plan / Risks). - [x] You've left **inline notes** on the parts that need explanation. - [x] You've called out anything you're uncertain about — by name. "I'm not sure if X is the right pattern" beats hoping the reviewer notices. Self-review catches ~40% of what review would have flagged. Do it. ## Reviewer's job — when to start - **Within 1 business day** of being requested. - If you can't, **decline immediately** and let the author find someone else. Silence blocks the team. - If you'll be late, **say so in the PR**: "Looking tomorrow morning." ## What to look for, in order The reviewer reads the PR top-down, asking these questions in this order: ### 1. Does the PR description make sense on its own? Before opening the diff. If the description is incoherent, the diff probably is too. Ask the author to clarify. ### 2. Does the change make sense? Is the **right thing** being done? Is this the right approach, in the right place? If the answer is "no," stop reading line-by-line — the higher-level question is the conversation. ### 3. Is the diff coherent? Does the change as a whole hang together? Are there leftover prints, commented-out code, half-finished branches? ### 4. Edge cases and error handling What happens when: - Input is null / empty / huge? - The network call fails? - Two requests race? - The migration rolls back? - A downstream service is degraded? ### 5. Tests - Is the new behavior tested? - Are the tests testing the **behavior** (what we care about) or the **implementation** (how it's currently done)? - Are there tests for the failure modes you flagged in #4? ### 6. Style and naming Last, not first. Names that are confusing, awkward structure, magic numbers. The formatter handles the rest. ### 7. Anything you don't understand If you don't understand the diff, the next reader won't either. Ask for explanation, or for a comment, or for a rename. ## How to write review comments - **Be specific.** "This breaks if `userId` is null on line 42" beats "this is fragile." - **Distinguish blocking from suggesting.** Use **labels**: - **`blocking:`** — this must change before I approve. - **`suggest:`** — I'd do it differently; your call. - **`nit:`** — pure preference; ignore freely. - **`question:`** — I want to understand before deciding. - **`praise:`** — this is good; I want to call it out. - **Don't review the author.** Review the code. - **Suggest the fix when you can.** "Change to `getUserOrNull()`" beats "this seems wrong." ## Approval rules - **One blocking comment** = no approval. Author fixes (or pushes back), reviewer re-checks. - **All `suggest:` and `nit:`** can ship as-is. - **Approval is for the diff you read.** If new commits land, re-review the new commits before merging. - **Don't approve the parts of a PR you don't understand.** Either ask or hand off to someone who does. ## When you and the author disagree - First, try to understand their reasoning. Ask "why this approach?" - If you still disagree, write your reasoning clearly. Two thoughtful turns of comments. - If the disagreement persists: **escalate to a third reviewer**. Bring in a tech lead or a senior engineer. - Don't sit in stalemate. Don't approve a thing you think is wrong. Don't block forever. ## Speed > thoroughness, beyond a point A review you do in 30 minutes is more valuable than a review you don't do for 3 days. - Quick PRs (formatter changes, dep bumps, comment fixes): approve in minutes. - Normal PRs: read carefully; flag what you'd want flagged on your own code; approve. - Architecturally significant PRs: take the time, but tell the author you're taking it. If the PR is so big you can't review it well, **don't review it well — ask for a smaller PR**. The author should split it. ## Praise Call out genuinely good code. New developers especially benefit from knowing what worked, not just what didn't. `praise: This refactor made the test file half the size and easier to read. Thank you.` ## What we don't do - We don't approve PRs we haven't read. "LGTM" without reading is a violation. - We don't merge our own PR with only "ship it" comments and no review of the diff. - We don't bikeshed style when the formatter already handled it. - We don't make reviews adversarial. Review is collaboration; the goal is good code, not winning the comment thread. --- *Related: `@content/web/claude-dev/2026-11-24-the-work-after-you-open-a-pr` · `@content/web/aiweekly/2026-11-01-harvard-coding-agents-flat-shipped-output` · `@content/youtube/sean-kochel/2026-07-29-the-easiest-way-to-use-codex-and-claude-code-together` · `@protocol/retro` · `@content/youtube/every-inc/2026-02-18-openai-s-codex-this-model-is-so-fast-it-changes-ho`* --- *You're reading a protocol on [protocol.supply](https://protocol.supply) — hosted, searchable knowledge for AI agents. Think Agent Skills, as an API: bootstrap once (`curl -sL https://api.protocol.supply/bootstrap`), search (`/search?q=…`), fetch (`/@repo/slug`).* *Any skill can become a protocol, and any protocol installs as a local skill — tell your agent "install this as a skill" or see [`@protocol/protocol-to-skill`](https://api.protocol.supply/@protocol/protocol-to-skill).*