How to review a pull request in code you don't know
Reviewing a PR in an unfamiliar part of the codebase? A method for building just enough context to review well: intent, call sites, contracts, tests and risk.
Sooner or later you'll be asked to review a pull request in code you've never seen. The diff looks reasonable, but you can't tell what it might break. Approving it blindly isn't a review, and learning the whole module first isn't practical. Here's a way to build just enough context.
1. Understand the intent before the code
Read the PR description, the linked issue and any screenshots. Write one sentence: "This change makes X do Y because Z." If you can't, ask the author before reading the diff. Reviewing code without knowing its goal turns into nitpicking style.
2. Find the changed functions' callers
For each function, component or endpoint the diff modifies, find who uses it:
- "Find all references" in your editor, or code search on GitHub
- For endpoints, search for the URL path in front-end code and other services
- For exported library functions, check whether they're part of the public API
A change to a function with one caller is a local change. A change to one with forty callers is an API change, whatever the diff size.
3. Check the contract
For each modified function, compare before and after:
- Inputs: are new parameters optional, or do callers need to change?
- Outputs: can it now return
null, throw a new error, or take longer? - Side effects: does it now write somewhere, send something, or skip something it used to do?
Callers rely on the old contract. Any change to it needs every caller checked.
4. Read the surrounding code, not just the diff
GitHub's "expand" arrows show lines around each hunk. Expand enough to see the whole function and the code just above where it's called. Many bugs live in what the diff didn't change: a condition upstream that no longer holds.
5. Look at the tests
- Do new tests cover the new behaviour and at least one failure case?
- Were existing tests changed? A test changed to make it pass deserves a careful look.
- If there are no tests, ask what was tested manually.
6. Think about the unhappy paths
Ask: what happens with empty input, a missing record, a timeout, a duplicate request, a user without permission? Reviewers catch most real bugs here.
7. Assess risk honestly
Low-risk: copy changes, isolated new code behind a flag, test-only changes. High-risk: auth, payments, data migrations, shared utilities, concurrency. Spend your review time in proportion.
8. Write useful comments
- Ask questions when you're unsure ("What happens to existing sessions after this?") rather than asserting.
- Separate blocking concerns from suggestions.
- If the PR is too big to review well, say so and suggest how to split it.
Getting context faster
Before reviewing, ask RepoGrasp about the code the PR touches: "what calls applyDiscount, and what do callers assume it returns?" You'll get the call sites and contract with file:line citations to check. Automated review bots can flag issues, but the person approving still needs to understand the code. See RepoGrasp vs CodeRabbit.
A short checklist
- I can state the intent in one sentence
- I know who calls each changed function
- I've compared the before and after contract
- I've read the whole changed functions, not just the hunks
- I've checked tests and unhappy paths
- My comments separate blockers from suggestions
Get context with RepoGrasp before your next review.