GitHub Copilot Commands & Prompt Reference

31 commands & parameters · 6 categories · Source: GitHub Docs — Copilot Chat cheat sheet

GitHub Copilot Chat exposes different command sets depending on where you run it: VS Code, Visual Studio, JetBrains, Xcode, the GitHub website, and the Copilot CLI each accept their own slash commands, and VS Code adds # chat variables and @ chat participants on top. This page groups the official cheat-sheet commands by client so you can see at a glance what works where.

The highest-leverage habit is scoping context on purpose: #selection or #function keeps the prompt tight, #project trades speed for breadth, and participants like @terminal or @vscode route the question to the right specialist. Slash commands such as /fix, /tests, and /explain then act on exactly the context you attached.

Also see: GitHub Copilot keyboard shortcuts.

All Commands

Slash Commands & Prompts (VS Code) (7)

Command / SyntaxWhat it doesNotes
/clearStart a new chat sessionClears the current Copilot Chat conversation in VS Code.
/explainExplain how the code in your active editor worksSelect code first for a focused explanation.
/fixPropose a fix for problems in the selected codeHighlight the broken code, then run the command.
/fixTestFailureFind and fix a failing testCopilot locates the failing test and proposes a repair.
/helpQuick reference and basics of using GitHub CopilotLists available commands and usage basics.
/newCreate a new projectScaffolds a new workspace from your description.
/testsGenerate unit tests for the selected codeSelect a function or class before running.

Chat Variables (#) Prompts (VS Code) (10)

Command / SyntaxWhat it doesNotes
#blockInclude the current block of code in the promptType # in the chat box, then the variable name.
#classInclude the current class in the promptScopes the context to the enclosing class.
#commentInclude the current comment in the promptUseful when iterating on a doc comment.
#fileInclude the current file's content in the promptAttaches the whole active file as context.
#functionInclude the current function or method in the promptScopes the context to the enclosing function.
#lineInclude the current line of code in the promptNarrowest context scope available.
#pathInclude the file path in the promptPasses the location, not the contents.
#projectInclude the project context in the promptBroadest scope; slower but most informed.
#selectionInclude the currently selected text in the promptSelect first, then reference #selection.
#symInclude the current symbol in the promptTargets the symbol under the cursor.

Chat Participants (@) Prompts (4)

Command / SyntaxWhat it doesNotes
@azureContext about Azure services: use, deploy, and manage themPublic preview; subject to change.
@githubUse GitHub-specific Copilot skillsBridges chat to GitHub skills from the IDE.
@terminalContext about the VS Code terminal shell and its contentsAsk it to create or debug terminal commands.
@vscodeContext about VS Code commands and featuresAsk how to do something in the editor itself.

Slash Commands (GitHub.com Chat) (4)

Command / SyntaxWhat it doesNotes
/clearClear conversation (GitHub.com)Runs in Copilot Chat on the GitHub website.
/deleteDelete a conversationRemoves the conversation from your history.
/newStart a new conversation (GitHub.com)Opens a fresh chat thread.
/renameRename a conversationGive threads descriptive names for later.

Slash Commands (Visual Studio & Xcode) (3)

Command / SyntaxWhat it doesNotes
/docAdd a documentation comment for this symbolCursor must be on the symbol to document.
/optimizeAnalyze and improve running time of the selected codeSelect the hot path first.
/simplifySimplify the current code selectionAvailable in Copilot for Xcode.

Slash Commands (JetBrains & Copilot CLI) (3)

Command / SyntaxWhat it doesNotes
/chronicleReview and analyze your session historySubcommands: standup, tips, search, improve.
/compactCompress the current Copilot CLI session contextKeeps a long-running session manageable.
/remoteEnable or manage remote control for the current CLI sessionAccess the session from GitHub.com or GitHub Mobile.

Recipes

Our own notes on combining the commands above. Every token used here appears in the reference tables on this page.

Ask about a specific block instead of the whole project

#selection or #function → /fix

Context scope drives both speed and answer quality. #selection and #function keep the prompt tight; #project is broader but slower and dilutes attention. Attach the narrowest scope that contains the problem, then run the slash command.

Generate tests that match the code you mean

select the function → #function → /tests

/tests works from whatever is in scope, so selecting the target first is the difference between tests for one function and a scattergun pass over the file.

Get a terminal command without switching windows

@terminal + a plain-language description

@terminal routes the question to the participant that has context about your shell and its recent contents, so the answer accounts for what is actually installed and what just failed.

Fix a failing test from the failure itself

#file → /fixTestFailure

/fixTestFailure locates the failing test and proposes a repair rather than asking you to describe the failure. Attaching the file keeps it from guessing which test you mean.

Keep a long Copilot CLI session workable

/compact → /chronicle

/compact compresses the CLI session context when it gets heavy. /chronicle reviews and analyses your session history, with subcommands for standup, tips, search, and improve, which is how you get value out of a long session afterwards.

Frequently Asked Questions

Why do the slash commands differ between editors?

Each Copilot client ships its own command set. The official cheat sheet documents them separately for VS Code, Visual Studio, JetBrains, Xcode, the GitHub website, and the Copilot CLI, which is how this page groups them.

What is the difference between # variables and @ participants?

# variables attach a scope of code as context (#selection, #file, #project). @ participants route the question to a specialist with its own knowledge, such as @terminal or @vscode.

How do I list the commands available right now?

Type / in the chat prompt box of your current environment. The live list reflects your client and context.

Every entry on this page is a literal, typeable token taken from the official documentation linked above. Command sets in AI tools change quickly - the in-product command menu is always authoritative for your installed version.

Related prompt references

Cursor (37) · Claude Code (142) · OpenAI Codex CLI (58) · All AI prompt references