Skip to content
Visual explainer 2h to learn 3 steps

Pull requests & code review

Open small reviewable PRs and give useful reviews.

By Invicly Tech, , in Git, GitHub & GitHub Actions. About 9 minutes to read.

Topic 6 of 18

In short

A pull request proposes merging one branch into another and is where review happens. Small, focused PRs with a clear description get faster, better reviews.

Explained simply

A pull request (PR) is a request to merge your branch into another branch, usually main. It shows the changes as a diff (lines removed in red, lines added in green), runs the automated checks, and gives teammates a place to comment before anything lands.

Small PRs are the secret to fast reviews. A PR that changes 50 lines gets read carefully in ten minutes. A PR that changes 2,000 lines gets skimmed or ignored for days. If a feature is big, split it into several PRs that each make sense alone.

The description is your message to the reviewer. Say what changed, why it was needed and how to check it. Link the issue it solves. A reviewer who understands the goal finds real problems instead of guessing.

Reviewing is a skill too. Good comments point at specific lines, explain the reason, and make clear whether something must change or is just a suggestion. The goal is better code and a team that learns from each other, not proving who is smarter.

Press Play on a diagram to walk through it one step at a time.

CycleThe review loop
  1. 1
    Open small PR

    One focused change with a clear description.

  2. 2
    CI runs

    Checks report pass or fail on the PR.

  3. 3
    Reviewer comments

    Specific, actionable suggestions or questions.

  4. 4
    Author updates

    Push fixes and reply to each comment.

  5. 5
    Re-review

    Approve, or loop again until ready.

  6. Back to step 1
LayersWhat to check, most important first
  1. 1
    Correctness

    Does it do what the issue asks, including edge cases?

  2. 2
    Security

    Input validation, secrets, permissions

  3. 3
    Design

    Right place, right abstraction, easy to change

  4. 4
    Tests

    Cover the new behaviour and the bug fixed

  5. 5
    Readability

    Names, comments, small functions

  6. 6
    Nits

    Optional polish, never blocking

In depth

What makes a PR easy to review

Reviewers find more bugs in smaller changes. Studies of code review often quote a few hundred lines as the point where attention drops sharply. So keep a PR to one purpose: a refactor, a feature or a fix, not all three. Move formatting changes or file renames into their own PR, because they bloat the diff and hide the real change.

Tell a story with commits if the team keeps them, and always in the description. Include screenshots for UI changes, sample requests and responses for APIs, and the exact commands to test. Open a draft PR early to share direction or get CI feedback, then mark it ready for review when it is done.

  • One purpose per PR
  • Separate refactors and formatting from behaviour changes
  • Self-review your own diff before asking anyone
  • Use a draft PR to ask early questions

Templates, linked issues and stacked PRs

A file at .github/pull_request_template.md pre-fills every new PR description, so What, Why and How to test are always there. For several templates, put them in .github/PULL_REQUEST_TEMPLATE/ and choose one with ?template=name.md in the compare URL.

Words like Fixes #42, Closes #42 or Resolves #42 link the issue and close it when the PR merges into the default branch. For large features, stack PRs: PR 2 targets PR 1's branch instead of main, so each diff stays small. When PR 1 merges and its branch is deleted, GitHub automatically retargets PR 2 to main.

Review states and suggestions

When you submit a review you choose one of three states. Comment gives feedback without a verdict. Approve says it is ready. Request changes blocks the merge (if branch protection requires approvals) until you approve or the review is dismissed. Start a review instead of single comments so the author gets one notification with everything.

A suggestion is a special comment containing replacement code for the selected lines. The author can click Commit suggestion, or batch several suggestions into one commit. Mark files as Viewed to track your progress, and use the hide whitespace option when indentation changed. The author should reply to or resolve each conversation, then click re-request review.

SequenceOne review round on GitHub
Author
Pull request
Reviewer
  1. 1Mark ready for review
    Author to Pull request: Mark ready for review
  2. 2Review requested
    Pull request to Reviewer: Review requested
  3. 3Comments and suggestions, Request changes
    Reviewer to Pull request: Comments and suggestions, Request changes
  4. 4Commit suggestions, push fixes
    Author to Pull request: Commit suggestions, push fixes
  5. 5Re-request review
    Author to Reviewer: Re-request review
  6. 6Approve
    Reviewer to Pull request: Approve

Writing review comments people can act on

Review the important things first: does it work, is it safe, is the design right, are there tests. Style and naming come last, and a linter should catch most of them. Ask questions when you are unsure ("What happens if items is empty here?") rather than stating guesses as facts.

