How to Conduct Effective Code Reviews
The Goal of Code Reviews
The primary purpose of a code review is to ensure overall code quality, catch bugs early, and share knowledge across the team. Unfortunately, in many engineering teams, code reviews devolve into ego-driven arguments over syntax preferences or become a massive bottleneck that delays deployments for days.
To build a high-velocity, high-trust engineering culture, you must adopt strict, empathetic, and efficient code review practices.
1. Review the Code, Not the Coder
The most common mistake senior engineers make is using accusatory language. This immediately puts the author on the defensive and turns a technical review into a personal attack.
Bad: "You forgot to handle the null pointer here. Why didn't you write a test for this?" Good: "We should probably add error handling for this edge case. What do you think about adding a unit test to cover it?"
By using "We" instead of "You", you reinforce that the entire team owns the codebase, not just the author.
2. Automate Everything You Can
If you are leaving comments in a code review about missing semicolons, incorrect indentation, or unused variables, you are wasting everyone's time.
The Fix: Humans should never debate things that a computer can verify automatically.
- Enforce Prettier for formatting.
- Enforce ESLint for syntax and basic bug catching.
- Enforce Husky pre-commit hooks so developers literally cannot push code that fails linting.
Code reviews should focus entirely on architecture, business logic, security, and performance.
3. Keep Pull Requests Small
There is an old engineering joke: "A 10-line PR gets 10 comments. A 1000-line PR gets 'Looks good to me' (LGTM)."
When a Pull Request (PR) contains 2,000 lines of code across 45 files, it is physically impossible for a reviewer to actually comprehend the architectural impact of the changes. They will just skim it and approve it, letting massive bugs slip into production.
The Fix: PRs should do one thing. If you are building a new feature and you notice a bug in an unrelated file, do not fix that bug in your feature PR. Open a separate, 5-line PR for the bug fix. Aim to keep PRs under 400 lines of code.
4. Ask Questions Instead of Giving Commands
When you spot a weird implementation, it's tempting to just tell the developer exactly how to rewrite it. However, the author might have had a very specific reason (like a weird API limitation) for doing it that way.
Bad: "Extract this logic into a separate helper function." Good: "Is there a reason we're keeping this logic inline? I wonder if extracting it to a helper function might make this easier to test."
5. Respond Promptly
Code reviews are the ultimate bottleneck in CI/CD pipelines. If a developer finishes a feature on Tuesday, but it doesn't get reviewed until Thursday, that developer has lost all context of what they were working on.
As a rule of thumb, code reviews should be your highest priority task when you start your day, or right after you return from lunch. Unblocking your teammates is often more valuable to the company than writing your own code.
Conclusion
Code reviews are a social exercise as much as a technical one. By automating the trivial stuff, keeping PRs small, and communicating with empathy, you can turn code reviews from a dreaded chore into a powerful mentoring tool.