# Code review

> Having another person read a code change before it becomes part of the product.

- Level: Intermediate
- Topics: Software
- URL: https://tidbit.legios.com.ar/code-review/
- In Spanish: [Revisión de código](https://tidbit.legios.com.ar/es/code-review/)

**Code review** is the practice of having at least one other developer read and approve a change before it is merged into the main code. Today it almost always happens through a **pull request** (GitLab calls it a **merge request**): the author pushes their change to a separate branch, opens a page that shows exactly which lines were added and removed, and explains why.

Reviewers read the diff and leave comments on specific lines: "this breaks if the list is empty", "there is already a function for this", "can we name it something clearer?". The author answers or updates the change, and the conversation repeats until a reviewer **approves** it. Meanwhile automated checks run on the same pull request, from tests to formatting rules, so humans can focus on what machines cannot judge.

It catches bugs, but research and experience suggest its bigger value is spreading knowledge: more than one person understands each part of the system, newcomers learn the codebase's conventions, and decisions are written down next to the code. It works best with small changes, which are reviewed faster and more carefully than huge ones, and with a kind, specific tone, since the code is being reviewed, not the person. AI tools now often add a first pass of automated review comments.

## An analogy

Like having a colleague proofread an important email before you send it to a client. They catch typos, but more often they say "this part could be misunderstood", and next time you write it better yourself.

## Keep in mind

- A pull request shows the exact change and collects the discussion about it.
- Usually at least one approval is required before merging.
- Shares knowledge as much as it catches bugs.
- Small changes get better reviews than big ones.

## Go deeper

- [About pull request reviews (GitHub docs)](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/about-pull-request-reviews)
- [Google's code review guidelines](https://google.github.io/eng-practices/review/)
- [Code review on Wikipedia](https://en.wikipedia.org/wiki/Code_review)

## Related terms

- [Bug](https://tidbit.legios.com.ar/bug/): A mistake in software that makes it behave differently from what was intended.
- [Source code](https://tidbit.legios.com.ar/source-code/): The human-readable text that programmers write and that a program is built from.
- [Artificial intelligence](https://tidbit.legios.com.ar/artificial-intelligence/): Getting computers to do things that, until recently, only people could do.
