跳到正文
FunCoding

搜索

搜索文档、Skill 和 MCP

Configuring code review by GitHub Copilot

Set up Copilot to review pull requests.

Introduction

You can configure Copilot code review to review pull requests automatically, set your Copilot review effort, and control who can request reviews. For an overview, see AUTOTITLE.

Configuring automatic code review for your own pull requests

You can set Copilot code review to review the pull requests you create, in any repository where Copilot code review is available to you.

Configuring automatic code review is available on the Copilot Pro, Copilot Pro+, and Copilot Max plans, and with a Copilot Business or Copilot Enterprise license. It is not available for managed user accounts.

  1. In the upper-right corner of any page on GitHub, click your profile picture, then click copilot Copilot settings.
  2. In the sidebar, under copilot Copilot, click Code review.
  3. Enable Automatic Copilot code review.
  4. Optionally, to review each new push to a pull request that Copilot is already reviewing, enable Review new pushes.
  5. Optionally, to review pull requests while they are still marked as drafts, enable Review draft pull requests.

A pull request can qualify for automatic review from several independent sources: your user settings, repository rulesets, or organization rulesets. These sources are evaluated separately. If more than one source applies, Copilot still posts a single review. Your user settings cannot disable push or draft reviews that a ruleset has enabled. For more information, see AUTOTITLE.

Configuring your Copilot review effort

You can choose the Copilot review effort that Copilot code review uses for the reviews you request. Your choice applies to automatic reviews and to reviews you request manually. For an overview of the levels and how Copilot decides which to use, see AUTOTITLE.

  1. In the upper-right corner of any page on GitHub, click your profile picture, then click copilot Copilot settings.
  2. In the sidebar, under copilot Copilot, click Code review.
  3. Next to "Review effort level," select the Copilot review effort for reviews you request.
    • Lite: Standard review.
    • Balanced: Deeper analysis of complex logic, security-sensitive code, and cross-service changes.
    • Max: Most thorough review. This option appears with a Coming soon label and is not available yet.

To return to the built-in default, select the Default option at the top of the menu. Until you choose a specific level, the control shows the built-in default, Default (Balanced).

Your Copilot review effort is independent of Automatic Copilot code review. Turning automatic review off does not clear your Copilot review effort or stop it from applying to reviews you request manually.

Configuring automatic code review for a repository

You can enable automatic code reviews for a repository and customize how code reviews are performed.

Enabling automatic reviews

  1. On GitHub, navigate to the main page of the repository.

  2. Under your repository name, click gear Settings. If you cannot see the "Settings" tab, select the More dropdown menu, then click Settings.

    Screenshot of a repository header showing the tabs. The "Settings" tab is highlighted by a dark orange outline.

  3. In the left sidebar, under "Code, planning, and automation", click Rulesets, then click Rulesets.

  4. Click New ruleset.

  5. Click New branch ruleset.

  6. Under "Ruleset name," type a name for the ruleset.

  7. To activate the ruleset, under "Enforcement Status", select Active.

  8. Under "Target branches," click Add target and choose one of the options—for example, Include default branch or Include all branches.

  9. Under "Target branches," click Add target and choose one of the target options.

  10. Under "Branch rules," select Automatically request Copilot code review.

  11. Optionally, if you want Copilot to review all new pushes to the pull request, select Review new pushes.

    If this option is not selected, Copilot will only review the pull request once.

  12. Optionally, if you want Copilot to review pull requests while they are still drafts, select the Review draft pull requests.

    This can be a useful option for catching errors early, before requesting a human review.

  13. At the bottom of the page, click Create.

Customizing Copilot code review

You can configure how Copilot code review completes code reviews in your repository.

  1. On GitHub, navigate to the main page of the repository.

  2. Under your repository name, click gear Settings. If you cannot see the "Settings" tab, select the More dropdown menu, then click Settings.

    Screenshot of a repository header showing the tabs. The "Settings" tab is highlighted by a dark orange outline.

  3. In the sidebar, under "Code, planning, and automation", click copilot Copilot, then Code review.

  4. To choose the depth of Copilot code reviews, next to "Review effort level," select the effort level for automatic reviews in this repository.

    • Lite: Standard review.
    • Balanced: Deeper analysis of complex logic, security-sensitive code, and cross-service changes.

    Balanced reviews use more AI credits, and may consume marginally more GitHub Actions minutes. See AUTOTITLE.

  5. To choose whether Copilot can approve pull requests in your repository, configure the settings under "Auto-approval."

    • Allow Copilot to approve pull requests: Toggle on to let Copilot submit approving reviews.
    • Allow Copilot approvals to count toward merge requirements: Toggle on so Copilot approvals can satisfy pull request approval requirements.
    • File paths: Optionally, limit which pull requests count toward merge requirements. Enter one file glob per line to count approvals only on pull requests where every changed file matches one of the globs. Leave blank to count approvals for all files. Up to 15 globs are supported.

Copilot approvals are in public preview and subject to change.

  1. To prevent people from using an external Copilot license to request reviews in this repository, enable Only allow Copilot code review to be triggered by authorized users. If this setting is enabled for your organization, you cannot turn it off for the repository. See AUTOTITLE.

Configuring automatic code review for repositories in an organization

You can enable automatic code reviews for repositories in your organization and customize how code reviews are performed.

