Skip to content
Team WorkflowChapter 53 / 57Intermediate6 min read

Pull Requests & Code Review

Code review best practices and what makes a good pull request, a small diff, a template-based description, reviewer duties and how to write review comments.

On this page

1. What is this practice?

A pull request (PR) does two jobs: it catches bugs before production, and it lets the team know what changed in the code and why. Review is not gatekeeping, it is a second pair of eyes.

2. Why does it matter?

Nobody really reviews a 2,000 line PR, they just scroll. Without a description the reviewer has to guess what the code is trying to do, so they comment only on style and miss the real problem (a missing auth check).

Weak PR processStrong PR process
1,500 lines, three jobs at onceUnder 400 lines, one job
Description: fixed stuffWhat, why, how it was tested
The author merges without reviewApproval from someone else
CI red but mergedNo merge without green CI
Comments get no replyEvery comment gets a reply, even just done
Review pending for weeksWithin one working day

3. When to follow it

LevelHow importantWhy
Learning projectOpen a PR for yourself and write a descriptionYou learn to explain your own work
Production codeThe full ruleEvery merge goes to production
Senior levelBeing a good reviewer, owning sensitive areasThe team's quality bar is built by you

4. Bad vs good code

Bad PR description

bash
title: Updates
body: fixed some bugs and added the thing we discussed

Good PR description

bash
title: block expired coupons at checkout

why
  expired coupons were still applied because the check used the server
  timezone, so customers in later timezones got a free extra day

what changed
  coupon expiry compared in utc in the coupon service
  checkout returns 422 with a clear message for expired coupons

how tested
  unit tests for the expiry helper around midnight utc
  endpoint tests: valid coupon, expired coupon (422), other store coupon (404)

task: link to the tracker ticket
screenshots: error message on checkout attached

Review comments: bad vs good

bash
hmm, not sure about this, maybe we could think about another approach?
bash
check the order belongs to the current store before updating

  const order = await orders.findForStore(id, user.storeId)

A good comment says in one line what to do, and gives the fix with code.

What is the difference?

ThingBadGood
TitleUpdatesWhat changed, in one line
WhyMissingThe cause of the bug and its impact
TestingMissingThe exact cases
CommentA vague questionClear instruction and code

5. How to apply it

For the author

From opening the PR to merge
Keep the work the size of one PR (under 400 lines)
Fill every section of the template, delete what does not apply
Link the task or ticket
CI green: typecheck, lint, build, tests, secret scan
Approval from someone else
Reply to every comment
The author squash merges

For big work, build a stack of PRs: the migration first, then the service and tests, then the UI.

For the reviewer

JobWhy
Read the description before the diffKnow what the code is trying to do, and ask if the "why" is missing
Look for an authorization check on every mutationThis is the most dangerous bug
Tenant scoping on every queryOne org's data must not show up for another
New env vars in .env.example?So the next deploy does not break
Tests for new endpoints?Definition of done
Block only for correctness, security or standardsNot for likes and dislikes
Review within one working day, otherwise hand it to someone elsePRs should not sit waiting

For a PR that touches auth, billing, migrations or deploy scripts, it is better to get approval from the owner of that area.

6. Exceptions and common mistakes

When the rule does not apply: a typo or a one-line docs fix does not need the full template, but it still needs a PR and green CI. AI review tools are helpful, but they do not replace a human approval.

Teams differ on merge style: some prefer squash merge (one PR, one commit), others merge commits or rebase so every small commit stays on main. With squash, the PR title becomes the final commit message, so the title must be clear.

Mistake: LGTM without reading

Why? Approval means you took responsibility, and a missing auth check is on your name too.

Better: Read at least the mutations, queries and tests, or say clearly that you cannot review it.

Mistake: A feature, a refactor and an upgrade in one PR

Why? The reviewer cannot focus on any one of them and a bug slips through.

Better: A separate PR for each job, refactor first and behaviour change after.

Mistake: Merging while ignoring a comment

Why? The reviewer does not know whether they were heard, and trust drops.

Better: Reply to every comment: you fixed it, or why you did not.

7. What to learn before and after

Final quick revision

CheckYes?
PR under 400 lines, one job
Template filled: why, what, how tested
Task linked
CI green
Approval from someone else
Every comment replied to
Reviewer checked auth and tenant scoping