Skip to main content

Poser des questions à GitHub Copilot dans votre IDE

Utilisez Copilot Chat dans votre éditeur pour fournir des suggestions de code, expliquer le code, générer des tests unitaires et suggérer des correctifs de code.

Prerequisites

If you have access to GitHub Copilot via your organization or enterprise, you won't be able to use GitHub Copilot Chat if your organization owner or enterprise administrator has disabled chat. See Managing policies for Copilot in your organization.

Submitting prompts

You can ask Copilot Chat to give code suggestions, explain code, generate unit tests, and suggest code fixes.

  1. In the Visual Studio menu bar, click View, then click GitHub Copilot Chat.

  2. In the Copilot Chat window, enter a prompt, then press Enter. For example prompts, see Getting started with prompts for Copilot Chat.

  3. Evaluate Copilot's response, and submit a follow up prompt if needed.

    The response often includes interactive elements. For example, the response may include buttons to copy, insert, or preview the result of a code block.

    To see the files that Copilot Chat used to generate the response, click the References link below the response. The references may include a link to a custom instructions file for your repository. This file contains additional information that is automatically added to all of your chat questions to improve the quality of the responses. For more information, see Adding repository custom instructions for GitHub Copilot.

Using keywords in your prompt

You can use special keywords to help Copilot understand your prompt.

Extending Copilot Chat

GitHub Copilot Extensions integrate the power of external tools into Copilot Chat, helping you reduce context switching and receive responses with domain-specific context. You can install Copilot Extensions from the GitHub Marketplace or build private ones within your organization, then type @ in a chat window to see a list of your available extensions. To use an extension, select the extension from the list or type the full slug name, then type your prompt.

To learn more, see Using extensions to integrate external tools with Copilot Chat.

Slash commands

Use slash commands to avoid writing complex prompts for common scenarios. To use a slash command, type / in the chat prompt box, followed by a command.

To see all available slash commands, type / in the chat prompt box. See also GitHub Copilot Chat cheat sheet or Slash commands in the Visual Studio documentation.

References

By default, Copilot Chat will reference the file that you have open or the code that you have selected. You can also use # followed by a file name, file name and line numbers, or solution to reference a specific file, lines, or solution.

See also GitHub Copilot Chat cheat sheet or Reference in the Visual Studio documentation.

Using GitHub skills for Copilot (preview)

Note

The @github chat participant is currently in preview, and only available in Visual Studio 2022 Preview 2 onwards.

Copilot's GitHub-specific skills expand the type of information Copilot can provide. To access these skills in Copilot Chat in Visual Studio, include @github in your question.

When you add @github to a question, Copilot dynamically selects an appropriate skill, based on the content of your question. You can also explicitly ask Copilot Chat to use a particular skill. For example, @github Search the web to find the latest GPT4 model from OpenAI.

You can generate a list of currently available skills by asking Copilot: @github What skills are available?

Asking a question about a knowledge base (preview)

Note

  • This feature is only available if you have a Copilot Enterprise subscription.
  • Support for knowledge bases is currently in preview, and only available in Visual Studio 2022 Preview 3 onwards.

Organization owners can create knowledge bases, grouping together Markdown documentation across one or more repositories. For more information, see Managing Copilot knowledge bases.

You can tell Copilot to answer a question within the context of a knowledge base.

  1. At the bottom of the Copilot Chat window, in the Ask Copilot: Type / for commands and # to reference text box, type @github, press #, then select a knowledge base from the list.
  2. In the Type / for commands and # to reference text box, continue your message with your question, and then press Enter.
  3. Copilot Chat will process your question and provide an answer, with citations from your knowledge base, in the chat window.

AI models for Copilot Chat

You can change the large language model that Copilot uses to generate responses to chat prompts. You may find that different models perform better, or provide more useful responses, depending on the type of questions you ask. For more information see Changing the AI model for Copilot Chat.

Additional ways to access Copilot Chat

In addition to submitting prompts through the chat window, you can submit prompts inline. To start an inline chat, right click in your editor window and select Ask Copilot.

See Ask questions in the inline chat view in the Visual Studio documentation for more details.

Sharing feedback

To share feedback about Copilot Chat, you can use the Send feedback button in Visual Studio. For more information on providing feedback for Visual Studio, see the Visual Studio Feedback documentation.

  1. In the top right corner of the Visual Studio window, click the Send feedback button.

    Screenshot of the share feedback button in Visual Studio.

  2. Choose the option that best describes your feedback.

    • To report a bug, click Report a problem.
    • To request a feature, click Suggest a feature.

Further reading