Your profile

One profile for every MSDEVBUILD site. Only you can see it, and the site owner if you write in.

Lesson 7 of 30
❮Prev Next❯

Copilot Chat: Slash Commands, Participants and Limits

Module 2: Copilot Features ⏱ 10 min read Updated

Your note

My notes for this lesson

Select any text in the lesson to highlight it or add a note. Saved in this browser.

    No highlights yet. Select a sentence in the lesson, then pick a colour or add a note.

    All my bookmarks and notes

    Reading settings

    For every lesson, saved in this browser.

    Text size
    Line spacing
    Font

    With IaaS you rent the virtual machine. Microsoft looks after the building, power and hardware; you patch the operating system.

    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.

    Simulate it » No Azure account needed

    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.

    VS Code & GitHub: Copilot Chat: slash commands, participants and feedback Slash commands, participants, context, the model picker and feedback.
    </> Embed

    Embed this simulation

    Free for trainers, teachers and bloggers. Paste this into your page:

    Loading…

    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
    1. Type / for slash commands: /explain, /fix, /tests, /doc, /new, /clear. Select code first so Copilot knows what you mean.
    2. /tests writes tests for the selection. Use 👍 / 👎 to give feedback on an answer, and Insert or Copy to use the code.
    3. Participants start with @: @workspace (your project), @terminal, @vscode, @github. Context starts with #: #file, #selection, #codebase, #terminalLastCommand.
    4. 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.
    5. 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.

    😟 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
    🛠️ Solved with: Copilot Chat

    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.

    CommandWhat it does
    /explainExplains the selected code or the active file
    /fixProposes a fix for problems in the selection
    /testsWrites unit tests for the selection
    /docAdds documentation comments
    /newScaffolds a new project or file
    /clearStarts a fresh conversation
    /helpLists 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:

    • @workspace answers questions about your whole project (“where is the discount applied?”).
    • @vscode answers questions about the editor and its settings.
    • @terminal helps with shell commands and the integrated terminal.
    • @github brings 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 /clear or 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

    Online retail

    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.
    Ready for more?The full lesson adds the technical explanation, when to use it, interview questions and revision notes.

    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.

    Question 1

    Question 1 of 5

    A developer selects the applyDiscount function in Visual Studio Code and wants Copilot Chat to generate unit tests for it. Which slash command should the developer use?

    Question 2

    Question 2 of 5

    A developer has been using one Copilot Chat conversation for several hours across unrelated tasks. Answers now reference code from earlier tasks that is not relevant. What should the developer do first?

    Question 3

    Question 3 of 5 · Select 2

    A developer asks Copilot Chat in Visual Studio Code why the cart total can be NaN. Which TWO references add specific context to the prompt? Each correct answer presents a complete solution.

    Question 4

    Question 4 of 5

    Your team repeatedly writes the same detailed prompt to generate edge-case tests. You need every developer to run an identical, version-controlled prompt on demand from Copilot Chat. What should you create?

    Question 5

    Question 5 of 5

    A developer with a Copilot Business seat cannot find a specific model in the Copilot Chat model picker, although a colleague in another organization can select it. What is the most likely reason?

    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. 1.Which slash command starts a fresh conversation?Show

      /clear

    2. 2.Which participant answers questions about VS Code itself?Show

      @vscode

    3. 3.Which variable adds the output of the last terminal command?Show

      #terminalLastCommand

    4. 4.Where do prompt files live?Show

      .github/prompts/ with the .prompt.md extension

    5. 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

    Studying with a friend? Send them this lesson

    It's free and needs no sign-up. Their progress saves in their own browser.

    Lesson done? Make it stick with a quick gameSort It, Match the Pairs, Lightning Round and Who Am I? Earn XP and badges. Play ❯

    Install MSDEVBUILD Azure

    Free · no account · works offline

    Save the whole course for offline ›

    Hi, I’m your Nimbus

    Your study buddy. Pick what we do next.

    MSDEVBUILD · Multi-Stack Dev Build

    Sign in to MSDEVBUILD

    One account for Azure certifications and the blog: sign in here and you are signed in on both. Your XP, streak, practice deck and certificate stay in sync on every device. Optional: everything works without an account.