Skip to main content

Verwenden des GitHub Copilot-Code-Reviews

Hier erfährst du, wie du einen Code Review von GitHub Copilot anforderst.

Wer kann dieses Feature verwenden?

This feature is not available in GitHub Copilot Free.

Note

About Copilot code review

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.

Copilot code review supports two types of review:

  • Review selection: Highlight code and ask for an initial review (Visual Studio Code only)
  • Review changes: Request a deeper review of all your changes (GitHub website and Visual Studio Code)

The current functionality and availability of the two types of review is summarized in the following table:

FeatureReview selectionReview changes
EnvironmentVisual Studio CodeVisual Studio Code and the GitHub website
DescriptionInitial review of a highlighted section of code with feedback and suggestionsDeeper review of all changes
Language supportAllC#, Go, Java, JavaScript, Markdown, Python, Ruby, TypeScript
Custom coding guidelines supportNoYes, see Customizing Copilot's reviews with coding guidelines
AvailabilityPublic preview, available to all Copilot subscribersPublic preview with waitlist, see Join the Copilot code review waitlist

Warning

Copilot isn't guaranteed to spot all problems or issues in a pull request, and sometimes it will make mistakes. Always validate Copilot's feedback carefully, and supplement Copilot's feedback with a human review.

For more information, see Responsible use of GitHub Copilot code review.

Requesting a review from Copilot

These instructions explain how to use Copilot code review in the GitHub website. To see instructions for Visual Studio Code, use the "Visual Studio Code" tool switcher at the top of the page.

Requesting a pull request review from Copilot

Note

Requesting a pull request review from Copilot is currently only available to a limited number of Copilot subscribers. To join the waitlist, see Join the Copilot code review waitlist.

  1. On GitHub.com, create a pull request or navigate to an existing pull request.

  2. Open the Reviewers menu, then select Copilot.

    Screenshot of selecting 'Copilot' from the 'Reviewers' menu.

  3. Wait for Copilot to review your pull request. This usually takes less than 30 seconds.

  4. Scroll down and read through Copilot's comments.

    Screenshot of a code review left by Copilot.

    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 reviews for the pull request, and Copilot's reviews will not block merging changes. For more details, see Approving a pull request with required reviews.

  5. 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, see Incorporating feedback in your pull request.

If you want to validate Copilot's suggested changes (for example by running automated tests or your linter), or if you want to make modifications before committing the suggested changes, click the Open in Workspace button. For more information, see Using Copilot to help you work on a 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.

  1. On a pull request review comment from Copilot, click the thumbs up (👍) or thumbs down (👎) button.

    Screenshot showing a Copilot code review comment with the thumbs up and thumbs down buttons.

  2. 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 clicking Submit feedback.

    Screenshot of the form for providing additional information when you give negative feedback on a comment from Copilot.

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 the Reviewers menu. For more information, see Requesting 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 from Copilot

By default, you will have to manually request a review from Copilot on each pull request.

You can enable automatic reviews from Copilot on all pull requests using rulesets configured at the repository level or organization level. For more information, see About rulesets.

To turn this on, enable the Request pull request review from Copilot branch rule, nested under Require a pull request before merging.

Screenshot of the "Request pull request review from Copilot" branch rule.

Customizing Copilot's reviews with coding guidelines

Note

Custom coding guidelines are currently only available to selected participants in the public preview of Copilot code review. Being accepted from the waitlist does not provide immediate access. In addition, custom coding guidelines are only available as part of a subscription to GitHub Copilot Enterprise.

When using Copilot code review to review changes in Visual Studio Code or the GitHub website, you can customize Copilot's review with custom coding guidelines written in natural language. Copilot will give feedback based on your coding guidelines when it reviews your code. For more information, see "Configuring coding guidelines for GitHub Copilot code review."

Comments generated based on a coding guideline will include a message, highlighting their source.

Screenshot of a comment produced from a custom coding guideline.

These instructions explain how to use Copilot code review in Visual Studio Code. To see instructions for the GitHub website, use the "Web browser" tool switcher at the top of the page.

Note

Copilot code review is only available in Visual Studio Code with version 0.22 or later of the GitHub Copilot Chat extension.

Reviewing a selection of code

You can request an initial review of a highlighted selection of code in Visual Studio Code.

  1. In Visual Studio Code, select the code you want to review.

  2. Open the VS Code Command Palette

    • For Mac:
      • Use: Shift+Command+P
    • For Windows or Linux:
      • Use Ctrl+Shift+P
  3. In the command palette, search for and select GitHub Copilot: Review and Comment.

    Screenshot of the command palette in Visual Studio Code with the GitHub Copilot: Review and Comment command selected.

  4. Wait for Copilot to review your changes. This usually takes less than 30 seconds.

    Screenshot of the progress indicator when Copilot is performing a review in Visual Studio Code.

  5. If Copilot has any comments, they will be shown inline in your file, and in the Problems tab.

    Screenshot of a comment from Copilot in Visual Studio Code.

Reviewing changes

Note

Reviewing changes is currently only available to a limited number of Copilot subscribers. To join the waitlist, see Join the Copilot code review waitlist.

You can request a review for your staged or unstaged changes in Visual Studio Code.

  1. In VS Code, switch to the Source Control tab.

  2. To request a review on your unstaged changes, hover over Changes in the sidebar, and then click the Copilot code review - Changes button.

    Screenshot of the "Copilot code review - Changes" button in Visual Studio Code. The code review button is outlined in dark orange.

  3. To request a review on your staged changes, hover over Staged Changes in the sidebar, and then click the Copilot code review - Staged Changes button.

  4. Wait for Copilot to review your changes. This usually takes less than 30 seconds.

    Screenshot of the progress indicator when Copilot is performing a review in Visual Studio Code.

  5. If Copilot has any comments, they will be shown inline in your file(s), and in the Problems tab.

    Screenshot of a comment from Copilot in Visual Studio Code.

Working with suggested changes provided by Copilot

Where possible, Copilot's feedback includes suggested changes which you can apply with a single click.

Screenshot of a comment from Copilot in Visual Studio Code with a suggested change.

If you're happy with the change, you can accept a suggestion from Copilot by clicking the Apply 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 the Discard 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.

Screenshot of a comment from Copilot in Visual Studio Code with feedback buttons displayed. The buttons are outlined in dark orange.

Customizing Copilot's reviews with coding guidelines

Note

Custom coding guidelines are currently only available to selected participants in the public preview of Copilot code review. Being accepted from the waitlist does not provide immediate access. In addition, custom coding guidelines are only available as part of a subscription to GitHub Copilot Enterprise.

When using Copilot code review to review changes in Visual Studio Code or the GitHub website, you can customize Copilot's review with custom coding guidelines written in natural language. Copilot will give feedback based on your coding guidelines when it reviews your code. For more information, see "Configuring coding guidelines for GitHub Copilot code review."

Comments generated based on a coding guideline will include a message, highlighting their source.