Practical Code Review (Including AI-Generated Code)
What to review (correctness, security, tests, readability), PR sizing, Conventional Comments, turnaround targets, self-review, and verifying AI-generated PRs.
TL;DR
Review for correctness, security, tests, and readability—never for style that eslint or prettier can fix. Keep PRs small, label comments with Conventional Comments (issue:, nitpick:, suggestion:), and when reviewing AI-generated code, always verify claims, run the suite, and check git log.
1. What to review (and what to skip)
| Focus here (Human judgment) | Skip here (Automate in CI) |
|---|---|
| Does this solve the stated problem and edge cases? | Semicolons, quotes, indentation, import sorting |
| Trust boundaries: authZ, input validation, secrets, XSS/SQLi | Unused variables or missing types (eslint / tsc) |
| Do tests assert real behavior (not just mock tautologies)? | Dead formatting preferences |
| Can a teammate understand this function in 6 months? | Bikeshedding over equivalent syntax |
2. PR size and turnaround
- PR size: Aim for ≤ 200–400 lines changed (excluding lockfiles or generated snapshots). Separate mechanical refactors from behavior changes into two PRs.
- Review turnaround: Target < 24 hours (ideally within a few hours). Unblocking a teammate's PR has higher leverage than starting a new feature of your own.
3. Conventional Comments
Prefix review comments so the author immediately knows severity and intent:
issue (blocking): `deleteItem` checks authentication but not ownership (BOLA).
suggestion (non-blocking): Extract `parseFrontmatter` into a shared helper.
nitpick (non-blocking): Rename `d` to `durationMs` for clarity.
question: Does this endpoint need rate limiting before we ship?
praise: Clean separation between the pure layout function and React state!Using (non-blocking) lets you approve the PR in the same pass instead of forcing another round-trip over a minor rename.
4. Reviewing AI-generated code
AI coding agents write plausible code fast—and can also hallucinate APIs, skip edge cases, or report stale test results. Apply these four checks on every agent PR:
- Verify claims against files: If the agent cites a symbol, flag, or library version, check
node_modulesor the actual file—never accept "I verified it" on faith. - Run it yourself: Run
pnpm lint && pnpm typecheck && pnpm test && pnpm build(or inspect CI logs) after the agent's final edit. - Check
git logandgit status: Confirm commits actually exist on the branch, follow commit conventions, and contain no stray scratch files or trailers. - Watch for duplication: Agents often reimplement an existing helper instead of reusing what's already in
lib/orcomponents/.
5. Self-review checklist (before requesting review)
Even as a solo developer, review your own PR diff on GitHub/Git before merging:
- Read every changed line in
git diff—remove debug logs, unused imports, and unrelated edits. - Confirm new functions handle empty/null/error inputs.
- Confirm tests would actually fail if the bug returned.
- Write a 3-line PR summary: What changed, Why, and How it was verified.
Minimum viable version (1–3 person team + AI agents)
- Solo developer: Treat every PR as an async self-review—never push directly to
mainfor non-trivial changes; open a PR, let CI run, read the diff once with fresh eyes, then merge. - 2–3 person team: 1 approving review per PR, Conventional Comments prefixes, and a 4-hour daytime review SLA.
When it's overkill
- Requiring 2+ senior approvals on a 1-line typo fix or dependency patch when CI is green.
- Leaving 25
nitpick:comments on an urgent hotfix during a production incident.
Gotchas
- Rubber-stamping 1,500-line PRs: Nobody actually reads a 1,500-line diff; reviewers say "LGTM" out of fatigue. Split the work earlier.
- Treating style preferences as blocking: Blocking a PR over
for..ofvs.map()slows the team down and breeds resentment.
Production checklist
- Automated lint/formatting runs in CI so reviews stay focused on logic and security.
- PRs are small enough to review in 15–20 minutes.
- Reviewers use explicit blocking vs non-blocking labels (Conventional Comments).
- AI-generated diffs are verified by running tests and inspecting
git log/git diff.
Check yourself
Check Yourself
1. You spot a missing ownership check in an API handler AND a slightly awkward local variable name. How should you write those two comments using Conventional Comments?
2. An AI coding agent finishes a task and says 'All tests pass.' What should the reviewer still do?
Sources
Related Notes
DoR, DoD, and Quality Gates
Practical Definition of Ready, Definition of Done, and measurable quality gates from PR to production—using Mengty Learns' real CI, labs, and Lighthouse/axe gates.
Incident Management and Blameless Postmortems
Severity levels, incident roles (IC and comms), mitigation-first timelines, a blameless postmortem template with owned actions, and a fictional training scenario.