DEV Community

Louis Liu
Louis Liu

Posted on

2 2 1 2

GitHub Copilot Chat Cheat Sheet

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 the command name.

Command Description
/clear Start a new chat session.
/explain Explain how the code in your active editor works.
/fix Propose a fix for problems in the selected code.
/fixTestFailure Find and fix a failing test.
/help Quick reference and basics of using GitHub Copilot.
/new Create a new project.
/tests Generate unit tests for the selected code.

Chat Variables

Use chat variables to include specific context in your prompt. To use a chat variable, type # in the chat prompt box, followed by a chat variable.

Variable Description
#block Includes the current block of code in the prompt.
#class Includes the current class in the prompt.
#comment Includes the current comment in the prompt.
#file Includes the current file's content in the prompt.
#function Includes the current function or method in the prompt.
#line Includes the current line of code in the prompt.
#path Includes the file path in the prompt.
#project Includes the project context in the prompt.
#selection Includes the currently selected text in the prompt.
#sym Includes the current symbol in the prompt.

Chat Participants

Chat participants are like domain experts who have a specialty that they can help you with. You can specify a chat participant by typing @ in the chat prompt box, followed by a chat participant name. To see all available chat participants, type @ in the chat prompt box.

Below is a list of some of the most common chat participants for using Copilot Chat.

Variable Description
@azure Has context about Azure services and how to use, deploy and manage them. Use @azure when you want help with Azure. The @azure chat participant is currently in public preview and is subject to change.
@github Allows you to use GitHub-specific Copilot skills. See Asking GitHub Copilot questions in your IDE.
@terminal Has context about the Visual Studio Code terminal shell and its contents. Use @terminal when you want help creating or debugging terminal commands.
@vscode Has context about Visual Studio Code commands and features. Use @vscode when you want help with Visual Studio Code.
@workspace Has context about the code in your workspace. Use @workspace when you want Copilot to consider the structure of your project, how different parts of your code interact, or design patterns in your project.

Reference: https://docs.github.com/en/copilot/using-github-copilot/copilot-chat/github-copilot-chat-cheat-sheet?tool=vscode

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay