Sub topic 10
Getting a review in your editor before opening a pull request
This chapter assumes you can already request a Copilot review on a pull request, as covered earlier. It also assumes you use an editor with Copilot installed, such as VS Code, Visual Studio, or a JetBrains IDE. The steps below use VS Code wording. Menu names differ between editors and versions, so check your editor's Copilot documentation if a label does not match.
Why review before the pull request
A review on a pull request is public. Teammates see the comments, and the history records every fix. An editor review is private. Copilot looks at your local changes, and you fix the obvious problems before anyone else sees them.
This gives you three benefits:
- Your pull request opens with fewer trivial issues.
- You get feedback while the code is still fresh in your mind.
- Fixes go into your working tree, so you avoid extra "address review" commits.
Two ways to ask for a review
In VS Code you can start a review in two ways:
- Review a selection. Select some code, right-click, and choose the Copilot review action (under the Generate or Copilot submenu). Copilot reviews only that code.
- Review all changes. In the Source Control view, use the Copilot code review button. Copilot reviews your uncommitted changes. Some versions also let you choose between staged and unstaged changes.
Copilot shows its comments inline in the editor, next to the lines it is commenting on. Many comments include a suggested change. You can apply it, or discard the comment if you disagree.
A worked example
Suppose your repository has the instruction file from the earlier chapter on custom instructions. It tells Copilot to flag database queries built by string concatenation. You write this function:
import sqlite3
def find_user(conn, name):
query = "SELECT id, name FROM users WHERE name = '" + name + "'"
return conn.execute(query).fetchall()
if __name__ == "__main__":
conn = sqlite3.connect(":memory:")
conn.execute("CREATE TABLE users (id INTEGER, name TEXT)")
conn.execute("INSERT INTO users VALUES (1, 'ada')")
print(find_user(conn, "ada"))You select the function and ask for a review. Copilot should flag the concatenated query and suggest a parameterized one. Because comments vary from run to run, treat this as the expected result, not a guarantee. If you accept the suggestion, the function becomes:
def find_user(conn, name):
query = "SELECT id, name FROM users WHERE name = ?"
return conn.execute(query, (name,)).fetchall()You run the script again to confirm it still prints [(1, 'ada')]. Applying a suggestion does not prove it works, so always run the code.
How this differs from a pull request review
| Aspect | Editor review | Pull request review |
|---|---|---|
| When | Before you commit or push | After the pull request exists |
| Scope | Selection or local changes | The full diff of the pull request |
| Visibility | Only you | Everyone on the pull request |
| Where fixes land | Directly in your working tree | New commits on the branch |
| Counts as approval | No | No |
Neither review counts as a human approval. Your branch protection rules still apply.
Common errors
- Reviewing too much at once. A large set of local changes produces diluted feedback. Review in smaller pieces, such as one function or one logical change.
- Assuming instructions are ignored. Custom instruction files can also guide editor reviews, but support depends on your editor and version. If Copilot seems to ignore your rules, check that the file is saved at
.github/copilot-instructions.mdand that your editor's Copilot feature is current. - Skipping the pull request review. An editor review is a first pass. The pull request review still sees the final diff, so it can find things you changed after the local review.
- Trusting suggestions blindly. Copilot can be wrong, as the limitations chapter explains. Read each suggestion before you apply it.
Exercises
Exercise
You have changed three unrelated files locally. Why might you run separate editor reviews for each change instead of one review of everything?
Show answer
Smaller scopes give more focused feedback, and large mixed changes can dilute it. Separate reviews also make it easier to judge whether each suggestion is valid for its own change.
Exercise
Does a clean editor review mean you can skip the Copilot review on the pull request? Explain.
Show answer
No. The editor review only covered your local changes at one moment. Later edits, merge results, and the full pull request diff can introduce new issues. Neither review replaces required human review.