Code review
Get the change
- Branch:
git diff $(git merge-base HEAD origin/main)...HEAD(or the base the user names) plusgit log --oneline <base>..HEAD. - PR:
gh pr view <n>andgh pr diff <n>. Read the PR description and linked issue first: you are reviewing against an intent. - Uncommitted:
git diffandgit diff --cached.
Read changed files in full where the diff is not enough to understand the context. Never comment on code you have not read.
Review in passes (most important first)
- Does it do the right thing? Compare with the description/issue. Missing cases, wrong assumptions, behavior changes that are not mentioned.
- Correctness. Logic errors, off-by-one, null/empty handling, error paths, concurrency and ordering, time zones, float money, resource leaks (files, connections, listeners), retries that are not idempotent.
- Security. Untrusted input reaching SQL, shell, file paths, HTML, URLs (SSRF), deserialization, regex (ReDoS); missing authorization on new endpoints (authn is not authz); secrets in code or logs; overly broad CORS or permissions.
- Tests. Do tests cover the new behavior and the failure modes? Would they fail if the change were reverted? Are they deterministic?
- Design. Right layer, right module? New dependencies justified? Public API changes backward compatible? Simpler alternative available?
- Readability. Names, function size, comments that explain why. Only after everything above.
- Operations. Logging and metrics for new failure modes, migrations safe to run on live data, config documented, feature-flagged if risky.
Report format
Summary: <1-2 sentences: what the change does and overall verdict>
Blocking
1. path/file.py:42 - <problem>. <why it matters>. Suggest: <concrete fix or code>.
Non-blocking
2. path/other.ts:10 - <...>
Nits (optional)
- ...
Questions
- <things you could not determine from the code>
Rules
- Every finding has a location, a reason and a suggested fix. “This is confusing” is not actionable; “rename
dtodelay_seconds” is. - Separate blocking from non-blocking honestly. Style preferences are never blocking unless the repo has a rule.
- Say what is good when it is notably good; it calibrates the rest.
- Prefer one comment per pattern (“same issue in 4 places: a.py:10, b.py:22, …”) over many duplicates.
- Do not rewrite the whole change in your preferred style.
- If the diff is too large to review well (roughly over 400-500 changed lines of logic), say so and suggest how to split it.