Summarize code review best practices
Demonstrate code review on a pull request
Code review, like peer review, enhances the quality of the work being submitted. All involved parties are collaborating to improve the final product of the pull request.
When performing code review, you are using your expertise to weigh in on a contribution. You aren’t going to have expertise on everything, but your experience with the code and with using it is relevant and valuable.
As a person getting code reviewed: appreciate the reviewer taking time to give you feedback on your work! They are invested and interested in what you’re contributing.
maintainer — a person who keeps things running in a software project. Sometimes maintainers aren’t focused on new features, but instead on overall project infrastructure and usability.
contributor — a person submitting a PR, issue, or feedback to a project. They may have never interacted with the project, or they may do so frequently.
user — people who use the code but don’t contribute upstream. Think about how changes in your code might affect these people, since they’re often not weighing in during code review.
A structured back-and-forth to improve a change before it lands on main:
I like this description from GitLab.
Read the PR description. What does the author want this code to do? Is it useful and applicable to the code it’s being submitted to (is it in scope)?
Read the documentation submitted with the code. Do I understand how to use it now? Is there anything ambiguous that could be enhanced by clarification? Are there docs missing that need to be added?
Look through the code. Do I follow the logic of what’s being done? I ask questions if I don’t.
Check the tests. Have tests been added for any new features? Do they cover the scope of the new feature? Do they help me understand the code in any way?
Consider the user. Is the API of the code changing from what already exists? Will it impact users significantly?
Suggest constructive improvements. Do I see a lot of repeated functionality that can be put into a single function? Do I see a place where a design pattern could be used? I try to add suggestions for improvement as code snippets.
Try to use the feature. I don’t always do this, but for new features I do. Do I run into any errors when I use it? Does it make sense in my workflow?
I also like to use a good code review checklist so I don’t forget things. Here’s the one my group uses: arfc.github.io/manual/guides/pull_requests
A lot lives on one screen — the next slide names the pieces you’ll actually click.
Your reviews are there to enhance the code that was submitted, for other maintainers, developers, and users. You are collaborating with the author.
Using a linter and formatter means that reviews avoid style bikeshedding.
Having good test coverage and CI means that a new contributor gets automatic feedback on how their code fits into your project.
This also allows code reviewers to focus on code readability and applicability, rather than helping the author debug.
Having good developer documentation (what linter and formatter does your code use? what is your docs style?) helps make the contributor experience a bit less iterative.
Having your issue tracker with clearly described issues helps people other than you understand what’s going on in the project.
Labeling issues with things like “good first issue”, and what type of fix the issue is (e.g. documentation, testing, or something feature-specific), means potential contributors can more easily choose a contribution they are comfortable with. This also ensures the contribution somebody addresses from the issue tracker is relevant to the project.
Consider having a project description in your README. What is the purpose of your code? What is it? What is it not?
If you know the contributor and you have done a few rounds of review, consider scheduling a call or sitting down with them to try to resolve things.
Getting your own code reviewed can be exciting — but it can also be a little nerve-wracking.
Let’s talk a bit about the process of responding to a code review.
Tools like GitHub Copilot and Claude can now pre-review a PR — summarizing the diff, flagging obvious bugs, and suggesting tests.
Used well, they’re a first pass that frees humans for the judgment calls:
The bot is a reviewer, not the reviewer. Treat its output like any other comment — weigh it, don’t rubber-stamp it.