I talked about custom instructions before as a way to tweak the Copilot prompt when interacting with GitHub Copilot. At that time it was rather limited and you had not much control on how it was applied.
The way it was handled was through a custom Markdown copilot-instructions.md
file. This feature has further evolved and now you can specify instructions for multiple purposes:
-
Code-generation instructions - provide context specific for generating code. You can specify those instructions directly in the settings, or in a Markdown file in your workspace.
-
Test-generation instructions - provide context specific for generating tests. You can specify those instructions directly in the settings, or in a Markdown file your workspace.
-
Code review instructions - provide context specific for reviewing the current editor selection. You can specify those instructions directly in the settings, or in a Markdown file in your workspace.
-
Commit message generation instructions - provide context specific for generating commit messages. You can specify those instructions directly in the settings, or in a Markdown file in your workspace.
Configure a specific set of instructions
-
Open the Command Palette: Press
Ctrl+Shift+P
(Windows/Linux) orCmd+Shift+P
(macOS) to open the Command Palette. -
Open Settings (JSON): Type
Preferences: Open Settings (JSON)
and select it from the list.
-
Edit the settings.jsonfile: This will open the
settings.json
file where you can add or modify settings.Now we can add for example a code-generation instruction:
-
Save the file: After making your changes, save the
settings.json
file.
Here are the different settings that can be used:
Instruction | Setting |
Code-generation instructions |
|
Test-generation instructions |
|
Code review instructions |
|
Commit message instructions |
|
Remark: If you define custom instructions in both the .github/copilot-instructions.md
file and in settings, Copilot tries to combine instructions from both sources.