Using GitHub Copilot code review
Learn how to request a code review from GitHub Copilot.
In this article
- Introduction
- Using Copilot code review
- Working with suggested changes provided by Copilot
- Providing feedback on Copilot's reviews
- Requesting a re-review from Copilot
- Enabling automatic reviews
- Customizing Copilot's reviews with custom instructions
- Working with suggested changes provided by Copilot
- Providing feedback on Copilot's reviews
- Customizing Copilot's reviews with custom instructions
- Prerequisite
- Using Copilot code review
- Using Copilot code review
- Prerequisite
- Using Copilot code review
- Prerequisites
- Using Copilot code review
Introduction
GitHub Copilot can review your code and provide feedback. Where possible, Copilot's feedback includes suggested changes which you can apply with a couple of clicks.
For a full introduction to GitHub Copilot code review, seeAbout GitHub Copilot code review.
Using Copilot code review
These instructions explain how to use Copilot code review in the GitHub website. To see instructions for other popular coding environments, click the appropriate tab at the top of the page.
On GitHub.com, create a pull request or navigate to an existing pull request.
Open theReviewers menu, then selectCopilot.
Wait for Copilot to review your pull request. This usually takes less than 30 seconds.
Scroll down and read through Copilot's comments.
Copilot always leaves a "Comment" review, not an "Approve" review or a "Request changes" review. This means that Copilot's reviews do not count toward required approvals for the pull request, and Copilot's reviews will not block merging changes. For more details, seeApproving a pull request with required reviews.
Copilot's review comments behave like review comments from humans. You can add reactions to them, comment on them, resolve them and hide them.
Any comments you add to Copilot's review comments will be visible to humans, but they won't be visible to Copilot, and Copilot won't reply.
Working with suggested changes provided by Copilot
Where possible, Copilot's feedback includes suggested changes which you can apply with a couple of clicks.
If you're happy with the changes, you can accept a single suggestion from Copilot and commit it, or accept a group of suggestions together in a single commit. For more information, seeIncorporating feedback in your pull request.
Providing feedback on Copilot's reviews
You can provide feedback on Copilot's comments directly within each comment. We use this information to improve the product and the quality of Copilot's suggestions.
On a pull request review comment from Copilot, click the thumbs up (👍) or thumbs down (👎) button.
If you click the thumbs down button, you're asked to provide additional information. You can, optionally, pick the reason for your negative feedback and leave a comment before clickingSubmit feedback.
Requesting a re-review from Copilot
When you push changes to a pull request that Copilot has reviewed, it won't automatically re-review your changes.
To request a re-review from Copilot, click the button next to Copilot's name in theReviewers menu. For more information, seeRequesting a pull request review.
Note
When re-reviewing a pull request, Copilot may repeat the same comments again, even if they have been dismissed with the "Resolve conversation" button or downvoted with the thumbs down (👎) button.
Enabling automatic reviews
By default, you manually request a review from Copilot on each pull request, in the same way you would request a review from a human. However, you can set up Copilot to automatically review all pull requests. SeeConfiguring automatic code review by GitHub Copilot.
Customizing Copilot's reviews with custom instructions
You can customize Copilot code review by adding custom instructions to your repository.
Repository custom instructions can either be repository wide or path specific. You specify repository-wide custom instructions in a.github/copilot-instructions.md
file in your repository. You can use this file to store information that you want Copilot to consider when reviewing code anywhere in the repository.
You can also write instructions that Copilot will only use when reviewing code in files that match a specified path. You write these instructions in one or more.github/instructions/**/NAME.instructions.md
files.
For more information, seeAdding repository custom instructions for GitHub Copilot.
Example
This example of a.github/copilot-instructions.md
file contains three instructions that will be applied to all Copilot code reviews in the repository.
When performing a code review, respond in Spanish.When performing a code review, apply the checks in the `/security/security-checklist.md` file.When performing a code review, focus on readability and avoid nested ternary operators.
Reviewing a selection of code
You can request an initial review of a highlighted selection of code in Visual Studio Code.
In Visual Studio Code, select the code you want to review.
Open the VS Code Command Palette
- For Mac:
- Use:Shift+Command+P
- For Windows or Linux:
- UseCtrl+Shift+P
- For Mac:
In the command palette, search for and selectGitHub Copilot: Review and Comment.
Wait for Copilot to review your changes. This usually takes less than 30 seconds.
If Copilot has any comments, they will be shown inline in your file, and in theProblems tab.
Reviewing all uncommitted changes
You can request a review of your uncommitted changes in Visual Studio Code.
In VS Code, click theSource Control button in the Activity Bar.
At the top of theSource Control view, hover overCHANGES, then click theCopilot Code Review - Uncommitted Changes button.
Wait for Copilot to review your changes. This usually takes less than 30 seconds.
If Copilot has any comments, they will be shown inline in your file(s), and in theProblems tab.
Working with suggested changes provided by Copilot
Where possible, Copilot's feedback includes suggested changes which you can apply with a single click.
If you're happy with the change, you can accept a suggestion from Copilot by clicking theApply and Go To Next button. Any changes you apply will not be automatically committed.
If you don't want to apply Copilot's suggested change, click theDiscard and Go to Next button.
Providing feedback on Copilot's reviews
You can provide feedback on Copilot's comments directly within each comment. We use this information to improve the product and the quality of Copilot's suggestions.
To provide feedback, hover over the comment and click the thumbs up or thumbs down button.
Customizing Copilot's reviews with custom instructions
You can customize Copilot code review by adding custom instructions to your repository.
Repository custom instructions can either be repository wide or path specific. You specify repository-wide custom instructions in a.github/copilot-instructions.md
file in your repository. You can use this file to store information that you want Copilot to consider when reviewing code anywhere in the repository.
You can also write instructions that Copilot will only use when reviewing code in files that match a specified path. You write these instructions in one or more.github/instructions/**/NAME.instructions.md
files.
For more information, seeAdding repository custom instructions for GitHub Copilot.
Example
This example of a.github/copilot-instructions.md
file contains three instructions that will be applied to all Copilot code reviews in the repository.
When performing a code review, respond in Spanish.When performing a code review, apply the checks in the `/security/security-checklist.md` file.When performing a code review, focus on readability and avoid nested ternary operators.
Prerequisite
To use Copilot code review, you must use Visual Studio version 17.14 or later. See theVisual Studio downloads page.
Using Copilot code review
These instructions explain how to use Copilot code review in Visual Studio. To see instructions for other popular coding environments, click the appropriate tab at the top of the page.
In the Git Changes window, clickReview changes with Copilot.This button appears as a comment icon with a sparkle.
Copilot will begin reviewing your changes. After a few moments, a link showing the number of code review comments appears in the Git Changes window.
Click the link to view and navigate the comments. If no issues are found, you’ll see the message:Copilot did not comment on any files.
Copilot displays comments in your code with a summary of each potential issue. You can:
- Review and make changes based on the suggestions.
- Dismiss a comment using the downward arrow in the top-right corner of the comment box.
To remove all review comments, click next to the code review link in the Git Changes window.
For more information on enabling and configuring Copilot code review in Visual Studio, seeReview local changes with Copilot Chat in the Visual Studio documentation.
Using Copilot code review
These instructions explain how to use Copilot code review in GitHub Mobile. To see instructions for other popular coding environments, click the appropriate tab at the top of the page.
- In GitHub Mobile, open a pull request.
- Scroll down to theReviews section and expand it.
- ClickRequest Reviews.
- Add Copilot as a reviewer, then clickDone.
Copilot will review the changes and provide feedback.
Prerequisite
To use Copilot code review in Xcode, you must use version 0.41.0 or later of the GitHub Copilot Chat extension. Download the latest release from thegithub/CopilotForXcode
repository.
Using Copilot code review
These instructions explain how to use Copilot code review in Xcode. To see instructions for other popular coding environments, click the appropriate tab at the top of the page.
In Xcode, make some changes to one or more files.
Open the Copilot chat window by clickingEditor in the menu bar, clickingGitHub Copilot thenOpen Chat.
Near the bottom right of the prompt box in the Copilot chat window, click theCode Review button (a speech bubble icon).
Click eitherReview Staged Changes orReview Unstaged Changes.
A list of files containing changes is displayed in the chat window. Click the check boxes to deselect any files you don't want Copilot to review.
ClickContinue to start the review process.
If Copilot finds things to comment on, it displays aReviewed Changes list in the chat window, listing the files it has commented on. Click a file in this list to see the comments.
Each comment is shown in a popup, overlaid over the editor.
If there is more than one comment in the file, use the up and down arrows, at the top right of the popup, to navigate between comments.
Copilot may suggest replacement code. You can apply the suggested change by clickingAccept or reject it by clickingDismiss.
Click another file in theReviewed Changes list in the chat window, to see the review comments for another file.
Prerequisites
Access to Copilot. SeeWhat is GitHub Copilot?.
Compatible JetBrains IDE. To use GitHub Copilot in JetBrains, you must have a compatible JetBrains IDE installed. GitHub Copilot is compatible with the following IDEs:
- IntelliJ IDEA (Ultimate, Community, Educational)
- Android Studio
- AppCode
- CLion
- Code With Me Guest
- DataGrip
- DataSpell
- GoLand
- JetBrains Client
- MPS
- PhpStorm
- PyCharm (Professional, Community, Educational)
- Rider
- RubyMine
- RustRover
- WebStorm
- Writerside
See theJetBrains IDEs tool finder to download.
Latest version of the GitHub Copilot extension. See theGitHub Copilot plugin in the JetBrains Marketplace. For installation instructions, seeInstalling the GitHub Copilot extension in your environment.
Sign in to GitHub in your JetBrains IDE. For authentication instructions, seeInstalling the GitHub Copilot extension in your environment.
Using Copilot code review
These instructions explain how to use Copilot code review in JetBrains IDEs. To see instructions for other popular coding environments, click the appropriate tab at the top of the page.
In a JetBrains IDE, make some changes to one or more files.
Open the "Commit" tool window on the left-hand side.
Above the commit message input field, clickCopilot: Review Code Changes. This button appears as a magnifying glass icon with a sparkle.
Copilot will begin reviewing your changes.
Copilot displays comments in your code with a summary of each potential issue. You can:
- Review and make changes based on the suggestions.
- Dismiss a comment by clickingDiscard.
If there is more than one comment, use the up and down arrows, at the top right of the popup, to navigate between comments.