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
+4-7Lines changed: 4 additions & 7 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: 6/16/2025
4
+
ms.date: 7/31/2025
5
5
ms.topic: how-to
6
6
author: anandmeg
7
7
ms.author: meghaanand
@@ -21,9 +21,6 @@ In this article, you learn how to get better answers by providing more informati
21
21
+ Use [slash commands](#slash-commands) to quickly specify common tasks like `/explain` to get code explanations.
22
22
+ Use the [guided chat experience](#prompting-guidance) and [custom instructions](#enable-custom-instructions) to refine context.
23
23
+[Attach images](#attach-images) to your prompt to provide additional context and better illustrate your ideas.
24
-
+ Scope the chat to specific files using [references](#reference).
25
-
+ Review the [source used](#find-context) by Copilot to generate the answer.
26
-
+ Use different [threads](#threads) for each of your Copilot chats so you can maintain different contexts in each.
27
24
28
25
Learn more about [AI-assisted development in Visual Studio](../ide/ai-assisted-development-visual-studio.md) and how to [use Copilot Chat in Visual Studio](../ide/visual-studio-github-copilot-chat.md#use-copilot-chat-in-visual-studio).
29
26
@@ -32,7 +29,7 @@ Learn more about [AI-assisted development in Visual Studio](../ide/ai-assisted-d
32
29
To get started using GitHub Copilot Chat in Visual Studio, you need:
33
30
+ Visual Studio 2022 [version 17.10](/visualstudio/releases/2022/release-history) or later
34
31
+[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).
32
+
<sup>**</sup> You can sign up for[GitHub Copilot for Free](copilot-free-plan.md).
36
33
37
34
Support for GitHub Copilot Chat will be provided by GitHub and can be reached at https://support.github.com.
38
35
@@ -80,15 +77,15 @@ You can use slash commands in a [chat window](visual-studio-github-copilot-chat.
80
77
| /generate | Generate code to answer specified question. <br> Example: `/generate code to add two numbers in Calculator.cs`| Yes | Yes |
81
78
| /help | Get help on using Copilot Chat. <br> Example: `/help`| Yes | Yes |
82
79
| /optimize | Analyze and improve running time of the selected code. <br> Examples:<br> - `/optimize the AddItemToBasket method in BasketService.cs`</br>- select desired code and enter `/optimize`| Yes | Yes |
83
-
| /tests| Create unit tests for the selected code.<br> Example: select desired code and enter `/tests using XUnit Framework`| Yes | Yes |
80
+
| /tests| Create unit tests for the selected code.<br> Example: select desired code and enter `/tests using XUnit Framework`| Yes | Yes |
84
81
85
82
:::image type="content" source="media/vs-2022/copilot-chat-context/copilot-chat-context-slash-commands.png" alt-text="Screenshot of slash commands in inline chat view and chat windows.":::
86
83
87
84
With Visual Studio 2022 version 17.13, as the user types a slash command, the command expands out the prompt in natural language to display the context the command will use.
88
85
89
86
## <aname="attach-images"></a>Attach images to a chat prompt
90
87
91
-
With vision integration for Copilot Chat in Visual Studio 17.14 Preview 1 and later, you can [attach images](visual-studio-github-copilot-chat.md#attach-images-to-chat-prompts) to your chat prompt, providing Copilot with additional context for improved responses. Use images in combination with [scope](#reference) and other contextual features such as slash commands to generate tailored responses.
88
+
With vision integration for Copilot Chat in Visual Studio 17.14 and later, you can [attach images](visual-studio-github-copilot-chat.md#attach-images-to-chat-prompts) to your chat prompt, providing Copilot with additional context for improved responses. Use images in combination with [scope](copilot-chat-referencing-context.md#reference-context) and other contextual features such as slash commands to generate tailored responses.
92
89
93
90
In the following example, Copilot interprets the attached image to generate a plan and suggest code to create a colorful Breakout game from scratch.
Copy file name to clipboardExpand all lines: docs/ide/copilot-chat-referencing-context.md
+11-3Lines changed: 11 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -30,13 +30,13 @@ Visual Studio automatically provides context to the chat prompt based on your cu
30
30
31
31
The following information is implicitly included in the chat context:
32
32
- The currently selected text in the active editor.
33
-
- The file name or notebook name of the active editor.
33
+
- The current file active in the editor.
34
34
35
-
The actual contents of the active file are not included in the context, but are shown as a suggested context item in the chat input box (indicated with italic text and a dotted outline). Depending on your prompt, Visual Studio might decide to read the contents of the active file. To explicitly include the contents of the active file in the chat context, select the suggested file in the chat input box.
35
+
Depending on your prompt, Copilot reads the contents of the active file. To explicitly include the contents of another file in the chat context, select the suggested file using the `+` button in the chat view to **Add attachment**.
36
36
37
37
:::image type="content" source="media/vs-2022/copilot-chat-context/copilot-chat-implicit-context.png" alt-text="Screenshot of implicit context in Copilot Chat.":::
You can ask your coding related questions in natural language and GitHub Copilot Chat will answer these in the context of the codebase open in Visual Studio. With references you can get more specific about the information you want Copilot to consider when answering your question.
42
42
@@ -68,6 +68,14 @@ With Visual Studio 2022 version 17.11, [GitHub Copilot Enterprise](https://docs.
68
68
69
69
:::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.":::
70
70
71
+
## <aname="attach-images"></a>Reference an image
72
+
73
+
With vision integration for Copilot Chat in Visual Studio 17.14 and later, you can [attach images](visual-studio-github-copilot-chat.md#attach-images-to-chat-prompts) to your chat prompt, providing Copilot with additional context for improved responses. Use images in combination with [scope](#reference-context) and other contextual features such as [slash commands](copilot-chat-context.md#slash-commands) to generate tailored responses.
74
+
75
+
In the following example, Copilot interprets the attached image to generate a plan and suggest code to create a colorful Breakout game from scratch.
76
+
77
+
:::image type="content" source="media/vs-2022/visual-studio-github-copilot-chat/example-attach-image-chat.png" alt-text="Screenshot of an example scenario of adding an image in Copilot Chat." lightbox="media/vs-2022/visual-studio-github-copilot-chat/example-attach-image-chat.png" :::
78
+
71
79
### Reference output window
72
80
73
81
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.
0 commit comments