Copilot Chat: Slash Commands, Participants and Limits
30-second answer
In Copilot Chat, slash commands run common jobs (/explain, /fix, /tests, /doc, /new, /clear, /help), participants starting with @ bring in a domain expert (@workspace, @vscode, @terminal, @github), and # adds context (#file, #selection, #codebase, #terminalLastCommand, #changes). The model picker (including Auto) chooses the model your plan and organization allow, 👍 / 👎 sends feedback, and prompt files (.github/prompts/*.prompt.md, run as /name) reuse a good prompt. Chat only sees the context you give it in a finite context window, and its answers can be wrong.
Exam objective: 2.3.4 Understand the limits, options, feedback, and commands of GitHub Copilot Chat; include prompt file reuse for consistent responses. (Skills measured as of August 7, 2026)
Simulations
Feel it before you read it. No account needed, nothing leaves this page.
Type <strong>/</strong> for <strong>slash commands</strong>: <code>/explain</code>, <code>/fix</code>, <code>/tests</code>, <code>/doc</code>, <code>/new</code>, <code>/clear</code>. Select code first so Copilot knows what you mean.
👆 Click the glowing item on screen to continue
Read the steps as text
- Type / for slash commands: /explain, /fix, /tests, /doc, /new, /clear. Select code first so Copilot knows what you mean.
- /tests writes tests for the selection. Use 👍 / 👎 to give feedback on an answer, and Insert or Copy to use the code.
- Participants start with @: @workspace (your project), @terminal, @vscode, @github. Context starts with #: #file, #selection, #codebase, #terminalLastCommand.
- The model picker lets you choose a model or Auto. Your plan and your organization decide which models are offered, and some models use more of your premium allowance.
- Know the limits: Chat only sees what is in the conversation and the context you add, history counts against the context window, and answers can be wrong. Start a new chat when the topic changes.
🧪 Simulation for learning. Screens are simplified versions of Visual Studio Code and github.com with GitHub Copilot; names, files and suggestions are examples. Not affiliated with GitHub or Microsoft, and nothing here touches your real account.
🖱️ Drag to rotate · scroll or pinch to zoom
How context is chosen
In chat, Copilot uses the active file and any selection, plus what you add: #file, #codebase (search your workspace), #terminalSelection, images, or a participant such as @workspace. Inline suggestions also use open tabs, so close unrelated ones.
🤔 What happens if…
Read this tour as text
- A vague prompt. Copilot only knows what is in the prompt. “Write a function” leaves it to guess the language, inputs, outputs and rules, so you get something generic.
- Structure: goal, context, constraints. A good prompt has a goal (what and why), context (which code, which framework) and constraints (style, edge cases, what not to do). Short is fine; vague is not.
- How context is chosen. In chat, Copilot uses the active file and any selection, plus what you add:
#file,#codebase(search your workspace),#terminalSelection, images, or a participant such as@workspace. Inline suggestions also use open tabs, so close unrelated ones. - Zero-shot and few-shot. Zero-shot: just the instruction. Few-shot: include one or more examples of the input and the output you want, then ask. Few-shot wins when your format is unusual.
- Break it down, then iterate. Split a big task into small steps and check each answer. Then iterate: keep what’s right and ask for the next change. Prompting is a conversation.
- Custom instructions. Repository instructions (
.github/copilot-instructions.md) and path-specific.instructions.mdfiles are added to requests automatically, so the house rules travel with every prompt. - Chat history is context too. Earlier messages in the same conversation go into the prompt. That helps follow-ups (“now add tests”) but old, unrelated turns can confuse the answer and fill the context window.
- The prompt process, end to end. Your words + selected context + instructions + history → the prompt. The model answers, you review, then refine. Better input, less clean-up.
Stop repeating yourself in every prompt. Write repository instructions, add path-specific instructions for tests, and create a custom agent that only writes tests, then watch Copilot follow them.
🎓 Education-only simulation. Your lab is saved in this browser, so you can leave and continue later.
😟 THE PROBLEM
Chat answers are vague because Copilot can’t tell which code you mean.
😊 THE SOLUTION
Use slash commands, participants and # context, and know Chat’s limits.
- Long explanations of intent✓ /explain, /fix, /tests, /doc
- Wrong files considered✓ #file, #selection, #codebase
- Answers drift over time✓ New chat when the topic changes
Start with a question
If you call a plumber and just say 'it's broken', how long before they fix the right pipe?
A long time. Now imagine you say “the kitchen tap drips, here’s a photo, it started after last week’s repair”. The plumber knows what kind of job it is, where to look and what changed.
Copilot Chat is the same. A slash command tells it the kind of job (/fix, /tests). A participant like @workspace sends the question to someone who knows the whole house. # context like #file is the photo. And like any plumber, it only knows what you showed it.
Explain it like I’m 10
The technical explanation
Slash commands
Type / in the chat box to see them. Select code first, so Copilot knows what “this” means.
| Command | What it does |
|---|---|
/explain | Explains the selected code or the active file |
/fix | Proposes a fix for problems in the selection |
/tests | Writes unit tests for the selection |
/doc | Adds documentation comments |
/new | Scaffolds a new project or file |
/clear | Starts a fresh conversation |
/help | Lists what’s available |
Select applyDiscount in src/discount.js, type /tests, and Copilot writes tests for SAVE10, an unknown code, no code and an empty cart. You then Insert into new file or Copy.
Participants (@) and context (#)
Participants are experts with their own context:
@workspaceanswers questions about your whole project (“where is the discount applied?”).@vscodeanswers questions about the editor and its settings.@terminalhelps with shell commands and the integrated terminal.@githubbrings in GitHub data such as issues and pull requests.
Context variables start with # and add exactly what you choose: #file:src/cart.js, #selection, #codebase (search the workspace), #terminalSelection, #terminalLastCommand and #changes (your uncommitted changes). You can also drag files or a screenshot into the chat.
@workspace why could cartTotal return NaN? #file:src/discount.js
Under each answer, Used n references lists what Copilot actually read. If the file you care about isn’t there, add it.
Model picker and feedback
The model picker lets you choose a model or Auto, which picks one for you. Which models you see depends on your plan and on your organization’s Models policy. Premium models use your monthly premium-request allowance, and extra use can be paid for or blocked by a budget.
Use 👍 / 👎 on an answer to send feedback. It helps GitHub improve the service and it’s a habit worth having: a thumbs down on a confident but wrong answer is useful data.
Prompt files: reuse a good prompt
If you keep typing the same careful prompt, save it as a prompt file in .github/prompts/:
---
description: Write edge-case tests for one module
mode: agent
---
Write unit tests for ${input:file} with the Node test runner.
Cover an unknown code, no code, an empty cart and totals that would go negative.
Save it as .github/prompts/edge-tests.prompt.md and run it with /edge-tests in chat. Everyone on the team gets the same instructions, and you improve the prompt through a pull request. Front matter can also set tools and model. Prompt files run only when you call them; repository instructions (.github/copilot-instructions.md) are added to every request automatically.
The limits you need to know
- Context window. Each request has a size limit. Your message, the context you added, custom instructions and the chat history all count. Long files get trimmed.
- History helps and hurts. Follow-ups like “now add tests” work because earlier turns are included. Old, unrelated turns confuse the answer. Use
/clearor a new chat when the topic changes. - Only what it can see. Chat doesn’t magically know your whole repo. It uses the active file, your selection and what you add.
- Answers can be wrong. Made-up APIs, outdated library versions and insecure code all happen. Review and test.
- Not deterministic. The same question can give a different answer next time.
Architect level Participants, tools and agent mode
In Ask mode, participants decide whose context is used. In Agent mode the model chooses tools itself (search the codebase, read a file, run a terminal command, call an MCP tool), so you’ll mostly use # references to point it in the right direction. A prompt file’s tools list limits which tools it may use when it runs as an agent, which is a simple way to make a reusable prompt that can read and edit but never run shell commands. Organization policies still apply: if an admin turns off a feature or a model, no prompt file can turn it back on.
Real-world business scenario
Contoso (fictional)
- The problem
- Contoso's developers each asked Copilot for tests in their own words. Some got tests without edge cases, some got Jest instead of the Node test runner, and long chats wandered off topic.
- What they used
- A shared prompt file, .github/prompts/edge-tests.prompt.md, run with /edge-tests, plus a team habit of adding #file context and starting a new chat per task.
- Why that choice
- The prompt file gives everyone the same instructions, and fresh chats keep old history out of the context window.
- The result
- Test pull requests became consistent enough that reviewers stopped asking for missing edge cases.
When to use it and when not to
✓ Use it when…
- Slash commands for quick, common jobs on selected code.
- @workspace or #codebase when you don't know where the answer lives.
- Prompt files for tasks the team repeats and wants done the same way.
- A new chat each time the topic changes.
✕ Think twice when…
- Pasting secrets or customer data into chat to "give it context".
- Trusting an answer because it sounds sure. Check the references and test the code.
- Putting house rules in a prompt file that people may forget to run. Use custom instructions for those.
↔ Alternatives to consider
- Custom instructions (.github/copilot-instructions.md) for rules that should apply to every request.
- Copilot CLI slash commands (/model, /context, /usage) when you work in the terminal.
Test yourself with exercises
5 original practice questions in the GH-300 style. Pick your answers, then check them. You will see why each option is right or wrong. Score 75% or more and this topic is marked complete.
Interview preparation
Say your answer out loud first, then open the model answer. Interviewers care more about your reasoning than the exact words.
Beginner What's the difference between @workspace and #file?
Model answer
@workspace is a participant: it answers questions about the whole project and finds the relevant code itself. #file adds one specific file I choose to the prompt. If I know where the answer is, #file is more precise. If I don't, @workspace or #codebase searches for me.
Intermediate Copilot Chat starts giving answers about an old bug you discussed an hour ago. What do you do?
Model answer
Start a new chat, or use /clear. The earlier turns are still in the prompt as history, so they eat the context window and pull the answer off topic. A fresh chat with only the context for the new question gives better answers.
Experienced developer Your team keeps writing the same long prompt for API endpoint reviews. How would you make that consistent?
Model answer
I'd save it as a prompt file, .github/prompts/review-endpoint.prompt.md, with a description and maybe the mode and tools in the front matter, and an input variable for the file name. Everyone runs it with /review-endpoint, gets the same instructions, and we change it in one place through a pull request.
Interviewer follows up
How is that different from copilot-instructions.md?
You
Repository instructions are added to every request automatically. A prompt file only runs when someone calls it, so it's for a specific task, not house rules.
Scenario A developer asks for a model that isn't in their model picker. Why might that be?
Model answer
The models offered depend on their Copilot plan and on what the organization has enabled under Copilot › Models. An admin may have turned that model off, or it's only on a higher plan.
Quick revision
Key points
- Slash commands: /explain, /fix, /tests, /doc, /new, /clear, /help.
- Participants (@): @workspace, @vscode, @terminal, @github.
- Context (#): #file, #selection, #codebase, #terminalSelection, #terminalLastCommand, #changes. You can also drag in files and images.
- The model picker includes Auto; your plan and organization decide which models appear, and premium models use your premium-request allowance.
- 👍 / 👎 sends feedback; "Used n references" shows which context Copilot used.
- Prompt files in .github/prompts/*.prompt.md run with /name and can take ${input:name} variables.
- Limits: finite context window, history counts against it, answers can be wrong or outdated.
Important terminology
- Slash command
- A shortcut typed with / in Copilot Chat, such as /explain, /fix or /tests, that tells Copilot the kind of job you want.
- Chat participant
- An @ handle such as @workspace or @terminal that routes the question to an expert with its own context.
- Chat variable (# context)
- A # reference such as #file, #selection or #codebase that adds specific context to the prompt.
- Prompt file
- A reusable prompt saved as .github/prompts/<name>.prompt.md and run in chat with /<name>.
- Context window
- The maximum amount of text a model can take in one request, including your message, context and chat history.
- Used references
- The list under a chat answer showing which files and sources Copilot actually used.
Common mistakes
- Keeping one endless chat for unrelated topics.
- Assuming Copilot read the whole repo when it only used the open file.
- Confusing prompt files (run on demand) with custom instructions (added automatically).
Exam tips
- "Generate unit tests for the selected function" = /tests.
- "Ask about the whole project" = @workspace (or #codebase).
- "Reuse the same prompt across the team" = a prompt file in .github/prompts.
Five quick revision questions
-
1.Which slash command starts a fresh conversation?Show
/clear
-
2.Which participant answers questions about VS Code itself?Show
@vscode
-
3.Which variable adds the output of the last terminal command?Show
#terminalLastCommand
-
4.Where do prompt files live?Show
.github/prompts/ with the .prompt.md extension
-
5.Where can you see which files Copilot used for an answer?Show
The "Used n references" list under the answer.
Official references
Finished this lesson? Tick it off. Your progress is saved in this browser.
Next up: GitHub Copilot CLI: Install and Key Commands
Lesson done? Make it stick with a quick gameSort It, Match the Pairs, Lightning Round and Who Am I? Earn XP and badges.