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/ide/copilot-chat-context.md
+34-9Lines changed: 34 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
---
2
2
title: 'Tips & Tricks for GitHub Copilot Chat in Visual Studio'
3
3
description: Use slash commands, references, and threads to form better questions and get better answers with scoped context in GitHub Copilot Chat.
4
-
ms.date: 2/26/2025
4
+
ms.date: 6/16/2025
5
5
ms.topic: how-to
6
6
author: anandmeg
7
7
ms.author: meghaanand
@@ -15,12 +15,12 @@ monikerRange: '>= vs-2022'
15
15
---
16
16
# Get better answers by setting the context for GitHub Copilot Chat in Visual Studio
17
17
18
-
You can use[**GitHub Copilot Chat**](visual-studio-github-copilot-chat.md)in Visual Studio to get coding information and support, such as syntax, programming concepts, context-specific code help, test cases, debugging, and more, without leaving the IDE. Copilot Chat is integrated into Visual Studio, which means it can understand what you're working on by gathering useful clues from what you have in the IDE.
18
+
You can ask[**GitHub Copilot Chat**](visual-studio-github-copilot-chat.md) to give you code suggestions, explain code, generate unit tests, and suggest code fixes. In addition to your prompt, Copilot uses additional context, like the code in your current file and the chat history, to generate a response.
19
19
20
-
In addition to your prompt, Copilot uses additional context, like the code in your current file and the chat history, to generate a response. In this article, you learn how to get better answers by providing more information to Copilot Chat including:
20
+
In this article, you learn how to get better answers by providing more information to Copilot Chat:
21
21
+ Use [slash commands](#slash-commands) to quickly specify common tasks like `/explain` to get code explanations.
22
-
+ Use the [guided chat experience](#prompting-guidance) and [custom instructions](#enable-custom-instructions) to refine context in Visual Studio 17.12 or later.
23
-
+[Attach images](#attach-images) to your prompt to provide additional context and better illustrate your ideas in Visual Studio 17.14 Preview 1 or later.
22
+
+ Use the [guided chat experience](#prompting-guidance) and [custom instructions](#enable-custom-instructions) to refine context.
23
+
+[Attach images](#attach-images) to your prompt to provide additional context and better illustrate your ideas.
24
24
+ Scope the chat to specific files using [references](#reference).
25
25
+ Review the [source used](#find-context) by Copilot to generate the answer.
26
26
+ Use different [threads](#threads) for each of your Copilot chats so you can maintain different contexts in each.
@@ -30,11 +30,9 @@ Learn more about [AI-assisted development in Visual Studio](../ide/ai-assisted-d
30
30
## Prerequisites
31
31
32
32
To get started using GitHub Copilot Chat in Visual Studio, you need:
33
-
+ Visual Studio 2022 [version 17.8](/visualstudio/releases/2022/release-history) or later
33
+
+ Visual Studio 2022 [version 17.10](/visualstudio/releases/2022/release-history) or later
34
34
+[Sign in to Visual Studio using a GitHub account](work-with-github-accounts.md) with [Copilot access](https://docs.github.com/en/copilot/about-github-copilot/what-is-github-copilot#getting-access-to-copilot) <br/>
35
-
<sup>**</sup> You can use [GitHub Copilot for Free](copilot-free-plan.md). Sign up and leverage AI to code faster and more efficiently.
36
-
+[GitHub Copilot](visual-studio-github-copilot-install-and-states.md) in Visual Studio
37
-
+[GitHub Copilot Chat](visual-studio-github-copilot-chat.md#get-github-copilot-chat-for-visual-studio) in Visual Studio
35
+
<sup>**</sup> You can use [GitHub Copilot for Free](copilot-free-plan.md).
38
36
39
37
Support for GitHub Copilot Chat will be provided by GitHub and can be reached at https://support.github.com.
40
38
@@ -54,6 +52,20 @@ To configure custom instructions:
54
52
55
53
Custom instructions are not visible in the Chat view or inline chat. However, when used by Copilot, the`.github/copilot-instructions.md` file is listed in the References list of a response.
56
54
55
+
## Use prompt files
56
+
57
+
You can now create reusable prompt files in your repository to run or share your frequently used prompts.
58
+
59
+
To create a prompt file:
60
+
1. Write your prompts as you normally would in the prompt box, using `#` references to include specific information from your solution, such as methods, classes, and files. You can even reference other prompt files for shared instructions.
61
+
1. Copy the prompt into a markdown file, and save it with the `.prompt.md` extension in the `.github/prompts` folder at the root of your repository.
62
+
63
+
To use a prompt file:
64
+
1. Type `#prompt:` in chat input to reference any prompt files from your `.github/prompts` folder, or click the ➕ icon in the chat input to add it as context.
65
+
1. Add any extra details, or simply enter the prompt as is.
66
+
67
+
:::image type="content" source="media/vs-2022/copilot-chat-context/prompt-files.png" alt-text="Screenshot of using prompt files in GitHub Copilot Chat.":::
68
+
57
69
## <aname="slash-commands"></a>Use slash commands in Copilot Chat for common tasks
58
70
59
71
Slash commands in Copilot Chat help you set the intent quickly for common development tasks. By using specific slash commands to form your question, you can get better answers without having to write out long questions.
@@ -112,6 +124,19 @@ With Visual Studio 2022 version 17.11, [GitHub Copilot Enterprise](https://docs.
112
124
113
125
:::image type="content" source="media/vs-2022/copilot-chat-context/copilot-chat-context-at-github.png" alt-text="Screenshot of using GitHub skills in Copilot Chat.":::
114
126
127
+
### Reference output window
128
+
129
+
You can now use the output window as context in chat to ask questions and get help with output logs. Supported output windows include Build, Debug, Tests, Source Control, Package Manager, or any other active output window pane.
130
+
131
+
Reference output logs in chat in one of the following ways:
132
+
133
+
- Use *#output* to reference it directly in chat.
134
+
- Select the ➕ icon in the chat input and add `Output logs` as context.
135
+
- Ask Copilot directly, for example, *Check my output logs and help me fix this error*.
136
+
- Right-click in the **Output Window** and select **Explain with Copilot** to attach it.
137
+
138
+
:::image type="content" source="media/vs-2022/copilot-chat-context/copilot-chat-context-output-window.png" alt-text="Screenshot of output window as context in Copilot Chat.":::
139
+
115
140
### Usage examples
116
141
Here are some examples of using references for context control:
0 commit comments