Sub topic 1
What Copilot code review is and what it is not
Prerequisites
This chapter assumes you can do the following:
- Use Git and GitHub day to day: create branches, push commits, and open pull requests.
- Understand how a human pull request review works, including the "Comment", "Approve", and "Request changes" outcomes.
- Read basic Markdown. Later chapters use YAML frontmatter, but this chapter does not require it.
You do not need a Copilot plan to read this chapter. You will need one to try the steps in later chapters. Chapter "Plans, access, and enablement" covers which plans include code review.
What Copilot code review does
Copilot code review is a GitHub feature that reads the changes in a pull request and posts review feedback. A pull request is a proposal to merge one branch into another. Copilot looks at the diff (the lines added, changed, and removed) and at some surrounding context in the repository. It then leaves comments on specific lines, and sometimes proposes a concrete code change you can apply with one click.
You request it the same way you request a human reviewer. Open the pull request, open the Reviewers menu in the sidebar, and select Copilot. A few moments later, Copilot posts a review.
The feedback usually falls into these groups:
- Likely bugs, such as an off-by-one error, a missing null check, or an unhandled error path.
- Security concerns, such as a database query built by string concatenation.
- Missing tests for new public functions.
- Maintainability problems, such as duplicated logic or unclear names.
- Small fixes that can be expressed as a suggested change.
Copilot is a reviewer that answers quickly, at any hour, and without needing a teammate's time. That makes it useful as a first pass. It is not a replacement for the people who understand your product and own the code.
How a review is produced
Copilot code review uses a large language model (LLM). An LLM is a model trained on large amounts of text and code that generates output by predicting likely continuations of its input. For a review, the input includes your diff, the relevant files, and any custom instructions your repository provides. The output is review text and suggested edits.
This has three consequences that shape how you should use the feature.
- The model does not run your code. It reads it. It can reason that a loop looks wrong, but it does not execute your tests or observe real behavior.
- The output is probabilistic. Two reviews of the same diff can differ. Comments can appear in one run and not the next.
- The model works from the context it is given. It may not see your deployment setup, your team's agreements, or the incident that led to a strange-looking workaround.
The flow below shows where Copilot sits in a typical pull request.
What it is not
Most mistakes with this feature come from treating it as something it is not. Four distinctions matter.
It is not an approval
When Copilot finishes, it posts a review with the "Comment" status. It does not post "Approve" and it does not post "Request changes". A comment review does not count toward the number of approvals a branch protection rule requires, and it does not block a merge.
So a pull request that has a Copilot review and no human approval is still unreviewed in the sense that matters for your merge policy. If your repository requires one approving review, Copilot cannot supply it.
It is not a static analyzer or a test suite
A linter or a static analysis tool applies fixed rules. Given the same code, it produces the same findings every time. Tests execute your code and assert results. Copilot does neither of these. The table below compares them.
| Property | Linter or static analyzer | Test suite | Copilot code review |
|---|---|---|---|
| Method | Fixed rules over syntax or data flow | Runs code and checks results | Language model reads the diff |
| Repeatable on the same input | Yes | Yes, if tests are deterministic | Not guaranteed |
| Can explain intent and context | No | No | Often, in plain language |
| Can miss real defects | Yes, outside its rules | Yes, outside tested paths | Yes, and unpredictably |
| Can report false problems | Sometimes | Rarely | Yes |
| Runs your code | No | Yes | No |
The practical conclusion is to keep your linter, formatter, and tests in your pipeline. Copilot adds a different kind of check. It does not remove the need for the existing ones. This is also why a good custom instruction tells Copilot to skip style comments that your linter already enforces, a technique covered in a later chapter.
It is not a teammate with project knowledge
A human reviewer knows why the billing module is odd, which customers depend on a legacy endpoint, and what the team agreed last quarter. Copilot knows what is in the diff, what it can see in the repository, and what your instruction files say. If something important is not written down in one of those places, Copilot cannot use it.
This is the reason repository custom instructions exist. They are a way to write down review priorities so that the model has them. They narrow and steer the review. They do not give the model real understanding of your product.
It is not guaranteed to be complete or correct
Copilot's review can fail in two directions:
- False negatives: a real problem exists and Copilot does not mention it.
- False positives: Copilot raises a problem that is not real, or suggests a change that is wrong, unsafe, or does not compile.
Both happen. A suggestion that looks plausible can still introduce a bug, because the model optimizes for output that reads as correct. You are responsible for every change you apply, whether a human or Copilot proposed it.
A worked example
Suppose a pull request adds this function to a Python service.
import sqlite3
def find_user(conn: sqlite3.Connection, name: str):
query = "SELECT id, email FROM users WHERE name = '" + name + "'"
return conn.execute(query).fetchone()A useful Copilot review of this diff would likely do the following:
- Flag the string concatenation as a SQL injection risk, because
namecomes from the caller and goes straight into the query. - Suggest a parameterized query.
- Possibly note that the function has no test in the pull request.
The suggested fix would look like this:
import sqlite3
def find_user(conn: sqlite3.Connection, name: str):
query = "SELECT id, email FROM users WHERE name = ?"
return conn.execute(query, (name,)).fetchone()This is a good case for automated review. The problem is visible in the diff, the fix is local, and the fix is safe to check by reading it.
Now consider what Copilot is less likely to catch here. Suppose the users table has a unique index on email and not on name, and the business rule is that names are not unique. Then fetchone() quietly returns an arbitrary match. Nothing in the diff shows that rule. A teammate who knows the data model would raise it. This is the kind of gap that human review fills.
What you should expect from a review
Setting accurate expectations helps you use the tool well.
- Speed: Reviews typically arrive within a short time after you request them. The exact time varies with the size of the change and with load.
- Status: The review is a "Comment" review. Nothing in it is binding.
- Scope: Comments attach to lines in the diff. Copilot concentrates on what changed, not on a full audit of the whole codebase.
- Variation: Re-requesting a review after new commits may produce different comments, including on code it did not comment on before.
- Actionability: Some comments include a suggested change you can commit directly. Others are observations you must act on yourself.
When it helps and when it does not
Copilot review pays off most in these situations:
- You want quick feedback before asking a teammate to spend time on the pull request.
- You work on a small team or alone, and no one is immediately available to review.
- You want a second look for common issues such as unchecked errors, missing tests, or risky patterns.
- Reviewers on your team want to spend their attention on design and domain questions, not on small mechanical fixes.
It helps least in these situations:
- The correctness of the change depends on business rules that are not in the code or instruction files.
- The change is mostly generated or vendored code, where comments are noise.
- The risk is architectural, such as a change in data ownership between services.
- You are tempted to merge on the strength of Copilot's review alone.
How the rest of the tutorial builds on this
This chapter sets the frame: Copilot's review is fast, automated, advisory feedback from a language model. The chapters that follow turn that frame into practice. You will learn to request a review, read and act on its comments, re-request after new commits, steer it with instruction files, run it automatically, and combine it with required human review.
Exercise
A pull request has a Copilot review with no comments, and your branch protection rule requires one approving review. Can the pull request be merged, and what does the empty review tell you?
Show answer
No, Copilot cannot satisfy the approval requirement. Its review has the "Comment" status, which does not count as an approval, so a human with the right permissions must still approve. An empty review only means the model reported nothing on a fast first pass. It is not proof that the change is correct, because the model does not run the code, can miss defects, and may not know your project's rules.
Exercise
Name two reasons you should keep your linter and test suite even when Copilot reviews every pull request, and give one kind of problem a human reviewer is more likely than Copilot to catch.
Show answer
First, linters and tests are deterministic: the same input gives the same result, while Copilot's output can vary between runs. Second, tests actually execute the code, and Copilot only reads it. A human reviewer is more likely to catch a problem that depends on unwritten project knowledge, such as a business rule that names are not unique, a customer depending on a legacy endpoint, or an architectural decision made in a past discussion.