You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/copilot/copilot-customization.md
+40-33Lines changed: 40 additions & 33 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,16 +4,14 @@ DateApproved: 04/03/2025
4
4
MetaDescription: Learn how to customize GitHub Copilot Chat with custom instructions and reusable prompt files to align AI responses with your coding practices and project requirements.
# Customize chat with instructions and prompt files
7
+
# Customize chat responses in VS Code
8
8
9
-
Customize chat responses to align with your coding practices and project requirements. This article explains two powerful customization approaches: custom instructions that apply guidelines to all your chat interactions, and prompt files that let you create, store, and share reusable AI prompts for specific tasks like generating components, reviewing code, or creating documentation.
10
-
11
-
[*Custom instructions*](#custom-instructions) enable you to describe common guidelines or rules to get responses that match your specific coding practices and tech stack. Instead of manually including this context in every chat query, custom instructions automatically incorporate this information with every chat request. VS Code supports custom instructions for different scenarios, such as code generation, commit-message generation, code reviewing, and more.
12
-
13
-
[*Prompt files*](#reusable-prompt-files-experimental) allow you to craft complete prompts in Markdown files, which you can then reference in chat. Unlike custom instructions that supplement your existing prompts, prompt files are standalone prompts that you can store within your workspace and share with others. With prompt files, you can create reusable templates for common tasks, store domain expertise in your codebase, and standardize AI interactions across your team.
9
+
Copilot can provide you with responses that match your coding practices and project requirements if you give it the right context. Custom instructions enable you to define and automatically apply the guidelines and rules for tasks like generating code, or performing code reviews. Prompt files let you craft complete chat prompts in Markdown files, which you can then reference in chat or share with others. In this article, you will learn how to use custom instructions and prompt files to customize your chat responses in Visual Studio Code.
14
10
15
11
## Custom instructions
16
12
13
+
Custom instructions enable you to describe common guidelines or rules to get responses that match your specific coding practices and tech stack. Instead of manually including this context in every chat query, custom instructions automatically incorporate this information with every chat request.
14
+
17
15
VS Code supports several types of custom instructions, targeted at different scenarios: code generation, test generation, code review, commit message generation, and pull request title and description generation instructions.
18
16
19
17
You can define custom instructions in two ways:
@@ -123,9 +121,17 @@ The following code snippet shows how to define a set of instructions in the `set
123
121
124
122
## Reusable prompt files (experimental)
125
123
126
-
Prompt files (_prompts_) let you build and share reusable prompt instructions with extra context. A prompt file is a Markdown file that mimics the existing format of writing prompts in Copilot Chat (for example, `Rewrite #file:x.ts`). This allows blending natural language instructions, additional context, and even linking to other prompt files as dependencies.
124
+
Prompt files allow you to craft complete prompts in Markdown files, which you can then reference in chat. Unlike custom instructions that supplement your existing prompts, prompt files are standalone prompts that you can store within your workspace and share with others. With prompt files, you can create reusable templates for common tasks, store domain expertise in your codebase, and standardize AI interactions across your team.
127
125
128
-
While custom instructions help to add codebase-wide context to each AI workflow, prompt files let you add instructions to a specific chat interaction.
126
+
A prompt file is a Markdown file that mimics the existing format of writing prompts in chat (for example, `Rewrite #file:x.ts`). This allows blending natural language instructions, additional context, and even linking to other prompt files as dependencies.
127
+
128
+
> [!TIP]
129
+
> Reference additional context files like API specs or documentation by using Markdown links to provide Copilot with more complete information.
130
+
131
+
VS Code supports two types of prompts:
132
+
133
+
***Workspace prompt files**: stored in a Markdown file within your workspace and only available in that workspace.
134
+
***User prompt files**: stored in a Markdown file in your profile folder and available for use across multiple workspaces.
129
135
130
136
Common use cases include:
131
137
@@ -136,7 +142,7 @@ Common use cases include:
136
142
137
143
### Prompt file examples
138
144
139
-
*`react-form.prompt.md` - documents a reusable task for generating a form:
145
+
*Document a reusable task for generating a form:
140
146
141
147
```markdown
142
148
Your goal is to generate a new React form component.
@@ -155,7 +161,7 @@ Common use cases include:
155
161
* Customize UX-friendly validation rules
156
162
```
157
163
158
-
* `security-api.prompt.md` - documents reusable security practices for REST APIs, which can be used to do security reviews of REST APIs:
164
+
* Document reusable security practices for REST APIs, which can be used to do security reviews of REST APIs:
159
165
160
166
```markdown
161
167
Secure REST API review:
@@ -166,58 +172,60 @@ Common use cases include:
166
172
…
167
173
```
168
174
169
-
### Usage
175
+
### Create a workspace prompt file
170
176
171
-
To enable prompt files, configure the `setting(chat.promptFiles)` VS Code setting. By default, prompt files are located in the `.github/prompts` directory of your workspace. You can also [specify additional folders](#prompt-files-experimental-settings) where prompt files are located.
177
+
Workspace prompt files are stored in your workspace and are only available in that workspace. Workspace prompt files are stored in the `.github/prompts` directory of your workspace.
172
178
173
-
#### Create a prompt file
179
+
To create a workspace prompt file:
174
180
175
181
1. Set the `setting(chat.promptFiles)` setting to `true` for the `.github/prompts` directory.
176
182
177
183
1. Create a `.prompt.md` file in the `.github/prompts` directory of your workspace.
178
184
179
-
Alternatively, use the **Create Prompt** command from the Command Palette (`kb(workbench.action.showCommands)`).
185
+
By default, prompt files are located in the `.github/prompts` directory of your workspace. You can specify additional prompt file locations with the `setting(chat.promptFilesLocations)` setting.
186
+
187
+
Alternatively, use the **Chat: Create Prompt** command from the Command Palette (`kb(workbench.action.showCommands)`) to create a prompt.
180
188
181
-
1. Write prompt instructions by using Markdown formatting.
189
+
1. Author the chat prompt by using Markdown formatting.
182
190
183
191
Within a prompt file, reference additional workspace files as Markdown links (`[index](../index.ts)`), or as `#file:../index.ts` references within the prompt file.
184
192
185
193
You can also reference other `.prompt.md` files to create a hierarchy of prompts, with reusable prompts that can be shared across multiple prompt files.
186
194
187
-
#### Create a user prompt file
195
+
### Create a user prompt file
188
196
189
197
User prompt files are stored in your [user profile](/docs/configure/profiles.md). With user prompt files, you can share reusable prompts across multiple workspaces.
190
198
191
-
You can add a user prompt file to a chat prompt in the same way as a workspace prompt file.
192
-
193
199
To create a user prompt file:
194
200
195
-
1. Select the **Create User Prompt** command from the Command Palette (`kb(workbench.action.showCommands)`).
201
+
1. Select the **Chat: Create User Prompt** command from the Command Palette (`kb(workbench.action.showCommands)`).
196
202
197
203
1. Enter a name for your prompt file.
198
204
199
-
1. Write prompt instructions by using Markdown formatting.
205
+
1. Author the chat prompt by using Markdown formatting.
200
206
201
-
User prompt files can now be synced across multiple devices with [Settings Sync](/docs/configure/settings-sync.md). Make sure to enable support for prompt files in your Settings Sync configuration. Select **Settings Sync: Configure** from the Command Palette, and make sure **Prompts** is selected.
207
+
You can also reference other `.prompt.md` user prompt files to create a hierarchy of prompts, with reusable prompts that can be shared across multiple prompt files.
202
208
203
-
#### Attach a prompt file to a chat request
209
+
> [!TIP]
210
+
> User prompt files can be synced across multiple devices with [Settings Sync](/docs/configure/settings-sync.md). Make sure to enable support for prompt files in your Settings Sync configuration. Select **Settings Sync: Configure** from the Command Palette, and make sure **Prompts** is selected.
204
211
205
-
1. Select the **Attach Context** <i class="codicon codicon-attach"></i> icon (`kb(workbench.action.chat.attachContext)`), and then select **Prompt...**.
212
+
### Use a prompt file in chat
206
213
207
-
Alternatively, use the **Chat: Use Prompt** command from the Command Palette (`kb(workbench.action.showCommands)`).
214
+
To use a prompt file as a chat prompt, attach it to your chat request as context:
208
215
209
-
1. Choose a prompt file from the Quick Pick to attach it to your chat request.
216
+
1. Open the Chat view in VS Code (`kb(workbench.action.chat.open)`).
210
217
211
-
You can use prompt files in both Copilot Chat and Copilot Edits.
218
+
1. Select **Attach Context** in the chat input field, and then select **Prompt...**.
212
219
213
-
1. Optionally, attach additional context files required for the task.
220
+
Alternatively, use the **Chat: Use Prompt** command from the Command Palette (`kb(workbench.action.showCommands)`).
214
221
215
-
For reusable tasks, send the prompt without any additional instructions.
222
+
1. Choose a prompt file from the Quick Pick to attach it to your chat request.
216
223
217
-
To further refine a reusable prompt, include additional instructions to provide more context for the task at hand.
224
+
You can use prompt files in any of the chat modes (ask, edit, or agent mode).
218
225
219
-
> [!TIP]
220
-
> Reference additional context files like API specs or documentation by using Markdown links to provide Copilot with more complete information.
226
+
1. Optionally, attach additional context files required for the task or include more instructions in the chat prompt.
227
+
228
+
To use the prompt file as-is, send the chat prompt without any additional instructions.
221
229
222
230
## Settings
223
231
@@ -242,5 +250,4 @@ User prompt files can now be synced across multiple devices with [Settings Sync]
242
250
243
251
## Related content
244
252
245
-
* Start AI chat conversations with [Copilot Chat](/docs/copilot/chat/copilot-chat.md).
246
-
* Start an AI-powered editing session with [Copilot Edits](/docs/copilot/chat/copilot-edits.md).
253
+
* [Get started with chat in VS Code](/docs/copilot/chat/copilot-chat.md)
0 commit comments