Sub topic 10
Getting a review in your editor before opening a pull request
Earlier chapters covered requesting Copilot's review on a pull request. This chapter covers the same idea one step earlier. You ask Copilot to review your changes in your editor, fix the obvious problems, and only then push and open the pull request.
This chapter assumes you have done the following:
- Used Copilot code review on a pull request.
- Written a repository instruction file.
- Used one of the supported editors with Copilot signed in.
The supported editors include Visual Studio Code, Visual Studio, and JetBrains IDEs. Menu names and button placement change between releases, so treat the labels below as typical, not exact.
Why review before the pull request
A pull request is a shared space. Everything you push there is visible to your teammates, and it may trigger CI runs, notifications, and an automatic Copilot review. An editor review gives you a private first pass.
It helps in three ways:
- You fix small mistakes, such as a missing null check or a leftover debug line, before anyone else sees them.
- The pull request history stays short. You avoid a cycle of "push, get a comment, push a fix" for trivial issues.
- Reviewers spend their attention on design and intent, not on things a tool could have caught.
An editor review is not a replacement for the pull request review. It does not create a review record on GitHub and does not count toward required approvals. It is a self-check.
Two scopes: a selection or your changes
Editor reviews work on one of two scopes. Which one you pick changes what Copilot sees.
| Scope | What Copilot reviews | When to use it |
|---|---|---|
| Selection | The code you highlighted, plus surrounding context from the file | You wrote or changed one function and want focused feedback |
| Changes | The diff of your uncommitted work (staged and unstaged) | You are about to commit and want a pass over the whole change |
In Visual Studio Code, the usual entry points are:
- Selection: highlight code, open the right-click menu, and choose the Copilot review action, often listed under a "Generate Code" or "Copilot" submenu.
- Changes: open the Source Control view and click the Copilot review button (a comment icon with a sparkle) near the commit message box.
Visual Studio exposes a similar review button in the Git Changes window. JetBrains IDEs offer it from the commit window. If you cannot find the button, check that your Copilot extension is current and that your plan includes code review.
What the review looks like
Results appear as inline comments in the editor, attached to specific lines, much like comments on a pull request. A comment usually describes the problem. Many also include a suggested replacement that you can apply with a click.
Reading and acting on them follows the same habits as on GitHub:
- Read the comment and the lines it points to.
- Decide whether the concern is real.
- Apply the suggestion, edit the code your own way, or dismiss the comment.
Applying a suggestion edits your working files directly. It is an ordinary change. You can undo it, see it in the diff, and commit it like any other edit.
A pre-pull-request workflow
Here is a sequence that works well.
Run your tests and linter first. Copilot's review is slower and less certain than a linter, so do not spend it on problems a deterministic tool finds for free. This also matches the guidance in the repository instruction example from earlier: formatting is enforced by the linter, so Copilot should focus on correctness and security.
Before you request a review of your changes, check what will be included:
git status --short
git diff --stat
git diff --cached --statgit diff --stat summarizes unstaged changes. git diff --cached --stat summarizes staged changes. If the summary contains files you did not mean to touch, such as generated output or a stray lockfile, clean up first. Otherwise the review spends effort on noise, and you may get comments about code unrelated to your task.
How repository instructions apply in the editor
The instruction files you wrote for pull request reviews can also guide editor reviews. A repository-wide file at .github/copilot-instructions.md is read from your workspace when you request a review. In many editors, path-specific files in .github/instructions/ with applyTo frontmatter are also applied.
For example, this file asks for security-focused feedback:
# 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.And this one limits TypeScript guidance to .ts files:
---
applyTo: "**/*.ts"
---
- Flag use of the `any` type unless a comment explains why it is needed.
- Check that async functions handle rejected promises.Two cautions apply.
- Editor support differs from GitHub support. Which instruction sources each editor reads, and how, varies by product and version. Some editors also have their own settings for review-specific instructions, separate from the repository files. Check your editor's Copilot documentation for the current behavior.
- Instructions are guidance, not rules. A file that says "flag any query built by string concatenation" does not guarantee that Copilot will flag every instance. Test your file: write a small deliberate violation, run a review, and see whether it is caught.
A quick calibration test is worth the two minutes. Add a throwaway function with an obvious problem, request a review, and see what comes back. Then delete the function. If Copilot ignores the problem, your instruction may be too vague. If it flags many unrelated things, the instruction is probably too broad.
Differences from a pull request review
The editor and the pull request have different strengths. Do not assume they behave the same way.
| Aspect | Editor review | Pull request review |
|---|---|---|
| Visibility | Private to you | Visible to everyone on the pull request |
| Record on GitHub | None | A review with the "Comment" status |
| Input | Selection or uncommitted changes | The pull request diff, with repository context |
| Re-running | Instant, as often as you like | Re-request after new commits |
| Counts as approval | No | No, and it never counts as a required approval |
| Automatic | No, you trigger it | Can be automatic through settings or rulesets |
Because the editor review leaves no trace, it is safe to experiment. You can request it ten times with different scopes and nothing will appear in the pull request.
Because the inputs differ, results can differ too. The editor sees your local working state. The pull request sees the final diff against the base branch. A comment you saw in the editor may not appear on GitHub, and the reverse is also true. This is normal, and it is part of the non-determinism covered in the limitations chapter. Do not treat a clean editor review as a promise of a clean pull request review.
Edge cases
Large changes. Very large diffs tend to get shallower feedback. Copilot may comment on only part of the change or skip files. If you changed twenty files, review by selection in the riskiest ones, or split the work into smaller commits and review each.
Files that are not text source. Generated files, minified bundles, binaries, and lockfiles give little useful feedback. Exclude them from what you review where you can, or avoid including them in the same change.
Staged versus unstaged work. Depending on the editor, the "changes" scope may cover only some of your modifications. After requesting a review, check whether the comments mention a file you edited. If one is missing, review it by selection.
Sensitive code. Editor reviews send code to Copilot's service. Follow your organization's policy on what may be sent. Do not paste secrets or credentials into files you review. Your organization may also disable the feature, in which case the button will not appear.
Stale comments. After you fix an issue, old inline comments may remain visible until you dismiss them or re-run the review. Dismiss comments you have handled so you can tell what is still open.
False confidence. The most common mistake is stopping at "Copilot said it was fine." The tool can miss bugs, misread intent, and suggest changes that break behavior. Run your tests again after applying any suggestion.
Checking a suggestion before you accept it
Treat every suggestion as a proposed patch from a colleague who has not run the code. Before applying one:
- Read the explanation and confirm you agree with the reason.
- Check that the replacement keeps the behavior you intended, including error handling and edge cases.
- Look for new imports, renamed variables, or changed signatures that ripple into other files.
- Run the relevant tests after applying it.
If a suggestion is almost right, edit it. If it is wrong, dismiss it. If a certain kind of wrong suggestion keeps showing up, that is a signal to tighten your instruction file, for example by adding "Do not suggest changing public function signatures."
When to use which review
A reasonable division of labor:
- Editor review: early and often, on small units of work, before each commit or before you push.
- Pull request review by Copilot: once per round of changes, after you push, as a second pass with the repository's full diff in view.
- Human review: always, for anything that merges. Copilot's review does not replace required approvals.
Using all three gives overlapping coverage. Each layer catches some problems the others miss, and none is complete on its own.
Summary
An editor review is a private, repeatable check of a selection or of your uncommitted changes. It uses the same kind of instruction files as pull request reviews, though editor support varies. It leaves no record on GitHub and never counts as an approval. Run your tests and linter first, check what the review will cover, calibrate with a deliberate bug, and verify each suggestion before applying it.
Exercise
You changed 15 files, and the Copilot editor review of your uncommitted changes returned no comments. You open the pull request, and the Copilot review there posts three comments. List two reasons this can happen, and say what you should do about the three comments.
Show answer
Possible reasons include: (1) the two reviews use different inputs, since the editor saw your local working state while the pull request review saw the final diff against the base branch; (2) Copilot's output is non-deterministic, and a large change may get shallow or partial feedback; (3) the "changes" scope may not have covered every file. You should evaluate each of the three comments on its merits, as you would any reviewer's comment: apply those that are correct (and re-run tests), dismiss those that are wrong, and not treat the clean editor review as proof that the code was fine.
Exercise
You added a rule to .github/copilot-instructions.md saying "Flag any new database query that is built by string concatenation." How can you check that editor reviews actually follow it?
Show answer
Add a temporary function that builds a query by string concatenation, request an editor review of that selection or change, and see whether Copilot flags it. Then delete the function. If it is not flagged, make the instruction more specific or check how your editor reads instruction files, because support varies by editor and version.