メモ
- The examples in this library are intended for inspiration—you are encouraged to adjust them to be more specific to your projects, languages, and team processes.
- For community-contributed examples of custom instructions for specific languages and scenarios, see the Awesome GitHub Copilot Customizations repository.
- You can apply custom instructions across different scopes, depending on the platform or IDE where you are creating them. For more information, see "GitHub Copilot Chat の回答のカスタマイズについて."
カスタマイズについて
次の 2 種類のファイルを使って、GitHub Copilot の応答をカスタマイズできます。
- カスタム指示では、ユーザーのすべての対話に対して GitHub Copilot がどのように動作する必要があるかについての実行時のガイダンスを提供します。
- プロンプト ファイル (パブリック プレビュー) では、必要に応じて呼び出すことができる、特定のタスクに対する再利用可能なプロンプトを定義します。 プロンプト ファイルは、VS Code でのみ使用できます。 初歩的な例については、「初めてのプロンプト ファイル」をご覧ください。
カスタム指示は各 AI ワークフローにコンテキストを追加するのに役立ちますが、プロンプト ファイルを使うと、チャットの特定の対話に指示を追加できます。
最もよく使われてサポートされるのはリポジトリ カスタム指示ですが、GitHub Copilot Chat in GitHub の場合のみ、個人および organization のカスタム指示を定義することもできます。 You can create repository custom instructions in two ways:
- Repository-wide instructions: Create a single
copilot-instructions.md
file at the repository root that applies to all files in the repository. - Path-specific instructions: Create one or more
.instructions.md
files with anapplyTo
field that apply only to specific files or directories. Path-specific instructions are currently supported for Copilot Chat in Visual Studio Code and GitHub Copilot coding agent.
初めての指示
最初に見るのは、GitHub Copilot がコーディングの優先事項を理解するのに役立つ、次のコア カスタム指示です。
関数の記述に関する指示
When writing functions, always: - Add descriptive JSDoc comments - Include input validation - Use early returns for error conditions - Add meaningful variable names - Include at least one example usage in comments
When writing functions, always:
- Add descriptive JSDoc comments
- Include input validation
- Use early returns for error conditions
- Add meaningful variable names
- Include at least one example usage in comments
これらの指示により、GitHub Copilot が関数を生成する方法が変わります。
テストする
カスタム指示によって実現できる効果を簡単にテストしてみるには、Copilot Chat のイマーシブ ビューで個人のカスタム指示を使用できます。
-
最初に、github.com/copilot に移動して次のプロンプトを入力します。
Create a JavaScript function that calculates the area of a circle
カスタム指示がない場合は、たとえば次のような結果になります。
function areaOfCircle(radius) { if (typeof radius !== 'number' || radius < 0) { throw new Error('Radius must be a non-negative number'); } return Math.PI * radius * radius; }
-
次に、ページの左下にあるプロフィール画像をクリックして個人のカスタム指示にアクセスし、[Personal instructions] をクリックします。 上記の指示をテキスト ボックスに貼り付けて、[Save] をクリックします。
次に、前に入力したのと同じプロンプトを入力します。
カスタム指示を使うと、次のような結果になります。
/** * Calculates the area of a circle given its radius. * * @param {number} radius - The radius of the circle. Must be a positive number. * @returns {number|null} The area of the circle, or null if the input is invalid. * * @example * // returns 78.53981633974483 * areaOfCircle(5); * * @example * // returns null (invalid input) * areaOfCircle(-2); */ function areaOfCircle(radius) { if (typeof radius !== "number" || isNaN(radius) || radius <= 0) { // Invalid input: radius must be a positive number return null; } const area = Math.PI * Math.pow(radius, 2); return area; } // Example usage: console.log(areaOfCircle(5)); // 78.53981633974483 console.log(areaOfCircle(-2)); // null
Further reading
- GitHub Copilot Chat の回答のカスタマイズについて - Overview of response customization in GitHub Copilot
- GitHub Copilot のカスタム指示を構成する - How to configure custom instructions
- Awesome GitHub Copilot Customizations - Repository of community-contributed custom instructions and other customizations for specific languages and scenarios