← All trainings

VS Code Copilot

Copilot Cheatsheet

This cheat sheet is for the Engineer — keep it next to your screen. Bookmark it. Reference it constantly until it’s second nature.

Roles: “Engineer” = you, the person being trained. “Mentor” = the trainer/teacher guiding your learning.

Table of Contents


The Golden Rule

Ask Copilot how to approach the problem before asking it to solve it. Maybe you’re solving the wrong one.

BAD:  "Build a user authentication system"
GOOD: "I need to add user authentication to my web app. What are the different
       approaches — session-based vs JWT vs OAuth? What are the tradeoffs
       for my stack? Which would you recommend and why?"

1. Mode Selection Guide

I need to…Use this modeWhy
Get a quick code suggestion as I typeInline completionsZero friction, Tab to accept
Apply a follow-up edit Copilot suggestsNext Edit Suggestions (NES)Tab through chained edits after a change
Ask a question about my code or projectAsk mode (Chat panel)Read-only, explores and explains without changing files
Edit a specific block of code in-placeInline Chat (Cmd+I)Quick targeted edits without leaving the editor
Make coordinated edits across filesEdit mode (Chat panel)Proposes diffs across multiple files, you review each one
Build a feature end-to-end autonomouslyAgent mode (Chat panel)Plans, creates files, runs terminal commands, iterates on errors

Mode progression during training:

  • Day 1: Inline + NES + Ask + Inline Chat + Edit mode
  • Day 2: All above + Agent mode
  • Day 3 (Capstone): Agent mode as primary, others as support

2. Keyboard Shortcuts

Inline Completions

