この記事のこのバージョンは、GitHub Web サイト上でリポジトリのカスタム命令を使うためのものです。 他の環境でカスタム指示を使う方法については、上のタブをクリックします。
この記事のこのバージョンでは、VS Code でのリポジトリ カスタム指示とプロンプト ファイルの使用について説明します。 他の環境でカスタム指示を使う手順については、上のタブをクリックします。
この記事のこのバージョンは、Visual Studio でリポジトリのカスタム命令を使うためのものです。 他の環境でカスタム指示を使う手順については、上のタブをクリックします。
この記事のこのバージョンでは、JetBrains IDE でのリポジトリ カスタム指示の使用について説明します。 他の環境でカスタム指示を使う手順については、上のタブをクリックします。
この記事のこのバージョンでは、Xcode でのリポジトリ カスタム指示の使用について説明します。 他の環境でカスタム指示を使う手順については、上のタブをクリックします。
メモ
この機能は現在パブリック プレビューにあり、変更される可能性があります。
この記事のこのバージョンでは、Eclipse でのリポジトリ カスタム指示の使用について説明します。 他の環境でカスタム指示を使う手順については、上のタブをクリックします。
Copilot に対するリポジトリのカスタム指示について
リポジトリ カスタム指示を使うと、Copilot にリポジトリ固有のガイダンスとユーザー設定を提供できます。
現在、リポジトリのカスタム指示は以下でサポートされています。
- VS Code の Copilot Chat
- Copilot コーディング エージェント
- Visual Studio、JetBrains IDE、Xcode、および GitHub Web サイトでの Copilot Chat (
copilot-instructions.md
ファイルのみ) - Copilot コード レビュー (
copilot-instructions.md
ファイルのみ)
リポジトリ カスタム指示の前提条件
- カスタム指示ファイルが必要です (後述する手順を参照してください)。
- カスタム指示を使うかどうかという個人の選択肢は、有効に設定する必要があります。 この機能は、既定では有効になっています。 この記事で後述する「リポジトリのカスタム命令の有効化または無効化」を参照してください。
- 自分の設定で [Use Instruction Files] オプションを有効にする必要があります。 この機能は、既定では有効になっています。 この記事で後述する「リポジトリのカスタム命令の有効化または無効化」を参照してください。
- 自分の設定で [Enable custom instructions...] オプションを有効にする必要があります。 この機能は、既定では有効になっています。 この記事で後述する「リポジトリのカスタム命令の有効化または無効化」を参照してください。
- 最新バージョンの Copilot 拡張機能が JetBrains IDE にインストールされている必要があります。
- 最新バージョンの Copilot 拡張機能が Xcode にインストールされている必要があります。
- 最新バージョンの Copilot 拡張機能が Eclipse にインストールされている必要があります。
リポジトリのカスタム命令ファイルを作成する
JetBrains IDE では、リポジトリに格納されている 1 つの .github/copilot-instructions.md
カスタム指示ファイルがサポートされています。
Copilot 設定ページを使ってリポジトリにカスタム指示ファイルを作成することも、手動でファイルを作成することもできます。
指示と指示の間の空白は無視されます。このため複数の指示を 1 段落に記述することも、1 行に 1 つずつ記述することもできます。あるいは、読みやすくするために空白行で区切ることもできます。
設定ページの使用
- JetBrains IDE で、ファイル メニュー (Windows) またはメニュー バー (macOS) のアプリケーションの名前をクリックし、設定 をクリックします。
- Languages & Frameworks で、 [GitHub Copilot] をクリックします。
- [Copilot Instructions] で、[Workspace] または [Global] をクリックし、カスタム指示を現在のワークスペースまたはすべてのワークスペースのどちらに適用するかを選びます。
ワークスペース カスタム指示ファイルの手作業での作成
-
リポジトリのルートに
.github/copilot-instructions.md
という名前のファイルを作成します。.github
ディレクトリがまだ存在しない場合は作成します。 -
Markdown 形式で自然言語の指示をファイルに追加します。
保存したこれらの指示は、Copilot を有効にして開いた JetBrains IDE の現在のワークスペースに適用されます。
グローバル カスタム指示ファイルの手作業での作成
同じ指示を JetBrains IDE 内のすべてのワークスペースに適用するには、ローカル コンピューターでグローバル カスタム指示ファイルを作成できます。
-
エクスプローラーまたはターミナルを開きます。
-
オペレーティング システムの適切な場所に移動します。
- macOS:
/Users/YOUR-USERNAME/.config/github-copilot/intellij/
- Windows:
C:\Users\YOUR-USERNAME\AppData\Local\github-copilot\intellij\
- macOS:
-
そのディレクトリに
global-copilot-instructions.md
という名前のファイルを作成します。 -
Markdown 形式を使い、自然言語でカスタム指示を追加します。
保存したこれらの指示は、Copilot を有効にして開いた JetBrains IDE のすべてのワークスペースにグローバルに適用されます。
Xcode では、リポジトリに格納されている 1 つの .github/copilot-instructions.md
カスタム指示ファイルがサポートされています。
Copilot 設定ページを使って、リポジトリにカスタム指示ファイルを作成できます。
指示と指示の間の空白は無視されます。このため複数の指示を 1 段落に記述することも、1 行に 1 つずつ記述することもできます。あるいは、読みやすくするために空白行で区切ることもできます。
- GitHub Copilot for Xcode アプリケーションを開きます。
- アプリケーション ウィンドウの上部にある [Settings] で、[Advanced] をクリックします。
- [Custom Instructions] の右側で [Current Workspace] または [Global] をクリックして、カスタム指示を現在のワークスペースまたはすべてのワークスペースのどちらに適用するかを選びます。
Eclipse では、ワークスペースとプロジェクトの 2 種類のリポジトリ カスタム指示がサポートされています。
ワークスペース カスタム指示ファイルを作成するには、Copilot の設定ページを使用できます。 プロジェクト カスタム指示ファイルを作成するには、プロジェクト ディレクトリでファイルを手動で作成できます。
指示と指示の間の空白は無視されます。このため複数の指示を 1 段落に記述することも、1 行に 1 つずつ記述することもできます。あるいは、読みやすくするために空白行で区切ることもできます。
ワークスペース カスタム指示ファイルの作成
- Copilot Chat パネルを開くには、Eclipse の下部にあるステータス バーで Copilot アイコン () をクリックします。
- メニューの [Edit preferences] を選びます。
- 左側のペインで、GitHub Copilot を展開して [Custom Instructions] をクリックします。
- [Enable workspace instructions] を選びます。
- [Workspace] セクションの [Set custom instructions to guide Copilot's code suggestions in this workspace] で、Markdown 形式を使って自然言語の指示をファイルに追加します。
プロジェクト カスタム指示ファイルの作成
- プロジェクト ディレクトリのルートに、
.github/copilot-instructions.md
という名前のファイルを作成します。 - Markdown 形式を使い、自然言語でカスタム指示を追加します。
保存したこれらの指示は、Copilot を有効にして開いた Eclipse の現在のプロジェクトに適用されます。
VS Code では次のどちらかがサポートされます。
- リポジトリに格納されている 1 つの
.github/copilot-instructions.md
カスタム指示ファイル - リポジトリ内の
.github/instructions
に格納されている 1 つ以上の.instructions.md
ファイル。 各ファイルではapplyTo
フロントマターを指定して、その指示が適用されるファイルまたはディレクトリを定義できます。
1 つの .github/copilot-instructions.md
ファイルの使用
-
リポジトリのルートに
.github/copilot-instructions.md
という名前のファイルを作成します。.github
ディレクトリがまだ存在しない場合は作成します。 -
Markdown 形式で自然言語の指示をファイルに追加します。
指示と指示の間の空白は無視されます。このため複数の指示を 1 段落に記述することも、1 行に 1 つずつ記述することもできます。あるいは、読みやすくするために空白行で区切ることもできます。
1 つ以上の .instructions.md
ファイルの使用
-
.github/instructions
ディレクトリがまだ存在しない場合は作成します。 -
1 つ以上の
.instructions.md
ファイルを作成し、自然言語の指示をファイルに追加します。指示と指示の間の空白は無視されます。このため複数の指示を 1 段落に記述することも、1 行に 1 つずつ記述することもできます。あるいは、読みやすくするために空白行で区切ることもできます。
-
glob 構文を使って、Markdown ファイルに
applyTo
フロントマターを追加し、指示が適用されるファイルまたはディレクトリを指定します。--- applyTo: "app/models/**/*.rb" --- Add custom instructions here
指示をすべてのファイルに適用するには、
**
パターンを使います。
Visual Studio では、リポジトリに格納された 1 つの .github/copilot-instructions.md
カスタム指示ファイルがサポートされています。
-
リポジトリのルートに
.github/copilot-instructions.md
という名前のファイルを作成します。.github
ディレクトリがまだ存在しない場合は作成します。 -
Markdown 形式で自然言語の指示をファイルに追加します。
指示と指示の間の空白は無視されます。このため複数の指示を 1 段落に記述することも、1 行に 1 つずつ記述することもできます。あるいは、読みやすくするために空白行で区切ることもできます。
GitHub Web サイトの Copilot Chat、Copilot コーディング エージェント、Copilot コード レビュー では、リポジトリに格納された 1 つの .github/copilot-instructions.md
カスタム指示ファイルがサポートされています。
さらに、Copilot コーディング エージェント では次のものがサポートされています。
- リポジトリ内の
.github/instructions
に格納されている 1 つ以上の.instructions.md
ファイル。 各ファイルではapplyTo
フロントマターを指定して、その指示が適用されるファイルまたはディレクトリを定義できます。 - リポジトリ内の任意の場所に格納されている 1 つ以上の
AGENTS.md
ファイル。 Copilot が動作している場合は、ディレクトリ ツリー内の最も近いAGENTS.md
ファイルが優先されます。 - リポジトリのルートに格納されている 1 つの
CLAUDE.md
またはGEMINI.md
ファイル。
1 つの .github/copilot-instructions.md
ファイルの使用
Copilot コーディング エージェント に .github/copilot-instructions.md
ファイルの生成を依頼するか、独自の指示ファイルを作成できます。
Copilot コーディング エージェント への .github/copilot-instructions.md
ファイルの生成依頼
メモ
Copilot コーディング エージェント は パブリック プレビュー段階にあり、変更される可能性があります。 プレビュー期間中、この機能の使用は「GitHub プレリリース ライセンス条項」の対象となります。
-
github.com/copilot/agents の [Agents] ページに移動します。
このページには、GitHub 上の任意のページの検索バーの横にある ボタンをクリックし、サイドバーから [Agents] を選んでアクセスすることもできます。
-
プロンプト フィールドのドロップダウン メニューを使用して、Copilot にカスタム指示の生成を依頼するリポジトリを選びます。
-
次のプロンプトをコピーし、必要に応じてカスタマイズします。
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.
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.
-
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 .github/copilot-instructions.md
file
-
In the root of your repository, create a file named
.github/copilot-instructions.md
.Create the
.github
directory if it does not already exist. -
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.
Using one or more .instructions.md
files
-
Create the
.github/instructions
directory if it does not already exist. -
Create one or more
.instructions.md
files, adding natural language instructions to the file(s).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.
-
Specify what files or directories the instructions apply to by adding
applyTo
frontmatter to the Markdown files, using glob syntax.--- applyTo: "app/models/**/*.rb" --- Add custom instructions here
指示をすべてのファイルに適用するには、
**
パターンを使います。
効果的なリポジトリのカスタム命令を作成する
カスタム指示ファイルに追加する指示は、このリポジトリでの動作に役立つ関連情報を Copilot に提供する、短い自己完結型の文章にする必要があります。 指示はすべてのチャット メッセージと共に送信されるため、リポジトリのコンテキストで行うほとんどの要求に幅広く適用できるものである必要があります。
指示ファイルに使う正確な構造は、プロジェクトとニーズによって異なりますが、次のガイドラインがよい出発点となります。
- 目的、目標、関連する背景情報など、作業中のプロジェクトの概要を提供します。
- プロジェクトに関連する重要なディレクトリやファイルなど、リポジトリのフォルダー構造を含めます。
- 名前付け規則、書式設定規則、ベスト プラクティスなど、従う必要があるコーディング標準と規則を指定します。
- プロジェクトで使われる特定のツール、ライブラリ、またはフレームワークを、関連するバージョン番号または構成と共に含めます。
次の指示ファイルは、これらの手法が実際に行われている例です。
# 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
ファイルが表示されるかどうかを調べます。
参照をクリックしてファイルを開くことができます。
メモ
- 複数の種類のカスタム命令を会話に適用できます。 個人用命令は最も優先順位が高く、その後にリポジトリ命令、最後に organization 用命令の順になります。 ただし、関連するすべての命令セットは引き続き結合され、Copilot Chat に提供されます。
- 可能な限り、競合する命令セットを提供しないようにする必要があります。 回答の品質に問題がある場合は、リポジトリ命令を一時的に無効にすることもできます。 「GitHub Copilot のリポジトリ カスタム命令を追加する」をご覧ください。
カスタム指示はチャット ビューやインライン チャットには表示されませんが、チャット ビューで応答の参照リストを確認することで、それらが Copilot によって使われていることを確認できます。 モデルに送信されたプロンプトにカスタム指示が追加されると、.github/copilot-instructions.md
ファイルが参照として一覧表示されます。 参照をクリックしてファイルを開くことができます。
カスタム指示はチャット ビューやインライン チャットには表示されませんが、チャット ビューで応答の参照リストを確認することで、それらが Copilot によって使われていることを確認できます。 モデルに送信されたプロンプトにカスタム指示が追加されると、.github/copilot-instructions.md
ファイルが参照として一覧表示されます。 参照をクリックしてファイルを開くことができます。
カスタム指示はチャット ビューやインライン チャットには表示されませんが、チャット ビューで応答の参照リストを確認することで、それらが Copilot によって使われていることを確認できます。 モデルに送信されたプロンプトにカスタム指示が追加されると、.github/copilot-instructions.md
ファイルが参照として一覧表示されます。 参照をクリックしてファイルを開くことができます。
カスタム指示はチャット ビューやインライン チャットには表示されませんが、チャット ビューで応答の参照リストを確認することで、それらが Copilot によって使われていることを確認できます。 モデルに送信されたプロンプトにカスタム指示が追加されると、.github/copilot-instructions.md
ファイルが参照として一覧表示されます。 参照をクリックしてファイルを開くことができます。
リポジトリのカスタム命令の有効化または無効化
Copilot でリポジトリベースのカスタム指示を使うかどうかを選択できます。
Copilot Chat のカスタム指示を有効または無効にする
カスタム指示は、Copilot Chat に対して既定で有効になっていますが、いつでも無効にしたり、再度有効にしたりすることができます。 これは、Copilot Chat の個人の使用に適用され、他のユーザーには影響しません。
-
GitHub.com 上で、次のいずれかを実行します。
- カスタム指示ファイルがあるリポジトリに移動し、補助チャット パネルを開きます。
- Copilot Chat (github.com/copilot) のイマーシブ ビューに移動し、カスタム指示ファイルを含むリポジトリをアタッチします。
-
[Chat] パネルの上部、またはイマーシブ ページの右上にある ボタンをクリックします。
-
[Disable custom instructions] または [Enable custom instructions] をクリックします。
メモ
これらのオプションは、カスタム指示ファイルが含まれているリポジトリのコンテキストでのみ表示されます。
選択内容は、変更するまで、カスタム指示ファイルを含むすべてのリポジトリに対して保持されます。
Copilot コード レビュー のカスタム指示を有効または無効にする
カスタム指示は、既定で Copilot コード レビュー に対して有効になっていますが、GitHub.com のリポジトリ設定で無効にしたり、再度有効にしたりすることができます。 これは、このリポジトリで実行されるすべてのコード レビューに対する Copilot のカスタム指示の使用に適用されます。
-
GitHub で、リポジトリのメイン ページに移動します。
-
リポジトリ名の下にある [設定] をクリックします。 [設定] タブが表示されない場合は、 [] ドロップダウン メニューを選び、 [設定] をクリックします。
-
サイドバーの [Code & automation] セクションで、 [Copilot]、[Code review] の順にクリックします。
-
[Use custom instructions when reviewing pull requests] オプションをオンまたはオフに切り替えます。
リポジトリのカスタム命令の有効化または無効化
Copilot でリポジトリベースのカスタム指示を使うかどうかを選択できます。
Copilot Chat のカスタム指示を有効または無効にする
カスタム指示は、Copilot Chat に対して既定で有効になっていますが、いつでも無効にしたり、再度有効にしたりすることができます。 これは、Copilot Chat の個人の使用に適用され、他のユーザーには影響しません。
- キーボード ショートカット Command+, (Mac) / Ctrl+, (Linux/Windows) を使用して設定エディターを開きます。
- 検索ボックスに、「
instruction file
」と入力します。 - [Code Generation: Use Instruction Files] の下のチェックボックスをオンまたはオフにします。
Copilot コード レビュー のカスタム指示を有効または無効にする
カスタム指示は、既定で Copilot コード レビュー に対して有効になっていますが、GitHub.com のリポジトリ設定で無効にしたり、再度有効にしたりすることができます。 これは、このリポジトリで実行されるすべてのコード レビューに対する Copilot のカスタム指示の使用に適用されます。
-
GitHub で、リポジトリのメイン ページに移動します。
-
リポジトリ名の下にある [設定] をクリックします。 [設定] タブが表示されない場合は、 [] ドロップダウン メニューを選び、 [設定] をクリックします。
-
サイドバーの [Code & automation] セクションで、 [Copilot]、[Code review] の順にクリックします。
-
[Use custom instructions when reviewing pull requests] オプションをオンまたはオフに切り替えます。
リポジトリのカスタム命令の有効化または無効化
Copilot でリポジトリベースのカスタム指示を使うかどうかを選択できます。
Copilot Chat のカスタム指示を有効または無効にする
カスタム指示は、Copilot Chat に対して既定で有効になっていますが、いつでも無効にしたり、再度有効にしたりすることができます。 これは、Copilot Chat の個人の使用に適用され、他のユーザーには影響しません。
-
Visual Studio メニュー バーの [ツール] で、 [オプション] をクリックします。
-
[Options] ダイアログで、検索ボックスに「
custom instructions
」と入力し、[Copilot] をクリックします。 -
[Enable custom instructions to be loaded from .github/copilot-instructions.md files and added to requests] のチェックボックスをオンまたはオフにします。
Copilot コード レビュー のカスタム指示を有効または無効にする
カスタム指示は、既定で Copilot コード レビュー に対して有効になっていますが、GitHub.com のリポジトリ設定で無効にしたり、再度有効にしたりすることができます。 これは、このリポジトリで実行されるすべてのコード レビューに対する Copilot のカスタム指示の使用に適用されます。
-
GitHub で、リポジトリのメイン ページに移動します。
-
リポジトリ名の下にある [設定] をクリックします。 [設定] タブが表示されない場合は、 [] ドロップダウン メニューを選び、 [設定] をクリックします。
-
サイドバーの [Code & automation] セクションで、 [Copilot]、[Code review] の順にクリックします。
-
[Use custom instructions when reviewing pull requests] オプションをオンまたはオフに切り替えます。
プロンプト ファイルの有効化と使用
メモ
プロンプト ファイルは パブリック プレビュー 段階であり、変更される可能性があります。
プロンプト ファイルを使うと、追加のコンテキストを含む再利用可能なプロンプト命令を作成し、共有することができます。 プロンプト ファイルはワークスペースに格納される Markdown ファイルです。Copilot Chat でプロンプトを記述する既存の形式 (たとえば、Rewrite #file:x.ts
) を模倣したものです。 ワークスペースには複数のプロンプト ファイルを含めることができます。そのそれぞれに異なる目的のプロンプトを定義します。
プロンプト ファイルを有効にする
プロンプト ファイルを有効にするには、ワークスペースの設定を構成します。
- Ctrl+Shift+P キー (Windows/Linux) または Command+Shift+P キー (Mac) を押してコマンド パレットを開きます。
- 「Open Workspace Settings (JSON)」と入力し、表示されるオプションを選びます。
settings.json
ファイルに"chat.promptFiles": true
を追加します。これで、.github/prompts
フォルダーはプロンプト ファイルの場所として有効になります。 このフォルダーが存在しない場合は作成されます。
プロンプト ファイルを作成する
-
Ctrl+Shift+P キー (Windows/Linux) または Command+Shift+P キー (Mac) を押してコマンド パレットを開きます。
-
「prompt」と入力し、[Chat: Create Prompt] を選びます。
-
ファイル名の拡張子
.prompt.md
を除いたプロンプト ファイルの名前を入力します。 名前には英数字とスペースを含めることができます。また、ファイルに含まれるプロンプト情報の目的がわかるようにすることをお勧めします。 -
Markdown 形式を使ってプロンプト命令を記述します。
ワークスペース内の他のファイルを参照するには、Markdown リンク (
[index](../../web/index.ts)
など) を使うか、#file:../../web/index.ts
構文を使います。 パスはプロンプト ファイルからの相対パスです。 他のファイルを参照することで、API 仕様や製品ドキュメントなどの追加のコンテキストを提供できます。
プロンプト ファイルを使う
-
Copilot Chat ビューの下部にある [Attach context] アイコン () をクリックします。
-
ドロップダウン メニューの **[Prompt...] ** をクリックし、使うプロンプト ファイルを選びます。
-
必要に応じて、プロンプト ファイルなどの追加ファイルを添付して、より多くのコンテキストを提供します。
-
必要に応じて、チャット プロンプト ボックスにその他の情報を入力します。
これが必要かどうかは、使うプロンプトのコンテンツによって異なります。
-
チャット プロンプトを送信します。
プロンプト ファイルについて詳しくは、Visual Studio Code のドキュメントの「VS Code での GitHub Copilot に対するカスタム指示」をご覧ください。