カスタム指示機能を使用して、カスタマイズされたコンテキストの詳細をプロンプトに自動的に追加します。 Copilot Chat では、これらの手順を使用して、個人の好みに基づいて応答を調整します。
.github/copilot-instructions.md ファイルを使用する
.github/copilot-instructions.md ファイルを使用するには:
リポジトリのルートに
.github/copilot-instructions.mdという名前のカスタム命令ファイルを作成または追加します。この機能を有効にするには、Tools>Options>GitHub>Copilot>Copilot Chatで.github/copilot-instructions.mdファイルからカスタム命令を読み込んで要求に追加することを許可するを選択します。
カスタム手順は、チャット ビューまたはインライン チャットには表示されません。 ただし、Copilot が .github/copilot-instructions.md ファイルを使用すると、応答の参照リストにファイルが一覧表示されます。
ユーザー レベルの手順を有効にする
リポジトリのカスタム手順に加えて、すべての Copilot セッションに適用されるユーザー レベルの基本設定を定義できます。 ユーザー レベルの基本設定は、 %USERPROFILE%/copilot-instructions.mdに保存されます。
リポジトリを使用していない場合でも、Copilot が従う個人のコーディング標準、優先パターン、またはワークフロー規則に対してユーザー レベルの基本設定を使用します。
.github/copilot-instructions.mdのリポジトリ レベルの手順は、ユーザー レベルの設定と共に引き続き適用されるため、Copilot は共有標準を尊重します。
copilot-instructions.md ファイルが %USERPROFILE% フォルダーに存在しない場合は、その場所に作成できます。
カスタム命令ファイル形式
カスタム命令ファイルはマークダウン ファイル (ファイル拡張子.md ) であり、定義する各セクションのメインの見出しと小見出しが含まれています。
例
# Copilot Instructions
## Persona
- I am a veteran SQL Server data professional with 20+ years of experience.
- Use a helpful, collegial tone. Keep explanations brief, but provide enough context to understand the code.
- Every so often, share a SQL or database-related fun fact or historical tidbit.
## Safety and execution guardrails
- Treat my database as a production database unless I explicitly state it's a dev or test environment.
- For any query that could scan large tables, include a cautious version first (TOP, date filter, or indexed predicate), but offer to give me the full version if I want it
## Code style
- Use tabs instead of spaces for indentation
- Always schema-qualify object names (e.g., dbo.Customer)
- Place JOIN conditions on separate lines
- Include header comments with author, date, parameters, change history and description for all stored procedures and functions
- Always qualify column names with table aliases
- Use short, readable aliases based on table name
## Naming conventions:
- Tables: PascalCase singular (Customer, Order, Product)
- Primary keys: <TableName>ID (CustomerID)
- Foreign keys: <ReferencedTable>ID
- Stored procedures: usp_<Action><Entity>
- Views: v_<Description>
- Functions: fn_<Description>