What Is Code Review, and How Do Teams Do It Well?
Code review is having another developer read a change before it ships, to catch bugs, share knowledge and keep the codebase consistent. Learn how it works.
On this page
Short answer
Code review is the practice of having one or more developers read and comment on a code change before it is merged. The reviewer checks the change for bugs, readability and fit with the codebase, and the author answers questions and fixes what the reviewer finds, so the code that ships has been read by at least two people.
What is code review?
Code review is a check on a proposed code change, done by a developer who did not write the change, before that change is merged into the main codebase. The author opens a pull request or merge request, the reviewer reads the diff, leaves comments and questions, and approves the change only when the comments are resolved.
The review looks at several things at once. The reviewer checks whether the code does what it claims to do, whether it handles errors and edge cases, whether it is readable, and whether it follows the team's conventions for naming, structure and tests. A good review also asks whether the change is the right size: a change that does too many things at once is hard to review well.
Code review is not a formality. It is the last shared look at a change before it reaches users, and it is also how a team spreads knowledge: a reviewer learns how a new part of the system works, and an author learns how a more experienced developer would have written it.
Why does code review matter?
Code review matters because it catches problems while they are still cheap to fix. A bug found in review costs a comment and a small edit; the same bug found in production costs an incident, a hotfix and often an apology to users.
It also keeps the codebase consistent. When every change passes through another pair of eyes, the team converges on shared conventions for structure, naming and error handling, which makes the code easier to read for everyone. A codebase that many people have read is easier to change than one that only its author understands.
The third benefit is knowledge sharing. Review spreads understanding across the team, so no single person becomes the only one who understands a critical part of the system.
That matters most when someone is away or leaves, because the team can keep working on code that more than one person has read. Teams that build software together usually pair review with custom software development practices that keep quality checks part of the daily routine, not a separate phase.
How does code review work in practice?
Code review works as a short loop between the author and the reviewer, and it runs on almost every change the team ships. The loop is simple, but the discipline is in keeping it short and focused.
- Write a small change. The author keeps the change focused on one job, with a clear title and a short description of what it does and why.
- Open a pull request. The author requests review from one or two people who know the area, and the CI pipeline runs tests on the change.
- Review the diff. The reviewer reads the change, checks the tests, and leaves comments on anything unclear, risky or inconsistent.
- Discuss and fix. The author answers questions, fixes what needs fixing, and pushes new commits to the same pull request.
- Approve and merge. Once the comments are resolved and the tests pass, the reviewer approves and the change is merged.
The whole loop should usually take hours, not days. A pull request that sits open for a week goes stale, conflicts pile up, and the author moves on to other work, which makes the eventual merge harder than it needed to be.
What should a reviewer check?
A reviewer should check correctness first, then readability, then consistency with the rest of the codebase. The table below gives a practical order, because a review that starts with style nits and never reaches the logic has missed the point.
| Check | What to look for | Why it matters |
|---|---|---|
| Correctness | Does the code do what the description says? | Bugs caught here are cheap to fix |
| Edge cases | Empty input, missing data, errors, timeouts | Edge cases cause most production incidents |
| Tests | Do tests cover the new behaviour? | Untested code breaks silently later |
| Readability | Clear names, small functions, no clever tricks | Code is read far more often than written |
| Security | Untrusted input, secrets, access checks | Security holes are hard to fix after release |
| Consistency | Same patterns as the surrounding code | Consistent code is easier to change |
A reviewer should not re-test everything the CI pipeline already checks. Formatting, linting and test runs belong in automation, so the human review can focus on the things a machine cannot judge: whether the change is the right approach, and whether the next person to read it will understand it.
Example (hypothetical): the cost of slow review
Example (hypothetical): a team of 6 developers opens 20 pull requests in a week, and each review takes about 30 minutes of a reviewer's time. That is 20 times 30 minutes, which is 600 minutes, or 10 hours of review time in a week, spread across the team.
When reviews take 3 days on average, authors start opening larger pull requests to avoid waiting, and the average change grows from 200 lines to 600 lines. Reviewers then need more than an hour per change, so the same 20 changes take over 20 hours of review time, and more comments get missed because a 600-line change is hard to read carefully.
The team agrees a rule: changes stay under 300 lines, and reviews happen within one working day. Review time falls back to about 10 hours a week, and the number of bugs found in review rises, because reviewers can actually read a 300-line change properly. The numbers are invented to show the arithmetic, not a real team's data.
What are the common mistakes in code review?
The most common code review mistakes are reviewing too slowly, reviewing too much at once, and reviewing the wrong things. Each one makes review feel like a burden, which makes the team do it less carefully.
- Letting reviews sit for days. Slow review blocks authors and pushes them towards bigger, harder-to-review changes.
- Reviewing huge changes. A 1,000-line change cannot be reviewed carefully; split it into smaller, reviewable pieces.
- Arguing about style. Style debates belong in a formatter and a style guide, not in review comments.
- Rubber-stamping. Approving without reading defeats the purpose and teaches the team that review is theatre.
- Being harsh in comments. A review that reads as criticism makes authors defensive and slows the next review down.
A good review reads like a conversation between colleagues: questions first, suggestions second, and praise where the code is genuinely well done. DevOps practices help here too, because automated tests and pipelines take the mechanical checks off the reviewer's plate.
How do you start doing code review well?
You start doing code review well by making small changes the norm and review speed a team habit, rather than by writing a long policy document. The process works when it is fast, kind and focused on the change in front of you.
- Keep changes small. Aim for changes under 300 lines, focused on one job, with a clear description.
- Review within a day. Treat a review request like a message from a colleague, not a task for the end of the week.
- Automate the mechanical checks. Formatting, linting and tests should run in CI, so reviewers judge logic, not commas.
- Write a short checklist. Correctness, edge cases, tests, readability, security and consistency, in that order.
- Review as a team habit. Share the load so no one person becomes the bottleneck, and pair new developers with experienced reviewers.
Teams that hire or grow developers often combine review habits with a dedicated development team setup, where review is part of how the team works every day.
DevOps services can help set up the CI pipeline that makes review fast.
Key takeaways
- Code review is a second pair of eyes on a change before it is merged
- It catches bugs cheaply, keeps the codebase consistent and spreads knowledge
- Keep changes small and review within a day, or review quality falls
- Automate formatting and tests so reviewers can focus on logic
- Good reviews read like a conversation, not an inspection
Frequently asked questions
How long should a code review take?
A small change should usually be reviewed within a few hours, and almost always within one working day. Reviews that sit for days go stale, block the author, and push the team towards larger changes that are harder to review. If a review regularly takes days, the team should look at change size and reviewer load, not at reviewer effort.
How many reviewers should a change have?
One careful reviewer is enough for most changes, and two is a good default for risky areas such as payments, security or database migrations. More than two reviewers usually slows the process down without adding much, because responsibility spreads and each reviewer assumes another will catch the problems.
Should the author review their own code first?
Yes. The author should re-read the diff before requesting review, because most authors spot their own mistakes, leftover debug code and unclear naming on a second read. A self-review also makes the change easier for the reviewer, which usually means faster and better feedback.
What is the difference between code review and pair programming?
In pair programming, two developers write the code together in real time, so review happens as the code is written. In code review, the author writes the change alone and a reviewer reads it afterwards. Pair programming gives faster feedback; code review gives the reviewer time to think and leaves a written record of the discussion.
Can code review slow a team down?
It can, if reviews sit for days or changes are huge. But a team without review usually pays more later, in production bugs and in code that only one person understands. The fix is not to skip review, but to keep changes small, review quickly, and automate the checks a machine can do.
Should juniors review senior developers' code?
Yes. Junior developers ask the questions that reveal unclear code, and reviewing senior code is one of the fastest ways for a junior to learn the codebase. The author should welcome the questions, because a change that a junior cannot follow is a change that the next reader will also struggle with.