Skip to main content

Improving the quality of recently merged code with AI

Explore GitHub Code Quality findings for recently merged code and fix with Copilotの自動修正 or delegate remediation work to Copilot コーディング エージェント.

この機能を使用できるユーザーについて

書き込み アクセスを持つユーザー

上の組織所有リポジトリで使用できます

メモ

GitHub Code Quality は現在 パブリック プレビュー にあり、変更される可能性があります。 パブリック プレビュー の間、Code Quality は課金されませんが、Code Quality スキャンでは GitHub Actions 分が消費されます。

Introduction

This tutorial shows you how to explore and remediate quality issues that have been detected by Code Quality's AI-powered analysis of code that was recently merged into your default branch.

When you improve quality of recently merged files, you reduce technical debt in the repository and make it easier for other developers to work on files that are under active development.

Code Quality has two lines of defense

Code Quality scans pull requests and comments on quality concerns, then runs a second AI scan after the pull request is merged. The two types of scan use complementary technologies:

  • Pull request scans use CodeQL rules to identify problems. This analysis is thoroughly tested, good at identifying where code doesn't match the quality rules, and can analyze many files. However, it supports a subset of coding languages and cannot identify problems where there is no rule.

  • Recently merged file scans use a large language model to analyze your most recently changed files and report findings for up to 5 files. This analysis examines your code across all languages, without being limited by rules, and provides contextual insights and suggestions that can go beyond what CodeQL rules offer.

Prerequisites

1. View the AI suggestions for your repository

After a Code Quality scan of the recently merged files on your default branch, you can see the results under the AI の結果 view, which displays findings for up to 5 files.

  1. リポジトリの [セキュリティ] タブに移動します。
  2. クリックして コードの品質 を展開し、AI の結果 をクリックします。

メモ

This view is empty if the repository is inactive or if LLM analysis could not suggest ways to improve code quality in recent pushes to the default branch.

2. Explore suggested improvements for your repository

On the AI の結果 page, each file is listed with the number of quality problems identified and when the file was pushed to the default branch.

  • Click a file name to view details of the quality problems detected and the suggested fixes.

Screenshot of the "AI の結果" view for code quality.

3. Delegate remediation work or open pull requests yourself

You can open a pull request to apply the suggested autofixes to a file or delegate the remediation work to Copilot コーディング エージェント. You need a Copilot license to assign work to Copilot コーディング エージェント.
Sign up for Copilot

Delegate work to Copilot コーディング エージェント

You can ask コーディング エージェント to open pull requests to make improvements to files using the suggested changes as a prompt. This is the best option if the suggested changes look good to you and you want to open a pull request that applies fixes to more than one file.

To delegate pull request creation:

  • Multiple files: Select the files you want to include, then click Assign selected to Copilot in the header for the list of files.
  • One file: Click Assign to Copilot for the file.

There is a delay while the コーディング エージェント sets up the work. When the pull request is open and work is in progress, a banner is displayed with a link to the pull request.

You can track Copilot コーディング エージェント's work:

Open your own pull requests

You can open pull requests yourself to apply autofix suggestions. This is the best option if:

  • You want to work on the changes locally or in GitHub Desktop before opening a pull request
  • You do not have access to Copilot コーディング エージェント

メモ

When you open a pull request yourself, you can only commit fixes to one file at a time. To fix multiple files at once, you must use Copilot コーディング エージェント.

Opening a pull request

  1. Click the file name to view details of the quality problems detected.

  2. Review the problems and suggested fixes.

  3. Expand the Assign to Copilot drop-down and then click Open pull request to change the default option to "Open pull request". Your preference is remembered.

    Screenshot of the "AI の結果" view for code quality.

  4. Click Open pull request to open a dialog of commit options.

  5. Click Commit change to create a pull request with the fixes.

4. Provide pull request reviewers with context

Providing context on why you are proposing changes to code is the best way to encourage team members to review your pull request. If you used Copilot コーディング エージェント, the pull request summary already includes full details of the problems fixed by the pull request.

If you opened the pull request directly from the GitHub Code Quality view, the pull request summary links to the "AI の結果" view. You may want to copy some of the explanations from the AI の結果 view into the pull request summary.

Screenshot of a pull request summary created by GitHub Code Quality.

5. See your changes make an impact on AI の結果

When you return to the "AI の結果" view after merging your pull request, the findings you fixed are no longer listed.

Next steps