Mesrai
All guides
Learn · Code review

What is code review? Process, best practices and checklist

Updated · Mesrai editorial team

Short answer

Code review is the practice of having someone other than the author examine a code change before it is merged, to catch defects, keep the codebase consistent and share knowledge across the team. On most teams it happens in a pull request (or merge request), where reviewers comment on the diff and approve it or ask for changes. Automated checks and AI reviewers now handle much of the first pass, so human reviewers can focus on design, intent and risk.

Why teams review code

Testing shows that code does what its tests expect. Review asks whether it does what the team actually needs, in a way the team can maintain. The two catch different problems, which is why mature teams use both.

  • Find defects early. A logic error caught in review costs minutes; the same error in production costs an incident, a fix and a customer conversation.
  • Keep the codebase consistent. Review is where conventions — naming, error handling, data access — are applied to every change.
  • Share knowledge. Every review teaches at least one more person how part of the system works, reducing single points of knowledge.
  • Security and compliance. Standards such as SOC 2 and PCI DSS expect evidence that changes were reviewed before release.

Types of code review

Teams use several forms of review, often together:

TypeHow it worksBest for
Pull request reviewReviewers comment on a diff in GitHub, GitLab, Bitbucket or Azure DevOps before mergeMost day-to-day changes
Pair programmingTwo developers write the code together, reviewing continuouslyComplex or risky work, onboarding
Over-the-shoulderThe author walks a reviewer through the change in person or on a callSmall teams, urgent fixes
Formal inspectionA scheduled meeting with defined roles and checklistsSafety-critical and regulated software
Automated and AI reviewLinters, static analysis and AI reviewers comment on every pull requestFast first pass at any scale

The code review process, step by step

Whatever the Git host, an effective pull request review follows the same steps:

  • 1. Prepare a small pull request. One logical change, with a description that says why it exists, how it was tested and what reviewers should focus on.
  • 2. Let automation go first. Build, tests, linters, static analysis and an AI reviewer comment before any person looks, so humans don't spend time on what tools catch.
  • 3. Review for the expensive problems. Correctness, security and impact on other code first; style last.
  • 4. Comment clearly. Mark which comments block the merge and which are suggestions, and explain why.
  • 5. Respond and iterate. The author fixes or explains. Disagreements that go past two rounds are faster to settle in a short call.
  • 6. Approve and merge. Once required approvals and checks pass. Approve when the change improves the code, even if it isn't how you would have written it.

What reviewers should look for

Work from the most expensive problems down. Formatting belongs to linters; a reviewer's time is best spent where tools are weakest.

  • Correctness. Does the change do what the ticket asks? Are edge cases, empty inputs, errors and concurrent access handled?
  • Security. Is every request authorised for the resource it touches? Is user input validated? Are secrets kept out of the code?
  • Impact beyond the diff. Which callers, jobs or services depend on the changed code, and do they still work?
  • Performance. Queries inside loops, unbounded result sets, missing indexes and expensive work on hot paths.
  • Tests. Do the tests cover the behaviour that changed, including failure paths?
  • Readability and design. Will the next person understand this in six months? Does it fit the existing architecture?

Code review best practices for authors

  • Keep pull requests small. A widely cited study of review at Cisco (SmartBear, 2006) found defect detection falls sharply beyond roughly 200–400 lines per review and after 60–90 minutes of reviewing.
  • Write a real description. Why the change exists, how you tested it, screenshots for UI, and anything risky.
  • Review your own diff first. Catch leftover debug code and accidental changes before anyone else spends time on them.
  • Separate refactors from behaviour changes. Mechanical changes in one pull request, behaviour in another, so reviewers can skim the first and focus on the second.
  • Respond to every comment. Fix it, or explain why not; don't leave threads silently unresolved.

Code review best practices for reviewers

  • Respond quickly. Waiting for a first review is usually the longest part of a pull request's life. Many teams aim for a first response within one working day.
  • Improve the code, don't demand perfection. Google's engineering guidance: approve a change once it definitely improves the overall health of the codebase, even if it isn't perfect.
  • Label your comments. Make clear what blocks the merge and what is optional — for example with Conventional Comments labels such as 'issue (blocking):', 'suggestion:' and 'nitpick:'.
  • Explain why. A comment that explains the risk teaches; a comment that only says 'change this' gets argued with.
  • Praise good work. Pointing out a well-handled edge case is cheap and makes the rest of the review easier to hear.

