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
Enhance module on configuring GitHub Copilot by adding prompt files, refining agent capabilities, and improving instructional clarity across multiple documents.
Copy file name to clipboardExpand all lines: learn-pr/wwl-azure/configure-customize-github-copilot-visual-studio-code/7-knowledge-check.yml
+22Lines changed: 22 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -78,3 +78,25 @@ quiz:
78
78
- content: "The handoff is disabled and the agent cannot transition to the target agent."
79
79
isCorrect: false
80
80
explanation: "Incorrect. The `send: false` setting doesn't disable the handoff. It simply requires the developer to manually submit the pre-filled prompt rather than having it sent automatically."
81
+
- content: "What is the purpose of a `.prompt.md` file in the `.github/prompts/` folder?"
82
+
choices:
83
+
- content: "It defines a custom agent persona with specific tool permissions."
84
+
isCorrect: false
85
+
explanation: "Incorrect. Custom agent personas are defined in `.agent.md` files, not `.prompt.md` files."
86
+
- content: "It provides a reusable prompt template that can be invoked as a slash command in Copilot Chat to run a common task consistently."
87
+
isCorrect: true
88
+
explanation: "Correct. Prompt files (`.prompt.md`) are reusable prompt templates with optional YAML frontmatter and variable placeholders. Once created, they appear as slash commands in Copilot Chat, allowing the team to standardize common tasks like generating tests or producing documentation."
89
+
- content: "It configures which AI model Copilot uses for all chat interactions in the workspace."
90
+
isCorrect: false
91
+
explanation: "Incorrect. Prompt files define reusable prompt templates, not model configuration. Model preferences can be set per-agent or per-prompt using the `model` frontmatter field."
92
+
- content: "How do subagents differ from handoffs in custom agent workflows?"
93
+
choices:
94
+
- content: "Subagents and handoffs are different names for the same feature."
95
+
isCorrect: false
96
+
explanation: "Incorrect. Subagents and handoffs are distinct mechanisms. Subagents are invoked programmatically within an agent's response, while handoffs transfer control to the user to approve a transition."
97
+
- content: "Subagents are invoked automatically within an agent's processing and return results to the calling agent, while handoffs transfer control to the user to approve a transition to another agent."
98
+
isCorrect: true
99
+
explanation: "Correct. Subagents are called programmatically by the parent agent during its response processing—the result flows back to the calling agent automatically. Handoffs, by contrast, present a button to the user who decides whether to transition to the next agent."
100
+
- content: "Subagents can only run in the cloud, while handoffs run locally in VS Code."
101
+
isCorrect: false
102
+
explanation: "Incorrect. Both subagents and handoffs can run in either the client or the cloud, depending on the agent's `target` configuration."
Copy file name to clipboardExpand all lines: learn-pr/wwl-azure/configure-customize-github-copilot-visual-studio-code/includes/2-examine-benefits-customize-github-copilot.md
+5-1Lines changed: 5 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,12 +4,16 @@ GitHub Copilot provides helpful code suggestions and chat responses right away,
4
4
5
5
Out-of-the-box, Copilot generates suggestions based on its general training data and the immediate code context. While this produces useful results for many common tasks, it can miss project-specific nuances. For example, your team might enforce specific architectural patterns like the repository pattern for data access, require particular naming conventions such as prefixing private fields with an underscore, or follow security practices that mandate input validation on every API endpoint. Without customization, Copilot doesn't know about these requirements and may generate code that needs significant manual editing to meet your standards.
6
6
7
-
Customization addresses this challenge through two complementary approaches:
7
+
Customization addresses this challenge through several complementary approaches:
8
8
9
9
-**Custom instruction files**: Markdown files stored in your repository that provide Copilot with always-on guidelines. These files describe your coding standards, preferred libraries, naming conventions, and other project-specific rules. Copilot reads these instructions and incorporates them into every chat response, producing suggestions that are aligned with your team's expectations from the start.
10
10
11
+
-**Prompt files**: Reusable prompt templates (`.prompt.md` files) that you can invoke as slash commands in Copilot Chat. While instruction files shape how Copilot responds, prompt files define what to ask—standardizing common tasks like generating tests, creating documentation, or performing code reviews so they run consistently across your team.
12
+
11
13
-**Custom agents**: Specialized AI personas that you define for particular development roles. Each agent has its own set of instructions, tool permissions, and behavioral guidelines. For instance, a "Planner" agent can focus on analyzing requirements and producing implementation plans without editing code, while an "Implementer" agent can focus on writing code that follows your project's guidelines. Agents give you fine-grained control over how Copilot behaves in different stages of your workflow.
12
14
15
+
-**Agent skills**: Structured descriptions of specific capabilities or expertise areas (defined in `SKILL.md` files) that agents can draw on to provide specialized knowledge. Skills complement agent instructions by exposing metadata about what an agent knows and can do.
16
+
13
17
Together, these features allow you to guide Copilot toward producing output that matches your team's conventions, reducing the editing overhead and improving consistency across your codebase.
Copy file name to clipboardExpand all lines: learn-pr/wwl-azure/configure-customize-github-copilot-visual-studio-code/includes/3-customize-copilot-responses-instruction-files.md
+83-4Lines changed: 83 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,8 +8,11 @@ For example, if your `.github/copilot-instructions.md` file specifies "Use Pasca
8
8
9
9
The instructions are written in natural language using Markdown formatting. Each guideline can be its own bullet point or paragraph. Whitespace between instructions is ignored when sent to the model, so you can format the file for readability without affecting how Copilot processes it.
10
10
11
+
> [!TIP]
12
+
> You can use the `/init` slash command in Copilot Chat to automatically generate a `copilot-instructions.md` file for your project. Copilot analyzes your workspace and produces a starter instruction file tailored to your project's language, framework, and structure.
13
+
11
14
> [!NOTE]
12
-
> VS Code also supports `AGENTS.md` files as always-on instructions. An `AGENTS.md` file placed in the root of your workspace works similarly to `copilot-instructions.md` and is useful when you work with multiple AI agents and want a single set of instructions recognized by all of them.
15
+
> VS Code also supports `AGENTS.md`and `CLAUDE.md`files as always-on instructions. An `AGENTS.md` file placed in the root of your workspace works similarly to `copilot-instructions.md` and is useful when you work with multiple AI agents and want a single set of instructions recognized by all of them. `CLAUDE.md` files follow the same pattern and are recognized by Copilot in VS Code. Additionally, nested `AGENTS.md` files can be placed in subdirectories to provide context-specific instructions that apply only when Copilot operates on files within that directory or its children.
13
16
14
17
## Path-specific instructions
15
18
@@ -32,7 +35,13 @@ applyTo: 'src/Backend/**/*.cs'
32
35
- Include XML documentation comments on all public methods.
33
36
```
34
37
35
-
The `applyTo` field accepts glob patterns. Common patterns include `**/*.cs` to match all C# files, `src/Frontend/**/*.ts` to match TypeScript files in a specific directory, or `**/Tests/**/*.cs` to match test files across the project. When a file's path matches an `applyTo` pattern, Copilot automatically includes those instructions alongside the general repository instructions.
38
+
The YAML frontmatter supports the following fields:
39
+
40
+
-**applyTo**: A glob pattern that determines which files trigger the instructions. Common patterns include `**/*.cs` to match all C# files, `src/Frontend/**/*.ts` to match TypeScript files in a specific directory, or `**/Tests/**/*.cs` to match test files across the project. When a file's path matches an `applyTo` pattern, Copilot automatically includes those instructions alongside the general repository instructions.
41
+
42
+
-**description**: A natural language description of what the instructions cover. Copilot uses this field for semantic matching—when you ask a question in chat, Copilot evaluates the description to determine whether the instructions are relevant to the current context, even if no file matching the `applyTo` pattern is open. For example, a description of "Guidelines for database migration scripts" helps Copilot include those instructions when you ask about database migrations.
43
+
44
+
-**name**: A display name for the instruction set that appears in the Chat Instructions menu and diagnostics view.
36
45
37
46
## Organization-level instructions
38
47
@@ -41,7 +50,14 @@ For enterprises that maintain coding standards across multiple repositories, Git
41
50
In Visual Studio Code, organization-level instructions are automatically detected when you're signed in to a GitHub account that has access to an organization with custom instructions configured. These instructions appear alongside your personal and workspace instructions in the Chat Instructions menu.
42
51
43
52
> [!NOTE]
44
-
> Personal instructions take the highest priority, followed by repository instructions, and then organization instructions. When multiple types of custom instructions exist, they're all provided to the AI, but higher-priority instructions take precedence when conflicts occur.
53
+
> When multiple types of custom instructions exist, Copilot includes all of them but follows a priority order when resolving conflicts. The full instruction priority chain, from highest to lowest, is:
54
+
> 1. Instructions entered manually in the Chat Instructions menu or pinned to the conversation.
> 1. Organization-level instructions configured by a GitHub organization administrator.
59
+
>
60
+
> Higher-priority instructions take precedence when conflicts occur.
45
61
46
62
## How to create instruction files
47
63
@@ -95,6 +111,69 @@ Repository-level instructions align AI output with team conventions and reduce t
95
111
96
112
Path-specific instructions allow for even more targeted guidance. Different rules can apply to frontend versus backend code, test files versus production code, or specific modules with unique requirements. This granularity ensures that suggestions are relevant to the specific area of the codebase the developer is working in.
97
113
114
+
## Tips for writing effective instructions
115
+
116
+
Well-crafted instructions produce significantly better results. Here are tips for getting the most out of custom instruction files:
117
+
118
+
-**Explain the reasoning behind rules**. Instead of just "prefix private fields with `_`," write "Prefix private fields with `_` to distinguish them from parameters and local variables at a glance." When Copilot understands why a rule exists, it applies the rule more consistently and can extend the principle to similar situations.
119
+
120
+
-**Include short code examples**. Pair guidelines with brief code snippets showing the expected pattern. For instance, follow "Use the factory pattern for complex object creation" with a two-line example. Concrete examples reduce ambiguity.
121
+
122
+
-**Focus on non-obvious rules**. Don't repeat what linters and formatters already enforce. Instead, document the conventions that only your team knows—like which libraries to prefer, which patterns to follow for error handling, or which architectural boundaries exist between modules.
123
+
124
+
-**Keep instructions concise and specific**. Overly long or vague instruction files dilute Copilot's attention. Each instruction should express one clear rule. Remove instructions that overlap or contradict each other.
125
+
126
+
-**Separate concerns using path-specific files**. Use `.instructions.md` files with `applyTo` patterns to keep backend and frontend rules separate, test logic distinct from production code, and infrastructure scripts isolated from application code.
127
+
128
+
## Prompt files
129
+
130
+
In addition to instruction files that provide always-on context, Visual Studio Code supports **prompt files**—reusable prompt templates stored as `.prompt.md` files that you can invoke as slash commands in Copilot Chat.
131
+
132
+
While instruction files shape how Copilot responds, prompt files define what to ask. A prompt file contains a pre-written prompt—with optional variable placeholders—that you can run on demand to execute a common task consistently. For example, you might create a prompt file that generates a code review checklist, creates a unit test for the current file, or produces API documentation in a specific format.
133
+
134
+
### How prompt files work
135
+
136
+
Prompt files use the `.prompt.md` extension and can be stored in the `.github/prompts/` folder of your workspace (shared with your team through version control) or in your VS Code user profile (personal, available across all workspaces). Each file contains an optional YAML frontmatter header and a Markdown body with the prompt text.
137
+
138
+
The following example shows a prompt file that generates unit tests:
139
+
140
+
```markdown
141
+
---
142
+
description: 'Generate unit tests for the current file'
143
+
agent: 'copilot'
144
+
tools: ['search', 'read']
145
+
---
146
+
# Generate Unit Tests
147
+
148
+
Analyze the code in the active file and generate comprehensive unit tests.
149
+
150
+
For each public method or function:
151
+
1. Write a test for the expected behavior (happy path).
152
+
2. Write tests for edge cases and error conditions.
153
+
3. Use the project's existing test framework and naming conventions.
154
+
155
+
Output the tests as a complete, runnable test file.
156
+
```
157
+
158
+
The YAML frontmatter for prompt files supports these fields:
159
+
160
+
| Field | Description |
161
+
|---|---|
162
+
|`description`| A natural language description of what the prompt does. Appears in the slash command picker. |
163
+
|`name`| An optional display name. If omitted, the filename is used. |
164
+
|`agent`| The agent that should handle the prompt (for example, `copilot`). |
165
+
|`model`| An optional model preference for this prompt. |
166
+
|`tools`| Tools the prompt should have access to when executed. |
167
+
168
+
### Using prompt files
169
+
170
+
Once created, prompt files appear as slash commands in the Copilot Chat input. Type `/` followed by the prompt file's name (without the `.prompt.md` extension) to select and run it. For example, a file named `generate-tests.prompt.md` becomes the `/generate-tests` command.
171
+
172
+
Prompt files support variable placeholders using the `${variable}` syntax. The variable `${file}` refers to the currently active file, and `${selection}` refers to the current text selection. You can also define custom variables that prompt the user for input when the prompt file is executed.
173
+
174
+
> [!NOTE]
175
+
> To enable prompt files, verify that the `chat.promptFiles` setting is turned on in VS Code. When enabled, your `.prompt.md` files are automatically detected and registered as available slash commands.
176
+
98
177
## Limitations
99
178
100
179
Custom instruction files have a few important limitations to keep in mind:
@@ -107,4 +186,4 @@ Custom instruction files have a few important limitations to keep in mind:
107
186
108
187
## Summary
109
188
110
-
Custom instruction files provide a structured way to guide Copilot's behavior at the repository, path, and organization levels. By creating a `.github/copilot-instructions.md` file for project-wide standards and optional `.instructions.md` files for path-specific rules, you can align AI-generated suggestions with your team's coding conventions. This reduces manual corrections, improves code consistency, and embeds your team's knowledge directly into the development workflow.
189
+
Custom instruction files and prompt files provide a structured way to guide Copilot's behavior at the repository, path, and organization levels. By creating a `.github/copilot-instructions.md` file for project-wide standards, optional `.instructions.md` files for path-specific rules, and `.prompt.md` files for reusable prompt templates, you can align AI-generated suggestions with your team's coding conventions. Writing effective instructions—with reasoning, examples, and focused scope—maximizes the value of these customization features. Together, these tools reduce manual corrections, improve code consistency, and embed your team's knowledge directly into the development workflow.
0 commit comments