ActionMacWindows/Linux
Accept suggestionTabTab
Dismiss suggestionEscEsc
Next suggestionAlt+]Alt+]
Previous suggestionAlt+[Alt+[
Accept next wordCmd+→Ctrl+→
Trigger suggestion manuallyAlt+\Alt+\

Next Edit Suggestions (NES)

ActionMacWindows/Linux
Accept NESTabTab
Dismiss NESEscEsc
Jump to next NES locationTab (when arrow shown)Tab (when arrow shown)

Chat & Modes

ActionMacWindows/Linux
Open Chat panelCmd+Shift+ICtrl+Shift+I
Inline ChatCmd+ICtrl+I
Quick Chat (floating)Cmd+Shift+Alt+LCtrl+Shift+Alt+L
Switch mode (Ask/Edit/Agent)Click mode dropdown in ChatClick mode dropdown in Chat
Open model pickerClick model name in ChatClick model name in Chat
Attach file to Chat# then type filename# then type filename
Add to Chat contextRight-click → “Copilot” → “Add to Chat”Right-click → “Copilot” → “Add to Chat”

General

ActionMacWindows/Linux
Fix with Copilot (on error)Click lightbulb → “Fix using Copilot”Click lightbulb → “Fix using Copilot”
Generate commit messageClick sparkle icon in Source ControlClick sparkle icon in Source Control
Explain terminal outputClick sparkle icon in terminalClick sparkle icon in terminal

3. Chat Participants & Variables

Participants (type @ in Chat)

ParticipantWhat it doesExample
@workspaceSearches your entire workspace for context”@workspace where is authentication handled?”
@terminalReferences terminal output and commands”@terminal explain this error”
@vscodeVS Code settings, commands, and features”@vscode how do I change the font size?”
@githubGitHub issues, PRs, repos (requires GitHub Copilot Chat)“@github list open issues”

Variables (type # in Chat)

VariableWhat it providesWhen to use
#fileContents of a specific file”Explain #file:src/auth.ts”
#selectionCurrently selected code”Refactor #selection to use async/await”
#codebaseWorkspace-wide context search”Find all API endpoints in #codebase”
#editorCurrently visible file in editor”What does this function do? #editor”
#terminalLastCommandLast terminal command + output”Why did this test fail? #terminalLastCommand”
#terminalSelectionSelected text in terminal”Explain #terminalSelection”
#problemsCurrent VS Code Problems panel entries”Fix the errors in #problems”
#changesCurrent git diff / staged changes”Review #changes for issues”

Slash Commands (type / in Chat)

CommandWhat it does
/explainExplain selected code or concept
/fixFix a problem in selected code
/testsGenerate tests for selected code
/docGenerate documentation for selected code
/newScaffold a new project or file
/newNotebookCreate a new Jupyter notebook

4. Custom Instructions Hierarchy

Copilot uses a layered instruction system. More specific instructions override more general ones.

.github/copilot-instructions.md          ← Project-wide: architecture, conventions, patterns
                                            Applied to ALL Copilot interactions in this repo

.instructions.md (with applyTo glob)      ← Scoped: rules for specific files/folders
                                            e.g., applyTo: "src/api/**" for API-specific rules

.github/copilot-instructions.md           ← Combined: project-wide + scoped = full context
   + matching .instructions.md files

AGENTS.md (project root or subdirs)       ← Agent mode only: extra rules for autonomous behavior
                                            e.g., "always run tests after changes"

.prompt.md files                          ← Reusable prompt templates for common tasks
                                            Invoked explicitly: #prompt:my-template

What to put in each:

FileContentsExample
copilot-instructions.mdArchitecture, tech stack, naming conventions, error handling patterns”Use repository pattern. All errors must be wrapped with context.”
.instructions.mdFile-scoped rules with applyTo front matter”Tests in this folder use vitest. Mock external APIs. Use factory functions for test data.”
AGENTS.mdRules for Agent mode autonomy”Run npm test after any code change. Commit with conventional commits.”
.prompt.mdReusable prompt templates”Generate a CRUD endpoint following our API conventions for the given resource.”

Setup order:

  1. Run Copilot’s /init command — it generates a starter copilot-instructions.md
  2. Edit it to match your actual stack and conventions
  3. Create .instructions.md files for specialized directories (tests, API routes, etc.)
  4. Create AGENTS.md when you start using Agent mode (Day 2)
  5. Create .prompt.md files for recurring tasks

5. Planning Mode

Use the /plan command in Agent mode for anything bigger than a single function.

/plan I need to add a user notification system. Users should receive
notifications when events they're interested in are updated. Design
the data model, API endpoints, and implementation plan.

Copilot will outline:

  • What files to create/modify
  • Step-by-step implementation plan
  • Dependencies and order of operations

Review the plan. Challenge it. Then tell it to proceed.

When to use /plan

SituationUse /plan?
Adding a new feature with multiple filesYes
Refactoring across several modulesYes
Building a new project from scratchYes
Fixing a single bugNo — just describe the bug
Adding a one-line config changeNo — just ask

How to review a plan

  1. Does it match your architecture? (right layers, right patterns)
  2. Does it handle errors and edge cases?
  3. Is the order logical? (data model before API, API before UI)
  4. Is anything missing? (tests, validation, error handling)
  5. Is it trying to do too much? (scope creep)

If the plan is wrong, tell it why: “This plan puts validation in the handler. Move it to the service layer. Also, add a step for writing tests.”


6. Prompt Engineering

The specificity spectrum

Level 1 (vague):    "Add authentication"
Level 2 (better):   "Add JWT authentication to the API"
Level 3 (good):     "Add JWT authentication with access tokens (15min expiry)
                     and refresh tokens (7d expiry). Store refresh tokens in
                     the database. Add middleware that validates the access
                     token on protected routes."
Level 4 (expert):   "Add JWT authentication following our existing middleware
                     pattern in src/middleware/. Use the jsonwebtoken library.
                     Access tokens: 15min, RS256. Refresh tokens: 7d, stored in
                     the refresh_tokens table. Add POST /auth/login,
                     POST /auth/refresh, POST /auth/logout endpoints.
                     Protect all /api/* routes. Include unit tests for the
                     auth service using our existing test patterns in __tests__/."

BAD vs GOOD prompts

BAD:  "Write tests"
GOOD: "Write unit tests for the UserService.createUser method. Test:
       - successful creation with valid input
       - validation error for missing email
       - duplicate email returns conflict error
       - database error is propagated correctly
       Use the same testing pattern as in order.service.test.ts"
BAD:  "Fix this bug"
GOOD: "This endpoint returns 500 when the user doesn't exist. It should
       return 404 with an error message. The bug is in src/handlers/user.ts.
       The service throws a NotFoundError but the handler doesn't catch it."
BAD:  "Refactor this"
GOOD: "Refactor this function to separate the HTTP concerns (request parsing,
       response formatting) from the business logic (validation, data
       transformation). The business logic should move to a service class
       that can be tested independently."

Give context, get better results

"Look at how we handle errors in src/services/order.service.ts.
 Apply the same pattern to this new user service."

"Our API follows REST conventions: POST returns 201, GET returns 200,
 not-found returns 404 with {error: message}. Follow these conventions."

"Check the existing tests in __tests__/services/ to match our testing style."

7. Agent Mode Best Practices

Scope your tasks

BAD:  "Build my entire application"
GOOD: "Add the user registration endpoint with validation, database storage,
       and unit tests. Follow the patterns in the existing order endpoint."

Agent mode works best with tasks that are:

  • Specific: clear outcome, defined scope
  • Bounded: one feature, one fix, one module
  • Verifiable: you can tell if it worked (tests pass, endpoint works)

The autonomy trap

Agent mode can run, modify files, execute commands, and iterate on errors. This is powerful but dangerous if you give it too much scope.

Signs you’ve given too broad a prompt:

  • Agent creates files you didn’t expect
  • Agent modifies code outside the scope you intended
  • Agent runs in circles fixing one error and creating another
  • Agent’s changes don’t match your architecture

How to recover:

  1. Stop the agent (click Stop)
  2. Undo changes: git checkout . or review the diff carefully
  3. Break the task into smaller pieces
  4. Re-prompt with tighter scope

Review diffs, always

Agent mode generates diffs for you to review before accepting. Read them. Every time.

  • Does the change match what you asked for?
  • Does it follow your project’s patterns?
  • Are there any changes outside the scope you requested?
  • Does the test coverage make sense?

Use Git as your safety net

Before starting an Agent mode session:

  1. Commit your current work
  2. Let the agent work
  3. Review the diff (git diff)
  4. If it’s good, commit
  5. If it’s bad, git checkout . and re-prompt

8. MCP Configuration

MCP (Model Context Protocol) extends Copilot with external tools and data sources.

Configuration file: .vscode/mcp.json

{
  "servers": {
    "my-server-name": {
      "type": "stdio",
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-filesystem", "/path/to/dir"]
    }
  }
}

Useful MCP servers

ServerPurpose
@modelcontextprotocol/server-filesystemRead/write files outside workspace
@modelcontextprotocol/server-githubAccess GitHub repos, issues, PRs
@modelcontextprotocol/server-postgresQuery PostgreSQL databases
@modelcontextprotocol/server-fetchFetch URLs and web content
@modelcontextprotocol/server-memoryPersistent key-value memory

When MCP helps

  • Agent mode needs to access external APIs or databases
  • You want Copilot to read documentation from a URL
  • You need to interact with tools outside VS Code

9. Anti-Patterns — Don’t Do These

Don’tDo Instead
Accept generated code without reading itRead every line. Ask “why?” for anything unclear.
Use Agent mode for everythingMatch the mode to the task (see Mode Selection Guide).
Give Agent mode unbounded scopeBreak tasks into specific, verifiable pieces.
Skip reviewing Agent mode diffsRead every diff. Check for out-of-scope changes.
Prompt “fix it” when something breaksPaste the error, ask for explanation first, then fix.
Ignore custom instructions setupSet up copilot-instructions.md on day 1. It shapes every response.
Let Agent mode run without Git safetyCommit before Agent sessions. Use git diff to review.
Copy-paste from AI into code you don’t understandIf you can’t explain it, don’t ship it.
Ask “write tests” without specifying what to testSpecify test cases: happy path, edge cases, error cases.
Ignore when AI contradicts itselfFlag it: “Earlier you said X, now you’re saying Y. Which is correct?”
Use only one model for everythingTry different models for different tasks. Compare results.
Skip .instructions.md for specialized directoriesScoped instructions dramatically improve output quality.

Quick Reference

I want to…How
Get code as I typeJust type — inline completions appear automatically
Accept a suggestionTab
See alternative suggestionsAlt+] / Alt+[
Accept just one wordCmd+→ (Mac) / Ctrl+→
Ask about my projectChat panel → Ask mode → @workspace + question
Edit code in-placeSelect code → Cmd+I → describe the change
Edit multiple filesChat panel → Edit mode → describe the change
Build a feature autonomouslyChat panel → Agent mode → describe the feature
Plan before buildingAgent mode → /plan + describe the feature
Explain codeSelect code → /explain in Chat
Fix an errorClick lightbulb on error → “Fix using Copilot”
Generate testsSelect code → /tests in Chat
Generate docsSelect code → /doc in Chat
Reference a file in ChatType #file: + filename
Use current selection in ChatType #selection
Search entire codebaseUse #codebase in Chat
Switch AI modelClick model name in Chat panel
Generate a commit messageClick sparkle icon in Source Control
Set up project instructionsCreate .github/copilot-instructions.md
Create scoped instructionsCreate .instructions.md with applyTo front matter
Configure Agent mode rulesCreate AGENTS.md in project root
Create a reusable promptCreate a .prompt.md file, use #prompt:name
Add an MCP serverEdit .vscode/mcp.json