Enabling automatic reviews

  1. In the upper-right corner of GitHub, click your profile picture, then click organization Organizations.

  2. Select an organization by clicking on it.

  3. Under your organization name, click gear Settings. If you cannot see the "Settings" tab, select the More dropdown menu, then click Settings.

    Screenshot of the tabs in an organization's profile. The "Settings" tab is outlined in dark orange.

  4. In the sidebar, under "Code, planning, and automation", click repo Repository, then click Rulesets.

  5. Click New ruleset.

  6. Click New branch ruleset.

  7. Under "Ruleset name," type a name for the ruleset.

  8. To activate the ruleset, under "Enforcement Status", select Active.

  9. Under "Target repositories," click Add target and choose either Include by pattern or Exclude by pattern.

  10. Type a pattern that matches the repository names you want to target—for example, *feature to match all repositories with names ending in feature.

    For pattern-matching syntax, see AUTOTITLE.

  11. Click Add inclusion pattern or Add exclusion pattern.

  12. Repeat for any additional patterns.

You can add multiple targeting criteria to the same ruleset. Exclusion patterns are applied after inclusion patterns. For example, you could include any repositories matching the pattern *cat*, and specifically exclude a repository matching the pattern not-a-cat.

  1. Under "Target branches," click Add target and choose one of the target options.

  2. Under "Branch rules," select Automatically request Copilot code review.

  3. Optionally, if you want Copilot to review all new pushes to the pull request, select Review new pushes.

    If this option is not selected, Copilot will only review the pull request once.

  4. Optionally, if you want Copilot to review pull requests while they are still drafts, select the Review draft pull requests.

    This can be a useful option for catching errors early, before requesting a human review.

  5. At the bottom of the page, click Create.

Customizing Copilot code review

You can configure how Copilot code review completes code reviews in repositories in your organization.

  1. In the upper-right corner of GitHub, click your profile picture, then click organization Organizations.

  2. Select an organization by clicking on it.

  3. Under your organization name, click gear Settings. If you cannot see the "Settings" tab, select the More dropdown menu, then click Settings.

    Screenshot of the tabs in an organization's profile. The "Settings" tab is outlined in dark orange.

  4. In the sidebar, under "Code, planning, and automation", click copilot Copilot, then Code review.

  5. To choose the depth of Copilot code reviews, next to "Review effort level," select the default effort level for automatic reviews in repositories in your organization.

    • Lite: Standard review.
    • Balanced: Deeper analysis of complex logic, security-sensitive code, and cross-service changes.

    Balanced reviews use more AI credits, and may consume marginally more GitHub Actions minutes. See AUTOTITLE.

  6. To choose how AI credits usage associated with members who have paid Copilot licenses is billed, next to Choose how members with a Copilot license are billed, select an option.

    • Member: Use the member's Copilot entitlement. If the member's quota is exhausted, the code review fails. This is the default.
    • Organization: Bill the organization.

    This choice applies to both manually requested and automatic code reviews, and changes billing only. It does not grant access to Copilot code review. To use Organization, AI credits paid usage must be enabled for the organization. Setting a budget is optional. See AUTOTITLE.

  7. To choose whether Copilot can approve pull requests in your repositories, select an option under "Approvals," next to "Count Copilot approvals toward merge requirements."

    • Enabled everywhere: Copilot approvals can count toward merge requirements in every repository in the organization.
    • Let repositories decide: Repository admins can decide this in repository settings.
    • Enable for selected repositories: Copilot approvals can count toward merge requirements only in the repositories you select. If you choose this option, also assign the repositories you want to enable this for.
    • Disabled everywhere: Copilot approvals cannot count toward merge requirements in any repository in the organization.

Copilot approvals are in public preview and subject to change.

  1. To prevent people from using an external Copilot license to request reviews in your organization's repositories, enable Only allow Copilot code review to be triggered by authorized users. This setting applies to every repository in the organization, and repository administrators cannot turn it off.

Configuring automatic code review for an enterprise

You can enable automatic code reviews for your enterprise and customize how code reviews are performed.

Enabling automatic reviews

  1. Create an enterprise-level branch ruleset. See AUTOTITLE.
  2. Target the organizations and repositories where Copilot code review should run automatically.
  3. Enable the Automatically request Copilot code review policy.
  4. Optionally, enable automatic reviews for draft pull requests and after each push to a pull request.
  5. Click Create.

Customizing Copilot code review

You can configure how Copilot code review completes code reviews for your enterprise.

  1. Navigate to your enterprise. For example, from the Enterprises page on GitHub.com.

  2. At the top of the page, click copilot AI controls.

  3. Scroll down to "Available Agents", then click Copilot code review.

  4. Next to "Copilot code review", select a policy.

  5. Then choose which Copilot code review features to enable for your enterprise.

  6. To choose who is billed for Copilot code review usage by members with a paid Copilot license, next to "Choose how members with a Copilot license are billed," select a policy.

    • Member: Use the member's Copilot entitlement for organizations in the enterprise.
    • Organization: Bill the organization that owns the repository.
    • Let organizations decide: Organization owners can choose how to bill usage associated with members who have paid Copilot licenses.

    Organizations billed must have AI credits paid usage enabled. Setting a budget is optional.

  7. To choose whether Copilot can approve pull requests in your organizations, next to "Allow Copilot to approve pull requests," select a policy.

    • Let organizations decide: Organization owners can choose whether to enable Copilot approvals.
    • Enable for selected organizations: Copilot approvals are enabled only for the organizations you select.
    • Disabled everywhere: Organizations cannot enable Copilot approvals. This is the default.

Copilot approvals are in public preview and subject to change.