Pull requests and code review

Play this lesson

Show me first

Kai finished bouncy lasers on a branch, a separate line of commits (save points) that keeps main safe. Before merging it (combining it into another branch), Kai opens a pull request, or PR: "here are my changes, please check them before they go in".

Teammates reading each other's changes is called code review. Many professional teams require at least one review before any change is merged. Even the best developers miss their own mistakes.

Opening a PR

Kai pushes the branch (uploads its commits to GitHub), then clicks Compare & pull request. A good PR has:

Writing Closes #12 in the description links task card #12. When the PR is merged into main, GitHub closes the card by itself.

Quick check

What should a pull request description say?

  1. What changed, why, and how to test it
  2. The team's passwords, so reviewers can log in
  3. Nothing, the code explains itself
Show the answer

What changed, why, and how to test it

The description helps the reviewer understand and test the change quickly. Passwords never belong in a PR, and code alone doesn't say why a change was made.

Reviewing a PR

Remy opens the PR's Files changed tab. It shows a diff of every file: removed lines with a minus, added lines with a plus. Remy can click any line to leave a comment. Then Remy plays the branch and submits a review:

Changes requested

Remy requests changes: "Lasers bounce forever and the screen fills up. Can they stop after 3 bounces?"

Kai doesn't open a new PR. Kai fixes it on the same branch, commits and pushes. The new commit appears in the PR automatically, and Remy reviews again.

Good review comments are about the code, not the person, and they say why. "This loop runs every frame, so it might slow phones down" beats "this is bad".

Review reply

Remy, comment on line 14 of lasers.js
The bounce limit is typed straight into the code as 3. Could it live in balance.json, so we can tune it without changing code?

What should Kai do?

  1. Move the number into balance.json, then commit and push to the same branch
  2. Close the PR and start again on a new branch
  3. Merge anyway, the lasers already work
Show the answer

Move the number into balance.json, then commit and push to the same branch

It's a fair request with a clear reason. Fixing it on the same branch adds the commit to the same PR, so Remy can review it again right there.

Checks on the PR

Every PR also gets checks. A robot called GitHub Actions runs our automated tests, tiny programs that check the code does what it should. A green tick means they passed. A red cross means something failed.

Repos can have branch protection rules, like "main needs 1 approval and passing checks". The merge button stays locked until both are true. Our studio uses exactly that rule for main.

Reviewing AI-written code

AI agents can open PRs too. Review them like a teammate's, only more carefully: AI code can look neat and still be wrong.

Review the AI

PR #31: Add combo bonus
score.js- score = score + n;+ score = score + n * combo; score.test.js- test('hit adds 10 points', ...);+ // removed old test

An AI agent opened this PR, and all checks are green. What should the reviewer notice?

  1. A test was deleted instead of the code being fixed, so the green tick proves less than it seems
  2. Nothing, green checks mean it's safe to merge
  3. The file names are too short
Show the answer

A test was deleted instead of the code being fixed, so the green tick proves less than it seems

The old test probably failed because combo was not set. Deleting a failing test hides the bug instead of fixing it. Ask for the test back, and for combo to start at 1.

Merge options

Bolt says: Next lesson: docs and READMEs, so every change explains itself. Then the automated tests behind those checks.

Fact-checked 9 October 2026