Skip to main content

GitHub Copilot のリポジトリ カスタム命令を追加する

プロジェクトを理解する方法と、その変更をビルド、テスト、検証する方法についての追加コンテキストを Copilot に提供するリポジトリ カスタム指示ファイルを作成します。

この記事のこのバージョンは、GitHub Web サイト上でリポジトリのカスタム命令を使うためのものです。 他の環境でカスタム指示を使う方法については、上のタブをクリックします。

現在、リポジトリのカスタム指示は以下でサポートされています。

  • VS Code の Copilot Chat
  • Copilot コーディング エージェント
  • Visual Studio、JetBrains IDE、Xcode、および GitHub Web サイトでの Copilot Chat (copilot-instructions.md ファイルのみ)
  • Copilot コード レビュー (copilot-instructions.md ファイルのみ)
  • Copilot コード レビュー

Prerequisites for repository custom instructions

  • You must have a custom instructions file (see the instructions below).

この記事のこのバージョンでは、VS Code でのリポジトリ カスタム指示とプロンプト ファイルの使用について説明します。 他の環境でカスタム指示を使う手順については、上のタブをクリックします。

現在、リポジトリのカスタム指示は以下でサポートされています。

  • VS Code の Copilot Chat
  • Copilot コーディング エージェント
  • Visual Studio、JetBrains IDE、Xcode、および GitHub Web サイトでの Copilot Chat (copilot-instructions.md ファイルのみ)
  • Copilot コード レビュー (copilot-instructions.md ファイルのみ)
  • Copilot コード レビュー

Prerequisites for repository custom instructions

  • You must have a custom instructions file (see the instructions below).

この記事のこのバージョンは、Visual Studio でリポジトリのカスタム命令を使うためのものです。 他の環境でカスタム指示を使う手順については、上のタブをクリックします。

現在、リポジトリのカスタム指示は以下でサポートされています。

  • VS Code の Copilot Chat
  • Copilot コーディング エージェント
  • Visual Studio、JetBrains IDE、Xcode、および GitHub Web サイトでの Copilot Chat (copilot-instructions.md ファイルのみ)
  • Copilot コード レビュー (copilot-instructions.md ファイルのみ)
  • Copilot コード レビュー

Prerequisites for repository custom instructions

  • You must have a custom instructions file (see the instructions below).

この記事のこのバージョンでは、JetBrains IDE でのリポジトリ カスタム指示の使用について説明します。 他の環境でカスタム指示を使う手順については、上のタブをクリックします。

現在、リポジトリのカスタム指示は以下でサポートされています。

  • VS Code の Copilot Chat
  • Copilot コーディング エージェント
  • Visual Studio、JetBrains IDE、Xcode、および GitHub Web サイトでの Copilot Chat (copilot-instructions.md ファイルのみ)
  • Copilot コード レビュー (copilot-instructions.md ファイルのみ)
  • Copilot コード レビュー

Prerequisites for repository custom instructions

  • You must have a custom instructions file (see the instructions below).

この記事のこのバージョンでは、Xcode でのリポジトリ カスタム指示の使用について説明します。 他の環境でカスタム指示を使う手順については、上のタブをクリックします。

現在、リポジトリのカスタム指示は以下でサポートされています。

  • VS Code の Copilot Chat
  • Copilot コーディング エージェント
  • Visual Studio、JetBrains IDE、Xcode、および GitHub Web サイトでの Copilot Chat (copilot-instructions.md ファイルのみ)
  • Copilot コード レビュー (copilot-instructions.md ファイルのみ)

Prerequisites for repository custom instructions

  • You must have a custom instructions file (see the instructions below).

メモ

この機能は現在パブリック プレビューにあり、変更される可能性があります。

この記事のこのバージョンでは、Eclipse でのリポジトリ カスタム指示の使用について説明します。 他の環境でカスタム指示を使う手順については、上のタブをクリックします。

現在、リポジトリのカスタム指示は以下でサポートされています。

  • VS Code の Copilot Chat
  • Copilot コーディング エージェント
  • Visual Studio、JetBrains IDE、Xcode、および GitHub Web サイトでの Copilot Chat (copilot-instructions.md ファイルのみ)
  • Copilot コード レビュー (copilot-instructions.md ファイルのみ)
  • Copilot コード レビュー