Many teams use labels at the start of comments, sometimes called Conventional Comments: nit: for optional polish, suggestion: for an improvement, issue: for a real problem, question: for clarification, praise: for something done well. The prefix tells the author what blocks the merge. Praise matters too; pointing out a good test teaches as much as pointing out a bug.

Learn it in 3 short steps

About 40m each. Track them with a timer in your plan.

  1. 1
    Open a small, focused PR~40m
  2. 2
    Write a clear PR description~40m
  3. 3
    Leave actionable review comments~40m

Key points

  • Aim for PRs a reviewer can read in under 20 minutes.
  • Describe what changed, why, and how to test it; link the issue.
  • Comment on the code, not the person, and explain the reason for each request.
  • Mark optional suggestions as nits so authors know what is blocking.

Key terms

Tap a card to flip it. 0/5 known

Examples

markdown
## What
Add /health endpoint returning app and DB status.

## Why
The load balancer needs a real health check. Fixes #42.

## How to test
1. docker compose up
2. curl localhost:8000/health
3. Stop the db container and expect status 503

A PR description that is quick to review.

Splitting a big change into reviewable PRs

You built CSV export: a new database query, a service function, an API endpoint and a button, 1,400 lines in total. Step 1: PR 1 adds the query and its tests. Step 2: PR 2, based on PR 1's branch, adds the service and the endpoint behind a feature flag. Step 3: PR 3 adds the button and turns the flag on. Each PR is under 500 lines, can be reviewed in one sitting, and is safe to merge on its own.

bash
git switch -c export/query main      # commit query + tests
gh pr create --fill --base main
git switch -c export/api             # branch off export/query
gh pr create --fill --base export/query
git switch -c export/ui              # branch off export/api
gh pr create --fill --base export/api

Turning a vague comment into an actionable one

A reviewer writes: "This is wrong." The author cannot tell what to fix. A better comment names the problem, explains why it matters and proposes a fix, as a suggestion the author can commit in one click. Compare the two below. The second takes 30 seconds longer to write and saves a round trip.

markdown
Bad:  This is wrong.

Good: issue: if `items` is empty, `items[0]` raises IndexError
and the endpoint returns 500. Could we return 404 instead?

```suggestion
if not items:
    raise HTTPException(status_code=404)
first = items[0]
```

Quick reference

  • .github/pull_request_template.md pre-fills every new PR description
  • Fixes #42 or Closes #42 closes the issue when the PR merges into the default branch
  • Draft PRs run CI but cannot be merged; gh pr ready marks them ready
  • Request changes blocks merging when approvals are required
  • Start a review and submit once, instead of many single comments
  • Prefix comments with nit:, suggestion:, issue: or question: to show what blocks
  • Add ?w=1 to a PR files URL to hide whitespace-only changes
  • gh pr merge --auto --squash merges by itself once checks and reviews pass

Common mistakes

  • Giant PRs mixing refactors, features and formatting changes.
  • Approving without running or reading the code because CI is green.

Quick quiz

Pick an answer to see if you're right and why.

Question 1

1Why are small PRs reviewed better?

Question 2

2PR 2 targets PR 1's branch. PR 1 is merged and its branch deleted. What happens to PR 2?

Question 3

3Which review state blocks merging when branch protection requires approvals?

Question 4

4What does the prefix nit: tell the author?

0/4 answered

Practice exercises

Try each one yourself first. Use the hint if you get stuck, then compare with the solution.

  1. Exercise 1easy

    Add a PR template to your repo with What, Why and How to test sections, then open a PR and check it is pre-filled.

  2. Exercise 2medium

    Open a draft PR from the terminal, push one more commit, then mark it ready and request a review from a teammate.

  3. Exercise 3hard

    Review a teammate's PR from the terminal: check it out, run the tests, then submit a Request changes review with a clear, prefixed comment.

Check yourself

Answer in your head, reveal, then be honest with yourself.

Feel confident about this topic?

Frequently asked questions

How big should a pull request be?
Small enough to review in one sitting, often under a few hundred changed lines. Generated files and lockfiles count less, but behaviour changes should stay focused.
What is a draft pull request for?
It shares work in progress: CI runs and people can comment, but it cannot be merged and reviewers are not asked to review until you mark it ready.
Should the author or the reviewer click merge?
Teams differ, but a common rule is that the author merges after approval, because they know when the change is safe to ship.
What does "dismiss review" do?
It removes an approval or change request so it no longer counts toward the merge rules, for example when the reviewer is away and the issue was fixed.

Go deeper

ShareXLinkedInWhatsApp