GitHub Copilot Chat Slash Commands in VS Code: Full Reference
🔍 WiseChecker

GitHub Copilot Chat Slash Commands in VS Code: Full Reference

GitHub Copilot Chat in VS Code offers slash commands that let you control how the AI generates code, explains logic, or fixes errors without typing long prompts. These commands act as shortcuts for common developer tasks such as debugging, writing tests, or refactoring. Without knowing the right slash command, you may get generic responses or waste time rewriting requests. This reference lists every available slash command, explains what each one does, and shows how to use them in the Copilot Chat panel.

Key Takeaways: GitHub Copilot Chat Slash Commands in VS Code

  • Slash command /fix: Automatically analyzes the selected code block and suggests a correction for syntax or logic errors.
  • Slash command /tests: Generates unit test cases for the selected function or method based on its current implementation.
  • Slash command /explain: Provides a plain-English explanation of the selected code, including its purpose and how it works.

What Are Slash Commands in Copilot Chat?

Slash commands are typed directly into the Copilot Chat input box in VS Code. Each command starts with a forward slash and tells Copilot to perform a specific action rather than responding to a free-form question. The commands are designed for developers who want fast, predictable results without writing long natural-language prompts. You do not need to install any extra extensions. The commands work with any programming language that Copilot supports, including Python, JavaScript, TypeScript, C#, Java, and Go.

How to Open Copilot Chat

Press Ctrl+Shift+I on Windows or Cmd+Shift+I on macOS to open the Copilot Chat panel. Alternatively, click the Copilot icon in the VS Code activity bar. The chat input field is at the bottom of the panel. Type a slash command there and press Enter.

Prerequisites

You must have the GitHub Copilot extension installed and be signed in with an active GitHub Copilot subscription. The extension version should be 1.86 or later. VS Code version 1.85 or later is recommended. The commands work in both the stable and Insiders builds of VS Code.

Complete List of Slash Commands and Their Usage

Below is the full list of slash commands available in Copilot Chat for VS Code as of version 1.94. Each command is shown with its exact syntax, what it does, and an example use case.

/explain – Explain the Selected Code

Select a block of code in the editor, then type /explain in the chat input. Copilot returns a step-by-step explanation of what the code does, including the logic behind loops, conditionals, and function calls. This command is useful when you inherit legacy code or review a pull request.

/fix – Fix Errors in the Selected Code

Select code that contains a syntax error, runtime error, or logic bug. Type /fix and Copilot suggests a corrected version. The command works best for isolated blocks rather than whole files. It does not run the code; it analyzes the text for common error patterns.

/tests – Generate Unit Tests

Select a function or method. Type /tests and Copilot generates test cases using the testing framework it detects in your project, such as pytest for Python or Jest for JavaScript. The command creates test stubs that you can paste into your test file.

/help – Show Available Commands

Type /help to see the full list of slash commands along with a short description of each. This command does not require any code selection. It is the fastest way to discover new commands without leaving the chat panel.

/clear – Clear the Chat History

Type /clear to erase the current conversation from the chat panel. The command resets the context so that subsequent prompts start fresh. It does not affect any open files or settings.

/doc – Generate Documentation Comments

Select a function, class, or method. Type /doc and Copilot generates JSDoc, XML doc comments, or Python docstrings depending on the language. The command inserts the comment block above the selected code. You can copy the output or apply it directly.

/optimize – Suggest Performance Improvements

Select a code block. Type /optimize and Copilot suggests changes that may improve execution speed or reduce memory usage. The command does not guarantee a measurable performance gain; it highlights common inefficiencies such as unnecessary loops or redundant API calls.

/clear – Reset Chat Context

Type /clear to erase the chat history. This is useful when you want to start a new topic without the AI remembering previous questions. The command does not affect the code in your editor.

/help – List All Commands

Type /help to display the same list you see in this reference. The output appears in the chat panel and includes a one-line description for each command.

Common Mistakes and Limitations

Copilot Chat Does Not Respond to the Slash Command

If you type a slash command and nothing happens, check that you typed the command at the very beginning of the input field. A space before the slash breaks the command. Also verify that your Copilot subscription is active and that the VS Code extension is up to date.

The Command Produces Irrelevant Output

Slash commands rely on the code you have selected. If you do not select any code, commands like /fix or /tests have no context and may return generic suggestions. Always select the relevant code block before typing the command.

Commands Do Not Work in the Inline Chat

Slash commands are currently supported only in the Copilot Chat panel, not in the inline chat that appears when you press Ctrl+I. Use the dedicated chat panel for all slash commands.

Copilot Does Not Recognize Custom Commands

You cannot create custom slash commands. The list is fixed and maintained by GitHub. If you need a specific behavior, write a free-form prompt instead.

Slash Commands in Copilot Chat vs Free-Form Prompts

Item Slash Commands Free-Form Prompts
Input format Starts with a forward slash Natural language question
Output predictability High – each command has a fixed behavior Variable – depends on wording
Code selection required Yes for most commands Optional
Speed Faster for repetitive tasks Slower for structured tasks
Customization None – fixed command set Full flexibility

Use slash commands when you need a predictable result for a specific task such as fixing a bug or generating tests. Use free-form prompts when you need to ask open-ended questions or combine multiple tasks in one request.

You now have a complete reference for every slash command in GitHub Copilot Chat for VS Code. Start by using /help to confirm your setup, then try /explain on a function you wrote last week. For faster daily work, memorize /fix and /tests because they save the most time. If a command does not behave as expected, select the code first and verify your extension version.