Prerequisites for repository custom instructions

  • You must have a custom instructions file (see the instructions below).
  • 最新バージョンの Copilot 拡張機能が JetBrains IDE にインストールされている必要があります。
  • 最新バージョンの Copilot 拡張機能が Xcode にインストールされている必要があります。
  • 最新バージョンの Copilot 拡張機能が Eclipse にインストールされている必要があります。

カスタム指示の作成

JetBrains IDE は、リポジトリに格納されている 1 つの .github/copilot-instructions.md カスタム指示ファイルと、ローカルに格納されている global-copilot-instructions.md ファイルをサポートしています。

.github/copilot-instructions.md ファイルは、Copilot 設定ページを使ってリポジトリに作成できます。また、手動でファイルを作成することもできます。

指示と指示の間の空白は無視されます。このため複数の指示を 1 段落に記述することも、1 行に 1 つずつ記述することもできます。あるいは、読みやすくするために空白行で区切ることもできます。

設定ページの使用

  1. JetBrains IDE で、ファイル メニュー (Windows) またはメニュー バー (macOS) のアプリケーションの名前をクリックし、設定 をクリックします。
  2. Languages & Frameworks で、 [GitHub Copilot] をクリックします。
  3. [Copilot Instructions] で、[Workspace] または [Global] をクリックし、カスタム指示を現在のワークスペースまたはすべてのワークスペースのどちらに適用するかを選びます。

ワークスペース カスタム指示ファイルの手作業での作成

  1. リポジトリのルートに .github/copilot-instructions.md という名前のファイルを作成します。

    .github ディレクトリがまだ存在しない場合は作成します。

  2. Markdown 形式で自然言語の指示をファイルに追加します。

保存したこれらの指示は、Copilot を有効にして開いた JetBrains IDE の現在のワークスペースに適用されます。

グローバル カスタム指示ファイルの手作業での作成

同じ指示を JetBrains IDE 内のすべてのワークスペースに適用するには、ローカル コンピューターでグローバル カスタム指示ファイルを作成できます。

  1. エクスプローラーまたはターミナルを開きます。

  2. オペレーティング システムの適切な場所に移動します。

    • macOS: /Users/YOUR-USERNAME/.config/github-copilot/intellij/
    • Windows: C:\Users\YOUR-USERNAME\AppData\Local\github-copilot\intellij\
  3. そのディレクトリに global-copilot-instructions.md という名前のファイルを作成します。

  4. Markdown 形式を使い、自然言語でカスタム指示を追加します。

保存したこれらの指示は、Copilot を有効にして開いた JetBrains IDE のすべてのワークスペースにグローバルに適用されます。

Xcode では、リポジトリに格納されている 1 つの .github/copilot-instructions.md カスタム指示ファイルがサポートされています。

Copilot 設定ページを使って、リポジトリにカスタム指示ファイルを作成できます。

指示と指示の間の空白は無視されます。このため複数の指示を 1 段落に記述することも、1 行に 1 つずつ記述することもできます。あるいは、読みやすくするために空白行で区切ることもできます。

  1. GitHub Copilot for Xcode アプリケーションを開きます。
  2. アプリケーション ウィンドウの上部にある [Settings] で、[Advanced] をクリックします。
  3. [Custom Instructions] の右側で [Current Workspace] または [Global] をクリックして、カスタム指示を現在のワークスペースまたはすべてのワークスペースのどちらに適用するかを選びます。

Eclipse では、ワークスペースとプロジェクトの 2 種類のリポジトリ カスタム指示がサポートされています。

ワークスペース カスタム指示ファイルを作成するには、Copilot の設定ページを使用できます。 プロジェクト カスタム指示ファイルを作成するには、プロジェクト ディレクトリでファイルを手動で作成できます。

指示と指示の間の空白は無視されます。このため複数の指示を 1 段落に記述することも、1 行に 1 つずつ記述することもできます。あるいは、読みやすくするために空白行で区切ることもできます。

