Skip to main content

Using GitHub Copilot code review

Learn how to request a code review from GitHub Copilot.

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 コード レビュー, see About Copilot code review.

Using Copilot コード レビュー

These instructions explain how to use Copilot コード レビュー in the GitHub website. To see instructions for other popular coding environments, use the tool switcher at the top of the page.

  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 approvals for the pull request, and Copilot's reviews will not block merging changes. For more details, see 必須レビューでのプルリクエストの承認.

  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 プルリクエストでのフィードバックを取り込む.

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 コード レビュー 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 Pull Request レビューをリクエストする.

メモ

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. See Configuring automatic code review by Copilot.

Customizing Copilot's reviews with custom instructions

メモ

Copilot コード レビュー に対するカスタム指示は パブリック プレビュー 段階であり、変更される可能性があります。

この機能は、Copilot Pro、Copilot Pro+、Copilot Business、Copilot Enterprise の各プランで使用できます。

Copilot Business または Copilot Enterprise プランをお使いの場合、パブリック プレビュー の期間中は、プランを提供する organization または Enterprise で [Opt in to preview features] の設定が有効にされている必要があります。 「Managing policies and features for Copilot in your organization」または「Managing policies and features for Copilot in your enterprise」をご覧ください

リポジトリのカスタム指示ファイルを追加して、Copilot コード レビュー の動作をカスタマイズします。 これを行うには、リポジトリに .github/copilot-instructions.md ファイルを作成し、Copilot がコードをレビューするときに考慮させたい自然言語テキストを追加します。 これは、Copilot Chat で使われるのと同じ copilot-instructions.md です。 「Adding repository custom instructions for GitHub Copilot」を参照してください。

コード レビューに対するカスタム指示を有効または無効にするには、リポジトリの設定に移動してから、[Copilot] の下にある [Code Review] に移動して、[Use custom instructions when reviewing pull requests] オプションを切り替えます。

この例の .github/copilot-instructions.md ファイルには、リポジトリ内のすべての Copilot コード レビュー に適用される 3 つの指示が含まれています。

When performing a code review, respond in Spanish.

When performing a code review, follow our internal security checklist.

When performing a code review, focus on readability and avoid nested ternary operators.

Customizing Copilot's reviews with coding guidelines

メモ

カスタム コーディング ガイドライン機能は、Copilot Enterprise プランでのみ利用でき、現在は一部のお客様に限定されています。

Visual Studio Code または GitHub Web サイトで Copilot コード レビュー を使って変更をレビューする場合は、自然言語で記述されたカスタム コーディング ガイドラインを使って Copilot のレビューをカスタマイズできます。 Copilot は、コードをレビューするときにそのコーディング ガイドラインに基づいてフィードバックを提供します。 詳しくは、「Configuring coding guidelines for GitHub Copilot code review」をご覧ください。

コーディング ガイドラインに基づいて生成されたコメントには、そのソースを明確に示すメッセージが含まれます。

Using Copilot コード レビュー

These instructions explain how to use Copilot コード レビュー in Visual Studio Code. To see instructions for other popular coding environments, use the tool switcher at the top of the page.

メモ

Copilot コード レビュー is 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.

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

Reviewing all uncommitted changes

You can request a review of your uncommitted changes in Visual Studio Code.

  1. In VS Code, click the Source Control button in the Activity Bar.

  2. At the top of the Source Control view, hover over CHANGES, then click the Copilot Code Review - Uncommitted Changes button.

    Screenshot of the "Source Control" view. The code review button is outlined in dark orange.

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

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

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 custom instructions

メモ

Copilot コード レビュー に対するカスタム指示は パブリック プレビュー 段階であり、変更される可能性があります。

この機能は、Copilot Pro、Copilot Pro+、Copilot Business、Copilot Enterprise の各プランで使用できます。

Copilot Business または Copilot Enterprise プランをお使いの場合、パブリック プレビュー の期間中は、プランを提供する organization または Enterprise で [Opt in to preview features] の設定が有効にされている必要があります。 「Managing policies and features for Copilot in your organization」または「Managing policies and features for Copilot in your enterprise」をご覧ください

リポジトリのカスタム指示ファイルを追加して、Copilot コード レビュー の動作をカスタマイズします。 これを行うには、リポジトリに .github/copilot-instructions.md ファイルを作成し、Copilot がコードをレビューするときに考慮させたい自然言語テキストを追加します。 これは、Copilot Chat で使われるのと同じ copilot-instructions.md です。 「Adding repository custom instructions for GitHub Copilot」を参照してください。

コード レビューに対するカスタム指示を有効または無効にするには、リポジトリの設定に移動してから、[Copilot] の下にある [Code Review] に移動して、[Use custom instructions when reviewing pull requests] オプションを切り替えます。

この例の .github/copilot-instructions.md ファイルには、リポジトリ内のすべての Copilot コード レビュー に適用される 3 つの指示が含まれています。

When performing a code review, respond in Spanish.

When performing a code review, follow our internal security checklist.

When performing a code review, focus on readability and avoid nested ternary operators.

Customizing Copilot's reviews with coding guidelines

メモ

カスタム コーディング ガイドライン機能は、Copilot Enterprise プランでのみ利用でき、現在は一部のお客様に限定されています。

Visual Studio Code または GitHub Web サイトで Copilot コード レビュー を使って変更をレビューする場合は、自然言語で記述されたカスタム コーディング ガイドラインを使って Copilot のレビューをカスタマイズできます。 Copilot は、コードをレビューするときにそのコーディング ガイドラインに基づいてフィードバックを提供します。 詳しくは、「Configuring coding guidelines for GitHub Copilot code review」をご覧ください。

コーディング ガイドラインに基づいて生成されたコメントには、そのソースを明確に示すメッセージが含まれます。

Prerequisite

To use Copilot コード レビュー, you must use Visual Studio version 17.14 or later. See the Visual Studio downloads page.

Using Copilot コード レビュー

These instructions explain how to use Copilot コード レビュー in Visual Studio. To see instructions for other popular coding environments, use the tool switcher at the top of the page.

  1. In the Git Changes window, click Review changes with Copilot. This button appears as a comment icon with a sparkle.

  2. 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.

  3. 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.

  4. 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.
  5. 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 コード レビュー in Visual Studio, see Review local changes with Copilot Chat in the Visual Studio documentation.

Using Copilot コード レビュー

These instructions explain how to use Copilot コード レビュー in GitHub Mobile. To see instructions for other popular coding environments, use the tool switcher at the top of the page.

  1. In GitHub Mobile, open a pull request.
  2. Scroll down to the Reviews section and expand it.
  3. Click Request Reviews.
  4. Add Copilot as a reviewer, then click Done.

Copilot will review the changes and provide feedback.