How to speed up code review

Slow reviews are usually a queueing problem, not a reading problem. The changes that help most:

  • Smaller pull requests. They wait less, are reviewed more thoroughly, and merge with fewer rounds.
  • An automated first pass. AI review gives feedback within minutes, so authors fix routine issues before a person looks.
  • A first-response target. An agreed target, such as same working day, keeps pull requests from sitting idle.
  • Spread the load. Code owners plus a rotation avoid one senior engineer becoming the bottleneck.
  • Measure the wait. Track time to first review and pull request cycle time to see where time actually goes.

Manual review, static analysis and AI code review

These are layers, not alternatives. Linters and static analysis apply fixed rules quickly and deterministically. AI code review reads the change in context and can reason about intent — for example, noticing that an endpoint loads a record by id without checking the caller owns it. Human reviewers judge design, trade-offs and whether the change is the right thing to build.

AI code review best practices

  • Let AI go first, humans decide. Use AI review as the first pass on every pull request; people stay responsible for approval.
  • Tune the noise. Set severity filters and comment limits so developers read the findings instead of skimming past them.
  • Teach it your conventions. Encode team rules and context so findings match how your team builds software.
  • Review AI-written code too. Code from coding assistants needs the same review — often more, because it looks plausible even when it calls APIs that don't exist.
  • Measure what gets acted on. Track which findings developers fix, and adjust rules accordingly.

Code review metrics

Track a few signals rather than many. Time to first review and pull request cycle time show whether review is a bottleneck. Review depth — comments per changed line, or the share of pull requests merged with no comments — shows whether reviews are real. Escaped defects traced back to reviewed changes show whether review catches what matters.

Code review checklist

  • The pull request description explains why, not just what.
  • The change does what the linked ticket asks, including edge cases.
  • Every endpoint or job checks that the caller may access the data it touches.
  • User input is validated before it reaches queries, shells, file paths or templates.
  • No secrets, tokens or credentials are committed.
  • Errors are handled or propagated with context, not swallowed.
  • No queries inside loops; result sets are bounded or paginated.
  • Callers of changed functions and APIs still work.
  • Tests cover the changed behaviour, including failure paths.
  • Names and structure follow team conventions.
// mesrai

How Mesrai helps with code review

Mesrai reviews every pull request automatically before a person does. Specialised agents check bugs, security, performance and your team's own rules, and a repository graph shows how the change affects code outside the diff. Findings arrive as inline comments with suggested fixes, ranked by severity.

  • First feedback in minutes on GitHub, GitLab, Bitbucket and Azure DevOps
  • Team conventions as Mesrai Rules, in plain English or YAML
  • Business logic validation against the linked Jira or Linear ticket
  • Runs on your own LLM key — you choose the model

Sources

Further reading

?

Code review — frequently asked

7 questions
  • What is the main purpose of code review?

    +

    To catch defects and risks before code reaches production, keep the codebase consistent, and spread knowledge of the system across the team.

  • What are the steps in the code review process?

    +

    Prepare a small pull request with a clear description, let automated checks run, review for correctness, security and impact first, comment clearly, iterate with the author, then approve and merge.

  • How long should a code review take?

    +

    For a pull request of a few hundred lines, 15–60 minutes of focused review is typical. Research suggests stopping after 60–90 minutes, because defect detection drops with fatigue. If a review needs longer, the pull request is usually too big.

  • What is the difference between code review and testing?

    +

    Testing runs the code to check it behaves as the tests expect. Code review reads the code to judge whether it is correct, secure, maintainable and what the team needs. Each finds problems the other misses.

  • How can we speed up code review?

    +

    Keep pull requests small, add an automated first pass, agree a first-response target, spread reviews across a rotation, and measure time to first review.

  • Can AI do code review?

    +

    AI can do a useful first pass: it finds many bugs, security issues and performance problems within minutes and explains them in context. People stay responsible for approving changes and judging design.

  • How many reviewers does a pull request need?

    +

    One knowledgeable reviewer is enough for most changes. Add a second for security-sensitive code, shared libraries, database migrations or anything hard to roll back.