Sub topic 1
What Copilot Code Review Is and What It Is Not
Prerequisites
This chapter assumes you already know the following:
- Basic Git and GitHub use: branches, commits, and pull requests.
- How a human pull request review works: reviewers leave comments, then approve or request changes.
- Basic Markdown, because later chapters write instruction files in it.
You do not need a Copilot plan to read this chapter. You will need one to follow the hands-on steps in later chapters.
What Copilot code review does
Copilot code review is a feature of GitHub Copilot that reads the changes in a pull request and posts feedback on them. You ask Copilot to review a pull request the same way you would ask a teammate. Copilot then adds a review to the pull request. The review contains a short summary and inline comments attached to specific lines of the diff. A comment can include a suggested change that you can apply from the pull request page.
The feedback is generated by a language model. The model reads the diff, may look at surrounding code for context, and follows any custom instructions your repository provides. It is useful for catching the kinds of issues a reviewer can miss on a long day:
- Likely bugs, such as an unchecked null value or a missing
await. - Security problems, such as a database query built by string concatenation.
- Missing error handling.
- Unclear names and small readability problems.
- Gaps in tests.
How a review flows
The diagram shows where Copilot's review sits in a normal pull request. Copilot runs early, and you fix the obvious problems before a person spends time on the change.
What Copilot review is not
Several misunderstandings cause trouble in teams, so it helps to name them early.
It is not an approval
Copilot always leaves its review with the Comment status. It never approves a pull request, and it never requests changes. Because of this, its review does not count toward the number of required approvals in a branch protection rule. A pull request that needs one human approval still needs one human approval after Copilot has reviewed it.
It is not a replacement for a human
A person understands the goal of the change, the history of the system, and the agreements your team has made. Copilot sees the code in front of it. It can tell you that a function is missing a null check. It cannot tell you that the feature should not exist, or that the change conflicts with a decision made last quarter.
It is not a test run or a linter
Copilot does not execute your code, and it does not replace your continuous integration (CI) checks. A comment such as "this will fail for empty input" is a prediction made by reading the code. It is not the result of running anything. Keep your tests and linters in the pipeline. Rules that a linter can enforce, such as formatting, are better left to the linter.
It is not deterministic
If you request two reviews of the same diff, you may get different comments. Some comments will be wrong or will not matter. Others will be correct but phrased in a way that is hard to act on. Treat every comment as a claim to check, not an order to follow.
| Question | Human reviewer | Copilot review |
|---|---|---|
| Can approve a pull request | Yes | No, always "Comment" |
| Counts toward required approvals | Yes | No |
| Knows team history and intent | Often | Only what is in the code and your instructions |
| Runs the code | Sometimes | No |
| Available at any hour | No | Yes |
| Gives the same result each time | No, but accountable | No, and not accountable |
Steering the review
By default, Copilot decides for itself what to comment on. You can shape this with plain Markdown files in your repository. A repository-wide file, saved as .github/copilot-instructions.md, might look like this:
# Review guidelines
- Flag any new database query that is built by string concatenation.
- Point out public functions that have no tests in the same pull request.
- Prefer comments about correctness and security over style; formatting is enforced by the linter.
- Keep each comment short and say why the change is needed.These instructions guide the review. They do not guarantee it. Later chapters cover repository-wide and path-specific instruction files in detail.
Common errors in how teams use it
- Treating a quiet review as a clean bill of health. No comments from Copilot does not mean the code is correct. It means the model did not notice anything.
- Applying every suggestion without reading it. A suggested change can fix the flagged line and break something nearby. Read it as you would read a colleague's patch.
- Asking Copilot to enforce style. Style rules belong in a linter or formatter, which gives the same answer every time.
- Dropping human review to save time. The two reviews catch different problems, which is why the later chapters combine them.
Exercise
Your branch protection rule requires one approval. Copilot reviews your pull request and finds nothing to comment on. Can you merge? Explain why or why not.
Show answer
No. Copilot's review always has the "Comment" status, so it is never an approval and does not count toward the required approvals. A human reviewer must still approve. Also, a review with no comments only means the model noticed nothing, not that the code is correct.
Exercise
A teammate says, "Copilot will catch formatting problems, so we can remove the linter." Give two reasons this is a poor idea.
Show answer
Copilot is not deterministic, so it may flag a formatting problem in one review and miss it in the next, while a linter gives the same result every time. Copilot also does not run in your CI pipeline to block a merge, and it is better used for correctness and security issues than for style.