Skip to main content
This guide explains GitHub Copilot slash commands—how to use them in editors like Visual Studio and Visual Studio Code, when Visual Studio provides extra benefits, and practical examples for documentation, explanations, fixes, tests, and project scaffolding.
If you use a licensed edition of Visual Studio (for example, Professional or Enterprise), Copilot access may be included with your Visual Studio subscription. Signing in with a paid GitHub Copilot account inside Visual Studio applies your Copilot subscription limits and features to the IDE. Check your Visual Studio account settings for entitlement details.

Core slash commands (quick reference)

These core slash commands are the most frequently used for day-to-day development tasks such as generating documentation, explaining code, proposing fixes, and starting fresh conversations.
A slide titled "Available Slash Commands" showing four labeled boxes: /doc, /exp, /explain, and /fix. Each box gives a brief description of the command (insert docs, start a new thread, explain selected code, and propose fixes).

Other useful slash commands

These additional commands extend Copilot’s capabilities for tests, optimization, scaffolding, and assistance. Use them to speed up repetitive or broader tasks. Example quick reference (copy/paste into chat if helpful):

How to invoke a slash command

You can open and trigger slash commands in several convenient ways:
  • Type a forward slash / directly in the GitHub Copilot Chat message box.
  • Click the Slash button in the Copilot Chat UI.
  • Use inline chat tied to your editor (for example, press Alt + / in many editor setups, or right‑click and select “Ask Copilot” from the context menu).
An infographic titled "Accessing Slash Commands" showing three colorful icons and brief steps: "Type a slash", "Click the Slash button", and "Use inline chat" to open Copilot chat commands.

Why slash commands are convenient

  • Dedicated Chat Window: Use the fuller chat UI to keep history, thread related prompts, and manage long conversations.
  • Inline Chat Dialog: Keep context near the code with inline prompts—ideal for quick, localized edits or explanations.
  • Continuous Workflow: Request documentation, fixes, tests, optimizations, or even scaffold projects without leaving your editor.
A dark-themed slide titled "Seamless Integration" listing three numbered features — Main Chat Window, Inline Chat Dialog, and Continuous Workflow — each with a short description and icon. A small "© Copyright KodeKloud" appears in the bottom-left.

Demo walkthrough (sign-in and examples)

After signing in to Visual Studio with a qualifying account, Copilot surfaces sample actions such as “Summarize my code”, “Write unit tests”, “Fix my code”, and “Explain programming concepts.” These UI shortcuts insert the corresponding slash commands on your behalf and speed up common workflows.
A Visual Studio IDE window showing the "What's New" pane and a GitHub Copilot Chat panel. The Copilot pane lists sample prompts like "Summarize my code" and "Write unit tests."

Examples

Below are practical examples showing where to use slash commands for documentation, components, explanations, and tests. Program documentation example
  • Open a code file (for example, Program.cs) and type /doc. Copilot inserts language-appropriate documentation comments for symbols near the cursor or for selected code.
Example Program.cs (illustrative):
Component example (Counter.razor)
  • Select the component code and run /doc or /explain to generate component-level comments and method summaries.
Explanation and tests
  • Highlight code and run /explain to produce readable explanations or XML summary comments. For example, selecting middleware calls might yield:
  • Use /tests on a method or class to have Copilot scaffold a test file with multiple cases and edge scenarios. If a CI run surfaces failing tests, /fix-test-failure inspects failures and suggests code-level fixes.

Closing notes and best practices

  • Slash commands are available in both Visual Studio and Visual Studio Code. They accelerate documentation, fixes, optimizations, test generation, and project scaffolding seamlessly within your editor.
  • Familiarize yourself with the most common commands — they reduce context switching and speed daily development tasks.
  • Use inline chat for quick, context-sensitive requests and the main chat window for longer or multi-step conversations.
Tip: Use the inline chat for quick context-sensitive requests and the main chat window when you need a longer conversation or to manage multiple related prompts.

Watch Video