ワークスペース カスタム指示ファイルの作成

  1. Copilot Chat パネルを開くには、Eclipse の下部にあるステータス バーで Copilot アイコン () をクリックします。
  2. メニューの [Edit preferences] を選びます。
  3. 左側のペインで、GitHub Copilot を展開して [Custom Instructions] をクリックします。
  4. [Enable workspace instructions] を選びます。
  5. [Workspace] セクションの [Set custom instructions to guide Copilot's code suggestions in this workspace] で、Markdown 形式を使って自然言語の指示をファイルに追加します。

プロジェクト カスタム指示ファイルの作成

  1. プロジェクト ディレクトリのルートに、.github/copilot-instructions.md という名前のファイルを作成します。
  2. Markdown 形式を使い、自然言語でカスタム指示を追加します。

保存したこれらの指示は、Copilot を有効にして開いた Eclipse の現在のプロジェクトに適用されます。

VS Code は、2 種類のリポジトリ カスタム指示をサポートしています。

  • リポジトリ全体のカスタム指示。リポジトリのコンテキストで行われたすべてのリクエストに適用されます。

    これらは、リポジトリの .github ディレクトリ内の copilot-instructions.md ファイルで指定されます。 「リポジトリ全体のカスタム指示の作成」を参照してください。

  • パス固有のカスタム指示。指定したパスに一致するファイルのコンテキストで行われたリクエストに適用されます。

    これらは、リポジトリの .github/instructions ディレクトリ内の 1 つ以上の NAME.instructions.md ファイルで指定されます。 「パス固有のカスタム指示の作成」を参照してください。

    指定したパスが Copilot による処理対象であるファイルと一致し、リポジトリ全体のカスタム指示ファイルも存在する場合は、両方のファイルの指示が使われます。

リポジトリ全体のカスタム指示の作成

  1. リポジトリのルートに .github/copilot-instructions.md という名前のファイルを作成します。

    .github ディレクトリがまだ存在しない場合は作成します。

  2. Markdown 形式で自然言語の指示をファイルに追加します。

    指示と指示の間の空白は無視されます。このため複数の指示を 1 段落に記述することも、1 行に 1 つずつ記述することもできます。あるいは、読みやすくするために空白行で区切ることもできます。

パス固有のカスタム指示の作成

  1. Create the .github/instructions directory if it does not already exist.

  2. Create one or more NAME.instructions.md files, where NAME indicates the purpose of the instructions. The file name must end with .instructions.md.

  3. At the start of the file, create a frontmatter block containing the applyTo keyword. Use glob syntax to specify what files or directories the instructions apply to.

    For example:

    ---
    applyTo: "app/models/**/*.rb"
    ---
    

    You can specify multiple patterns by separating them with commas. For example, to apply the instructions to all TypeScript files in the repository, you could use the following frontmatter block:

    ---
    applyTo: "**/*.ts,**/*.tsx"
    ---
    

    To apply the instructions to all files, use applyTo: "**".

  4. Add your custom instructions in natural language, using Markdown format. Whitespace between instructions is ignored, so the instructions can be written as a single paragraph, each on a new line, or separated by blank lines for legibility.

Visual Studio では、リポジトリに格納された 1 つの .github/copilot-instructions.md カスタム指示ファイルがサポートされています。

  1. リポジトリのルートに .github/copilot-instructions.md という名前のファイルを作成します。

    .github ディレクトリがまだ存在しない場合は作成します。

  2. Markdown 形式で自然言語の指示をファイルに追加します。

    指示と指示の間の空白は無視されます。このため複数の指示を 1 段落に記述することも、1 行に 1 つずつ記述することもできます。あるいは、読みやすくするために空白行で区切ることもできます。

GitHub.com で使用できるように、何種類かのリポジトリ カスタム指示を作成できます。

  • リポジトリ全体のカスタム指示は、リポジトリのコンテキストで行われたすべてのリクエストに適用されます。

    サポートしているもの: Copilot ChatCopilot コーディング エージェントCopilot コード レビュー

    これらは、リポジトリの .github ディレクトリ内の copilot-instructions.md ファイルで指定されます。 「リポジトリ全体のカスタム指示の作成」を参照してください。

  • パス固有のカスタム指示は、指定したパスに一致するファイルのコンテキストで行われたリクエストに適用されます。

    サポートしているもの: Copilot コーディング エージェントCopilot コード レビュー

    これらは、リポジトリの .github/instructions ディレクトリ内の 1 つ以上の NAME.instructions.md ファイルで指定されます。 「パス固有のカスタム指示の作成」を参照してください。

    指定したパスが Copilot による処理対象であるファイルと一致し、リポジトリ全体のカスタム指示ファイルも存在する場合は、両方のファイルの指示が使われます。

  • エージェントの指示は AI エージェントによって使われます。

    サポートしているもの: Copilot コーディング エージェント

    1 つ以上の AGENTS.md ファイルを作成し、リポジトリ内の任意の場所に格納できます。 Copilot が動作している場合は、ディレクトリ ツリー内の最も近い AGENTS.md ファイルが優先されます。

    または、リポジトリのルートに格納された 1 つの CLAUDE.md または GEMINI.md ファイルを使うこともできます。

リポジトリ全体のカスタム指示の作成

独自のカスタム指示ファイルをゼロから作成することもできます。 「独自の copilot-instructions.md ファイルの作成」を参照してください。 または、Copilot コーディング エージェント に生成を依頼することもできます。

Copilot コーディング エージェント への copilot-instructions.md ファイルの生成依頼

メモ

Copilot コーディング エージェント は パブリック プレビュー段階にあり、変更される可能性があります。 プレビュー期間中、この機能の使用は「GitHub プレリリース ライセンス条項」の対象となります。

  1. github.com/copilot/agents の [Agents] ページに移動します。

    このページには、GitHub 上の任意のページの検索バーの横にある ボタンをクリックし、サイドバーから [Agents] を選んでアクセスすることもできます。

  2. プロンプト フィールドのドロップダウン メニューを使用して、Copilot にカスタム指示の生成を依頼するリポジトリを選びます。

  3. 次のプロンプトをコピーし、必要に応じてカスタマイズします。

    Markdown
    Your task is to "onboard" this repository to Copilot coding agent by adding a .github/copilot-instructions.md file in the repository that contains information describing how a coding agent seeing it for the first time can work most efficiently.
    
    You will do this task only one time per repository and doing a good job can SIGNIFICANTLY improve the quality of the agent's work, so take your time, think carefully, and search thoroughly before writing the instructions.
    
    <Goals>
    - Reduce the likelihood of a coding agent pull request getting rejected by the user due to
    generating code that fails the continuous integration build, fails a validation pipeline, or
    having misbehavior.
    - Minimize bash command and build failures.
    - Allow the agent to complete its task more quickly by minimizing the need for exploration using grep, find, str_replace_editor, and code search tools.
    </Goals>
    
    <Limitations>
    - Instructions must be no longer than 2 pages.
    - Instructions must not be task specific.
    </Limitations>
    
    <WhatToAdd>
    
    Add the following high level details about the codebase to reduce the amount of searching the agent has to do to understand the codebase each time:
    <HighLevelDetails>
    
    - A summary of what the repository does.
    - High level repository information, such as the size of the repo, the type of the project, the languages, frameworks, or target runtimes in use.
    </HighLevelDetails>
    
    Add information about how to build and validate changes so the agent does not need to search and find it each time.
    <BuildInstructions>
    
    - For each of bootstrap, build, test, run, lint, and any other scripted step, document the sequence of steps to take to run it successfully as well as the versions of any runtime or build tools used.
    - Each command should be validated by running it to ensure that it works correctly as well as any preconditions and postconditions.
    - Try cleaning the repo and environment and running commands in different orders and document errors and and misbehavior observed as well as any steps used to mitigate the problem.
    - Run the tests and document the order of steps required to run the tests.
    - Make a change to the codebase. Document any unexpected build issues as well as the workarounds.
    - Document environment setup steps that seem optional but that you have validated are actually required.
    - Document the time required for commands that failed due to timing out.
    - When you find a sequence of commands that work for a particular purpose, document them in detail.
    - Use language to indicate when something should always be done. For example: "always run npm install before building".
    - Record any validation steps from documentation.
    </BuildInstructions>
    
    List key facts about the layout and architecture of the codebase to help the agent find where to make changes with minimal searching.
    <ProjectLayout>
    
    - A description of the major architectural elements of the project, including the relative paths to the main project files, the location
    of configuration files for linting, compilation, testing, and preferences.
    - A description of the checks run prior to check in, including any GitHub workflows, continuous integration builds, or other validation pipelines.
    - Document the steps so that the agent can replicate these itself.
    - Any explicit validation steps that the agent can consider to have further confidence in its changes.
    - Dependencies that aren't obvious from the layout or file structure.
    - Finally, fill in any remaining space with detailed lists of the following, in order of priority: the list of files in the repo root, the
    contents of the README, the contents of any key source files, the list of files in the next level down of directories, giving priority to the more structurally important and snippets of code from key source files, such as the one containing the main method.
    </ProjectLayout>
    </WhatToAdd>
    
    <StepsToFollow>
    - Perform a comprehensive inventory of the codebase. Search for and view:
    - README.md, CONTRIBUTING.md, and all other documentation files.
    - Search the codebase for build steps and indications of workarounds like 'HACK', 'TODO', etc.
    - All scripts, particularly those pertaining to build and repo or environment setup.
    - All build and actions pipelines.
    - All project files.
    - All configuration and linting files.
    - For each file:
    - think: are the contents or the existence of the file information that the coding agent will need to implement, build, test, validate, or demo a code change?
    - If yes:
       - Document the command or information in detail.
       - Explicitly indicate which commands work and which do not and the order in which commands should be run.
       - Document any errors encountered as well as the steps taken to workaround them.
    - Document any other steps or information that the agent can use to reduce time spent exploring or trying and failing to run bash commands.
    - Finally, explicitly instruct the agent to trust the instructions and only perform a search if the information in the instructions is incomplete or found to be in error.
    </StepsToFollow>
       - Document any errors encountered as well as the steps taken to work-around them.
    
    
  4. Click Send now or press Return.

Copilot will start a new session, which will appear in the list below the prompt box. Copilot will create a draft pull request, write your custom instructions, push them to the branch, then add you as a reviewer when it has finished, triggering a notification.

Writing your own copilot-instructions.md file

  1. In the root of your repository, create a file named .github/copilot-instructions.md.

    Create the .github directory if it does not already exist.

  2. Add natural language instructions to the file, in Markdown format.

    Whitespace between instructions is ignored, so the instructions can be written as a single paragraph, each on a new line, or separated by blank lines for legibility.

ヒント

The first time you create a pull request in a given repository with Copilot コーディング エージェント, Copilot will leave a comment with a link to automatically generate custom instructions for the repository.

Creating path-specific custom instructions

メモ

Currently, on GitHub.com, path-specific custom instructions are only supported for Copilot コーディング エージェント and Copilot コード レビュー.

  1. Create the .github/instructions directory if it does not already exist.

  2. Create one or more NAME.instructions.md files, where NAME indicates the purpose of the instructions. The file name must end with .instructions.md.

  3. At the start of the file, create a frontmatter block containing the applyTo keyword. Use glob syntax to specify what files or directories the instructions apply to.

    For example:

    ---
    applyTo: "app/models/**/*.rb"
    ---
    

    You can specify multiple patterns by separating them with commas. For example, to apply the instructions to all TypeScript files in the repository, you could use the following frontmatter block:

    ---
    applyTo: "**/*.ts,**/*.tsx"
    ---
    

    To apply the instructions to all files, use applyTo: "**".

  4. Add your custom instructions in natural language, using Markdown format. Whitespace between instructions is ignored, so the instructions can be written as a single paragraph, each on a new line, or separated by blank lines for legibility.

Did you successfully add a custom instructions file to your repository?

Yes No

Writing effective repository custom instructions

The instructions you add to your custom instruction file(s) should be short, self-contained statements that provide Copilot with relevant information to help it work in this repository. Because the instructions are sent with every chat message, they should be broadly applicable to most requests you will make in the context of the repository.

The exact structure you utilize for your instructions file(s) will vary by project and need, but the following guidelines provide a good starting point:

  • Provide an overview of the project you're working on, including its purpose, goals, and any relevant background information.
  • Include the folder structure of the repository, including any important directories or files that are relevant to the project.
  • Specify the coding standards and conventions that should be followed, such as naming conventions, formatting rules, and best practices.
  • Include any specific tools, libraries, or frameworks that are used in the project, along with any relevant version numbers or configurations.

The following instructions file(s) is an example of these practices in action:

# Project Overview

This project is a web application that allows users to manage their tasks and to-do lists. It is built using React and Node.js, and uses MongoDB for data storage.

## Folder Structure

- `/src`: Contains the source code for the frontend.
- `/server`: Contains the source code for the Node.js backend.
- `/docs`: Contains documentation for the project, including API specifications and user guides.

## Libraries and Frameworks

- React and Tailwind CSS for the frontend.
- Node.js and Express for the backend.
- MongoDB for data storage.

## Coding Standards

- Use semicolons at the end of each statement.
- Use single quotes for strings.
- Use function based components in React.
- Use arrow functions for callbacks.

## UI guidelines

- A toggle is provided to switch between light and dark mode.
- Application should have a modern and clean design.

リポジトリのサイズと複雑さも考慮する必要があります。 次のような指示は、共同作成者が少数の小規模なリポジトリではうまくいく可能性がありますが、大規模で多様なリポジトリでは、問題が発生する可能性があります

  • 応答を作成するときに外部リソースを参照するという要求
  • 特定のスタイルで回答するという指示
  • 常に特定の詳細レベルで応答するという要求

たとえば、次の指示では意図した結果が得られない場合があります

Always conform to the coding styles defined in styleguide.md in repo my-org/my-repo when generating code.

Use @terminal when answering questions about Git.

Answer all questions in the style of a friendly colleague, using informal language.

Answer all questions in less than 1000 characters, and words of no more than 12 characters.

使われているリポジトリのカスタム命令

ファイル内の指示は、ファイルを保存するとすぐに Copilot Chat で使用できます。 完全な指示セットは、そのリポジトリのコンテキストで Copilot に送信するリクエストに自動的に追加されます。 たとえば、Copilot Chat に送信するプロンプトに追加されます。

Copilot Chat のイマーシブ ビュー (github.com/copilot) では、指示ファイルを含むリポジトリをアタッチメントとして追加して、リポジトリ カスタム指示を使う会話を開始できます。

リポジトリ カスタム指示が Copilot Chat で使われるたびに、生成される応答に対する参照として指示ファイルが追加されます。 リポジトリ カスタム指示が使われたかどうかを確認するには、[Chat] パネルのチャット応答の上部にある参照一覧を展開し、.github/copilot-instructions.md ファイルが表示されるかどうかを調べます。

展開された [References] リストのスクリーンショット。'copilot-instructions.md' ファイルが濃いオレンジ色の枠線で強調表示されています。

参照をクリックしてファイルを開くことができます。

メモ

  • Multiple types of custom instructions can apply to a Copilot Chat conversation. Personal instructions take the highest priority, followed by repository instructions, with organization instructions prioritized last. However, all sets of relevant instructions are still combined and provided to Copilot Chat.
  • Whenever possible, you should avoid providing conflicting sets of instructions. If you are concerned about response quality, you can also choose to temporarily disable repository instructions. See GitHub Copilot のリポジトリ カスタム命令を追加する.

カスタム指示はチャット ビューやインライン チャットには表示されませんが、チャット ビューで応答の参照リストを確認することで、それらが Copilot によって使われていることを確認できます。 モデルに送信されたプロンプトにカスタム指示が追加されると、.github/copilot-instructions.md ファイルが参照として一覧表示されます。 参照をクリックしてファイルを開くことができます。

展開された [References] リストのスクリーンショット。'copilot-instructions.md' ファイルが濃いオレンジ色の枠線で強調表示されています。

カスタム指示はチャット ビューやインライン チャットには表示されませんが、チャット ビューで応答の参照リストを確認することで、それらが Copilot によって使われていることを確認できます。 モデルに送信されたプロンプトにカスタム指示が追加されると、.github/copilot-instructions.md ファイルが参照として一覧表示されます。 参照をクリックしてファイルを開くことができます。

[References] ポップアップのスクリーンショット。'copilot-instructions.md' ファイルが濃いオレンジ色の枠線で強調表示されています。

カスタム指示はチャット ビューやインライン チャットには表示されませんが、チャット ビューで応答の参照リストを確認することで、それらが Copilot によって使われていることを確認できます。 モデルに送信されたプロンプトにカスタム指示が追加されると、.github/copilot-instructions.md ファイルが参照として一覧表示されます。 参照をクリックしてファイルを開くことができます。

カスタム指示はチャット ビューやインライン チャットには表示されませんが、チャット ビューで応答の参照リストを確認することで、それらが Copilot によって使われていることを確認できます。 モデルに送信されたプロンプトにカスタム指示が追加されると、.github/copilot-instructions.md ファイルが参照として一覧表示されます。 参照をクリックしてファイルを開くことができます。

リポジトリのカスタム命令の有効化または無効化

Copilot でリポジトリベースのカスタム指示を使うかどうかを選択できます。

Copilot Chat のカスタム指示を有効または無効にする

カスタム指示は、Copilot Chat に対して既定で有効になっていますが、いつでも無効にしたり、再度有効にしたりすることができます。 これは、Copilot Chat の個人の使用に適用され、他のユーザーには影響しません。

  1. GitHub.com 上で、次のいずれかを実行します。

    • カスタム指示ファイルがあるリポジトリに移動し、補助チャット パネルを開きます。
    • Copilot Chat (github.com/copilot) のイマーシブ ビューに移動し、カスタム指示ファイルを含むリポジトリをアタッチします。
  2. [Chat] パネルの上部、またはイマーシブ ページの右上にある ボタンをクリックします。

  3. [Disable custom instructions] または [Enable custom instructions] をクリックします。

    メモ

    これらのオプションは、カスタム指示ファイルが含まれているリポジトリのコンテキストでのみ表示されます。

選択内容は、変更するまで、カスタム指示ファイルを含むすべてのリポジトリに対して保持されます。

Copilot コード レビュー のカスタム指示を有効または無効にする

カスタム指示は、既定で Copilot コード レビュー に対して有効になっていますが、GitHub.com のリポジトリ設定で無効にしたり、再度有効にしたりすることができます。 これは、このリポジトリで実行されるすべてのコード レビューに対する Copilot のカスタム指示の使用に適用されます。

  1. GitHub で、リポジトリのメイン ページに移動します。

  2. リポジトリ名の下にある [設定] をクリックします。 [設定] タブが表示されない場合は、 [] ドロップダウン メニューを選び、 [設定] をクリックします。

    タブを示すリポジトリ ヘッダーのスクリーンショット。 [設定] タブが濃いオレンジ色の枠線で強調表示されています。

  3. サイドバーの [Code & automation] セクションで、 [Copilot][Code review] の順にクリックします。

  4. [Use custom instructions when reviewing pull requests] オプションをオンまたはオフに切り替えます。

リポジトリのカスタム命令の有効化または無効化

Copilot でリポジトリベースのカスタム指示を使うかどうかを選択できます。

Copilot Chat のカスタム指示を有効または無効にする

カスタム指示は、Copilot Chat に対して既定で有効になっていますが、いつでも無効にしたり、再度有効にしたりすることができます。 これは、Copilot Chat の個人の使用に適用され、他のユーザーには影響しません。

  1. キーボード ショートカット Command+, (Mac) / Ctrl+, (Linux/Windows) を使用して設定エディターを開きます。
  2. 検索ボックスに、「instruction file」と入力します。
  3. [Code Generation: Use Instruction Files] の下のチェックボックスをオンまたはオフにします。

Copilot コード レビュー のカスタム指示を有効または無効にする

カスタム指示は、既定で Copilot コード レビュー に対して有効になっていますが、GitHub.com のリポジトリ設定で無効にしたり、再度有効にしたりすることができます。 これは、このリポジトリで実行されるすべてのコード レビューに対する Copilot のカスタム指示の使用に適用されます。

  1. GitHub で、リポジトリのメイン ページに移動します。

  2. リポジトリ名の下にある [設定] をクリックします。 [設定] タブが表示されない場合は、 [] ドロップダウン メニューを選び、 [設定] をクリックします。

    タブを示すリポジトリ ヘッダーのスクリーンショット。 [設定] タブが濃いオレンジ色の枠線で強調表示されています。

  3. サイドバーの [Code & automation] セクションで、 [Copilot][Code review] の順にクリックします。

  4. [Use custom instructions when reviewing pull requests] オプションをオンまたはオフに切り替えます。

リポジトリのカスタム命令の有効化または無効化

Copilot でリポジトリベースのカスタム指示を使うかどうかを選択できます。

Copilot Chat のカスタム指示を有効または無効にする

カスタム指示は、Copilot Chat に対して既定で有効になっていますが、いつでも無効にしたり、再度有効にしたりすることができます。 これは、Copilot Chat の個人の使用に適用され、他のユーザーには影響しません。

  1. Visual Studio メニュー バーの [ツール] で、 [オプション] をクリックします。

    Visual Studio メニュー バーのスクリーンショット。 [ツール] メニューが展開され、[オプション] 項目がオレンジ色の枠線で強調表示されています。

  2. [Options] ダイアログで、検索ボックスに「custom instructions」と入力し、[Copilot] をクリックします。

  3. [Enable custom instructions to be loaded from .github/copilot-instructions.md files and added to requests] のチェックボックスをオンまたはオフにします。

    [Enable custom instructions] オプションのチェックボックスがオンになっている Visual Studio の [Options] ダイアログのスクリーンショット。

Copilot コード レビュー のカスタム指示を有効または無効にする

カスタム指示は、既定で Copilot コード レビュー に対して有効になっていますが、GitHub.com のリポジトリ設定で無効にしたり、再度有効にしたりすることができます。 これは、このリポジトリで実行されるすべてのコード レビューに対する Copilot のカスタム指示の使用に適用されます。

  1. GitHub で、リポジトリのメイン ページに移動します。

  2. リポジトリ名の下にある [設定] をクリックします。 [設定] タブが表示されない場合は、 [] ドロップダウン メニューを選び、 [設定] をクリックします。

    タブを示すリポジトリ ヘッダーのスクリーンショット。 [設定] タブが濃いオレンジ色の枠線で強調表示されています。

  3. サイドバーの [Code & automation] セクションで、 [Copilot][Code review] の順にクリックします。

  4. [Use custom instructions when reviewing pull requests] オプションをオンまたはオフに切り替えます。

プロンプト ファイルの有効化と使用

メモ

プロンプト ファイルを使うと、追加のコンテキストを含む再利用可能なプロンプト命令を作成し、共有することができます。 プロンプト ファイルはワークスペースに格納される Markdown ファイルです。Copilot Chat でプロンプトを記述する既存の形式 (たとえば、Rewrite #file:x.ts) を模倣したものです。 ワークスペースには複数のプロンプト ファイルを含めることができます。そのそれぞれに異なる目的のプロンプトを定義します。

プロンプト ファイルを有効にする

プロンプト ファイルを有効にするには、ワークスペースの設定を構成します。

  1. Ctrl+Shift+P キー (Windows/Linux) または Command+Shift+P キー (Mac) を押してコマンド パレットを開きます。
  2. 「Open Workspace Settings (JSON)」と入力し、表示されるオプションを選びます。
  3. settings.json ファイルに "chat.promptFiles": true を追加します。これで、.github/prompts フォルダーはプロンプト ファイルの場所として有効になります。 このフォルダーが存在しない場合は作成されます。

プロンプト ファイルを作成する

  1. Ctrl+Shift+P キー (Windows/Linux) または Command+Shift+P キー (Mac) を押してコマンド パレットを開きます。

  2. 「prompt」と入力し、[Chat: Create Prompt] を選びます。

  3. ファイル名の拡張子 .prompt.md を除いたプロンプト ファイルの名前を入力します。 名前には英数字とスペースを含めることができます。また、ファイルに含まれるプロンプト情報の目的がわかるようにすることをお勧めします。

  4. Markdown 形式を使ってプロンプト命令を記述します。

    ワークスペース内の他のファイルを参照するには、Markdown リンク ([index](../../web/index.ts) など) を使うか、#file:../../web/index.ts 構文を使います。 パスはプロンプト ファイルからの相対パスです。 他のファイルを参照することで、API 仕様や製品ドキュメントなどの追加のコンテキストを提供できます。

プロンプト ファイルを使う

  1. Copilot Chat ビューの下部にある [Attach context] アイコン () をクリックします。

  2. ドロップダウン メニューの **[Prompt...] ** をクリックし、使うプロンプト ファイルを選びます。

  3. 必要に応じて、プロンプト ファイルなどの追加ファイルを添付して、より多くのコンテキストを提供します。

  4. 必要に応じて、チャット プロンプト ボックスにその他の情報を入力します。

    これが必要かどうかは、使うプロンプトのコンテンツによって異なります。

  5. チャット プロンプトを送信します。

プロンプト ファイルについて詳しくは、Visual Studio Code のドキュメントの「VS Code での GitHub Copilot に対するカスタム指示」をご覧ください。