Lesson 8 of 28Pull requests and code review
Receiving Feedback Without the Ego
Turn review comments into growth: triage them, clarify before you change code, push back with evidence, close every thread, and handle reviews that go wrong.
You open your first real pull request at a new job, go home, and wake up to 23 comments. Some are one word. One says "this whole approach seems off". Your stomach drops. This moment happens to every engineer, and how you handle it shapes how fast you grow and how people see you. Engineers who take review well get more reviews, learn the codebase faster, and are trusted with bigger work sooner. Engineers who get defensive get fewer, shorter reviews, and stop learning from them.
Why it stings, and why it is worth it
Code you wrote feels like part of you, so criticism of the code lands as criticism of you. It is not. A comment on line 40 says something about line 40. Repeat that until you believe it.
Text also strips out tone. "Why is this here?" said out loud with a curious face is a question. Typed at 11pm by a tired senior, it reads like an accusation. The default that works best is to assume good intent: read every comment as if a friendly colleague meant it helpfully. You will be right far more often than wrong, and when you are wrong, you still kept your own reply professional.
Here is the part juniors miss. Review is the cheapest teaching you will ever get. A senior engineer is spending their time showing you exactly how this codebase works and where the traps are. 23 comments on your first PR is not a failing grade. It is a free tutorial on your team's standards, and the number drops fast once you learn from it.
Read everything first, then triage
Do not start fixing the first comment the moment you see it. Read all of them first. Comments often relate: the "approach seems off" comment may explain six of the small ones, and fixing those six one by one is wasted work if the approach changes.
Then sort each comment into a bucket:
First question: do you actually know what the reviewer wants? Not what you guess. What they mean.
Clarify before you change code
Vague comments are common: "can this be simpler?", "hmm", "not sure about this". Guessing wastes a round trip and often makes the code worse in a new way. Restate what you think they mean, and offer a concrete option:
Reviewer: Can this be simpler?
You: Do you mean collapsing the three if-blocks into a lookup dict
(so adding a new plan is one line), or something else? Happy to
do the dict version if that's it.This works because it shows you thought about it, gives the reviewer a yes or no instead of an essay, and makes the reviewer be specific. Reviewers are often unsure themselves, and your restating helps them decide.
When the comment is "this whole approach is off"
This is the comment that hurts most, because it can mean days of work thrown away. Handle it before any of the small ones. Ask for a short call, and go in curious: what does the reviewer see that you do not? Often they know about a constraint that is written down nowhere: a service that is being retired, a table that is too big to scan, a team that already owns this logic.
Then decide together. Sometimes the answer is a rewrite, and it is better to learn that now than after merge. Sometimes the reviewer's concern can be met with a smaller change. Sometimes the right call is to merge what you have and fix the design in a follow-up, because the current version is still an improvement. Write the decision on the PR.
The lesson for next time is not "write better code". It is get design feedback earlier. Before you build anything that takes more than a day or two, post a short sketch in the team channel or open a draft PR with just the interfaces: "I'm planning to add the discount logic in the pricing service, called from the cart route. Any objections before I build it?" Five minutes of a senior's time on day one saves three days of rework on day four. The Pull requests that get reviewed fast lesson shows how draft PRs fit into this.
Reply to every thread
Every comment gets a reply, even a one-word one. The reviewer should never have to diff your next push to work out what you did with their comment.
Done in 3f2a91c.
Good catch, fixed in 3f2a91c and added a test for the empty cart.
Left as is: this matches how the other handlers do it (see orders.py:88).
Happy to change all of them in a follow-up if you think it's worth it.
Opened TICKET-1042 for the caching idea, linked in the description.Two rules teams care about. First, do not resolve someone else's question silently. If a reviewer asked "why not use the existing helper?", answer it, and let them resolve it or resolve it yourself only once the answer is there. Resolving a thread with no reply hides it, and reviewers notice. Second, after you push your fixes, re-request review so the reviewer gets a notification. Otherwise they may never know you are done.
How you push fixes depends on the team. If reviewers read changes incrementally ("changes since your last review"), add fix-up commits and do not force-push during the review, because a rewritten history makes them re-read everything. Git can tidy those commits away before merge:
git commit --fixup 3f2a91c # makes a commit titled "fixup! <original message>"git push # reviewers see just the new change# later, once approved, if the team wants a clean history:git rebase --autosquash main # folds each fixup into its target commitgit push --force-with-lease--autosquash works without -i in Git 2.44 and later; on older versions use git rebase -i --autosquash main. If your team squash-merges every PR, skip the tidying: the fix-ups vanish into one commit anyway. The Rebase, Merge and Squash lesson covers these strategies.
Pushing back well
You will sometimes be right and the reviewer wrong. Agreeing to everything is not humility; it ships worse code and teaches you nothing. Push back, but do it with reasons, evidence and trade-offs, not feelings:
Weak: I prefer it this way.
Weak: That's not how I learned it.
Strong: I kept the query in the loop on purpose: it runs at most 3 times
(one per region), and batching would mean a raw SQL join that's
harder to read. Profiled locally: 4ms total. If you still think
batching is worth it, I'm happy to switch.The strong version gives the reviewer something to check, admits the cost of your choice, and leaves the door open. That last line matters. "Strong opinions, loosely held" is the stance: argue for your view, then change it fast when you see better evidence.
Know when not to fight. Codebase convention usually wins over your preference, even when your way is objectively a bit better. A file where half the handlers raise exceptions and half return error tuples is worse than either style used consistently. If you think the convention is wrong, propose changing it everywhere, separately.
Scope creep is the other common case: "while you're here, could you also refactor the email module?" It is often a good idea and a bad fit for this PR. Agree that it is worth doing, open a ticket, link it, and keep your PR focused.
Match each review comment to the best response.
Learn from patterns, not single comments
One comment is feedback on one line. The same comment three times is feedback on you, and it is the most useful kind. Keep a short log of the themes you get, and look at it every few weeks:
Press Run (⌘ Enter) to see what happens.Four of nine comments are about tests, so this engineer's personal checklist starts with "did I test the failure paths and assert the response body?". Run your checklist during self-review, before you ask anyone. Within a month, reviewers stop needing to say it, and their comments move up to design. That shift is what growth looks like from the outside, and your manager will notice it.
What does this print?
from collections import Counter themes = ["tests", "naming", "tests", "scope", "tests", "naming"] print(Counter(themes).most_common(1))
When you cannot agree
Most disagreements end in two or three replies. When one does not, more typing will not fix it. Try these, in order:
- Move to a call. Fifteen minutes of talking beats two days of comments. Write the outcome back on the PR.
- Bring in a tie-breaker. Ask the tech lead or the code owner for that area. Frame it neutrally: "Ana and I see two options here, could you pick?" and summarise both fairly.
- Write it down. If it is a real design question that will come up again, a one-page doc or an architecture decision record settles it for everyone, not just this PR.
- Disagree and commit. Once the decision is made, implement it fully and without sulking. You can say "I still think B, but let's go with A" once, then do A well.
A big review lands on your PR. Put your response in a sensible order.
- Tap the steps below in the right order.
Hard scenarios: rude reviewers, contradictory reviewers, silent reviewers
A comment is rude. "This is a mess, did you even test it?" Do not reply in kind, and do not reply when you are angry. Answer the technical part only: "I tested the happy path; I've added tests for the empty and expired cases in 7d1e0a2." If it happens again, talk to the person privately, or to your manager. Rudeness in review is a team problem, and good managers want to know.
Two reviewers want opposite things. One says inline the helper, the other says extract it further. Do not pick one quietly and leave the other feeling ignored. Tag both in one thread: "Sam suggested X and Lee suggested Y. I lean to X because of Z. Does that work for you both?" Let them settle it, with a tech lead if needed.
The reviewer never responds. Wait one business day, then nudge politely in the PR or team channel: "Hi Jo, is this still on your list? Happy to walk through it on a call if that's faster." If it still sits, ask in the team channel whether someone else can review. Waiting silently for a week is not polite; it is lost work.
The reviewer is wrong about a fact. Show, don't argue: link the docs, paste the test output, or point to the line that handles their case. Facts end debates that opinions cannot.
- assume good intent
- Reading every review comment as if a helpful colleague wrote it, because written text loses tone.
- fix-up commit
- A small commit made with
git commit --fixup <sha>that addresses review feedback and can be folded into its target later with autosquash. - re-request review
- Telling the reviewer, through the PR tool, that you have addressed their comments and the PR is ready for another look.
- scope creep
- Requests to add work beyond what the PR was for. Usually best handled with a follow-up ticket.
- codebase convention
- The way the existing code already does something. Following it usually beats a locally better style.
- disagree and commit
- Stating your disagreement once, then fully supporting the decision the team made.