Skip to content

Lesson 10 of 40AI coding tools

GitHub Copilot in VS Code

Use Copilot's suggestions, chat and agents in VS Code, give it the right context and instructions, and know when to reach for Claude Code instead.

15 min read0/4 questions

GitHub Copilot is the AI assistant built into VS Code. It works at three speeds: suggestions that appear as you type, a chat you can ask questions in, and agents that plan and make changes across many files. On GitHub itself it can also review pull requests and work on issues by itself. This lesson walks through each layer, how to give Copilot the right context, how to customise it for your project, and how it fits alongside Claude Code. Copilot changes often (features get renamed, shortcuts move), so treat code.visualstudio.com/docs/copilot as the source of truth for current details.

Getting started

Copilot Chat has been built into VS Code since version 1.116 (April 2026), so on a current VS Code there is nothing to install. To sign in, hover over the Copilot icon in the Status Bar (the bar along the bottom of the window), choose Use AI Features, and pick a sign-in method. Without a subscription you get Copilot Free, which includes a monthly allowance of completions and chat. Free and paid tiers exist for individuals and organizations; check GitHub's site for what each includes.

Layer 1: suggestions as you type

Inline suggestions appear as grey "ghost text" ahead of your cursor. Copilot predicts what you are about to type, from a few characters to a whole function.

Next edit suggestions (NES) go one step further. After you make a change, Copilot predicts the next edit you will need somewhere else, like updating the other three places that use a variable you just renamed. An arrow appears in the gutter (the margin beside the line numbers) to show where.

ActionKey
Accept a suggestionTab
Accept the next word onlyCmd+Right
DismissEsc
Jump to a next edit suggestion, then acceptTab, then Tab
Open the Chat viewCtrl+Cmd+I
Inline chatCmd+I

Accepting word by word is underrated. When a suggestion starts well and then drifts, take the good part and type the rest yourself.

Quick check
You rename a function parameter from qty to quantity. An arrow appears in the gutter a few lines down. What is it?
Need a nudge? A hint rules out a wrong answer.

Layer 2: chat

There are three places to chat:

  • The Chat view, a panel at the side for longer conversations (Ctrl+Cmd+I on macOS, Ctrl+Alt+I on Windows).
  • Inline chat (Cmd+I or Ctrl+I), which opens right in the editor at your cursor, for a quick change to the code in front of you. It works in the terminal too, which is handy for "what command does X?".
  • Quick Chat, a small floating box for a fast question without opening the panel.

Slash commands give common requests a shortcut: /explain explains code, /fix proposes a fix, /tests writes tests, /plan starts a plan, /init generates a project instructions file, /models opens the model picker, and /compact and /clear manage the conversation.

Layer 3: agents

The Chat view has built-in agents (earlier versions called these chat modes). You pick one in the chat input:

AgentWhat it doesChanges code?
AskAnswers and explainsNo
PlanResearches the codebase and proposes a plan for you to approveNo
AgentWorks across many files, edits, runs terminal commands within your approval levelYes

The rhythm is the same as with any coding agent: understand with Ask, design with Plan, build with Agent, then read the diff. If you see older tutorials that mention an "Edit mode" or chat participants like @workspace, they describe earlier versions.

Match the pairs0/3 matched

Match each task to the built-in agent that fits.

Choose an item, then its match on the other side.

Giving Copilot context

Copilot answers better when it sees the right code. In the chat input, type # to attach context:

  • #codebase lets Copilot search the whole project for what is relevant.
  • #selection attaches the code you have selected.
  • A file by name, like #checkout.ts.
  • Folders, symbols, terminal output, source control changes and tools are also available from the # menu.

You can also drag files from the Explorer onto the chat, or use the Add Context button. As with Claude Code, point at specific files rather than pasting large blocks of code.

Quick check
You want Copilot to answer a question using code from across your whole project. What do you type in the chat?
Need a nudge? A hint rules out a wrong answer.

Customising Copilot for your project

You do not want to repeat "we use pytest, not unittest" in every chat. Copilot reads instruction files from your repo automatically.

A repo customised for Copilot
  • my-app/
  • AGENTS.mdread by default; shared with other AI tools
  • .github/
  • copilot-instructions.mdrepo-wide instructions
  • instructions/
  • python.instructions.mdapplyTo: "**/*.py"
  • prompts/
  • new-endpoint.prompt.mdrun as /new-endpoint
  • agents/
  • reviewer.agent.mda custom agent
  • .vscode/
  • mcp.jsonMCP servers for this workspace
  • src/
  • .github/copilot-instructions.md holds repo-wide rules: commands, conventions, things to avoid.
  • .github/instructions/*.instructions.md files hold rules for certain paths. Frontmatter like applyTo: "**/*.py" means the rules only apply to Python files.
  • AGENTS.md at the repo root is supported and on by default, and CLAUDE.md is read too. One well-kept instructions file can serve both Copilot and Claude Code.
  • Prompt files in .github/prompts/*.prompt.md are reusable prompts. new-endpoint.prompt.md runs as /new-endpoint.
  • Custom agents in .github/agents/*.agent.md have frontmatter with a name, description and the tools they may use. Agent skills and hooks also exist; see the docs.
.github/instructions/python.instructions.md
---
applyTo: "**/*.py"
---
- Use pytest for tests; put them in tests/ mirroring src/.
- Type-hint every public function.
- Use pathlib, not os.path.

Which file should a rule go in? Ask who needs it and when. A rule every request should follow belongs in the repo-wide file. A rule for one language or folder belongs in a path-specific file, so it does not clutter unrelated requests. A task you repeat every week belongs in a prompt file.

Quick check
Your team wants Copilot to always use pytest fixtures, but only when it works on Python files. Where does that rule go?
Need a nudge? A hint rules out a wrong answer.

The Context Engineering lesson covers what makes these files good.

Models and MCP

The chat input has a model picker (also /models), including an Auto option that chooses for you. Claude models are available alongside OpenAI and Google models. Which ones you see depends on your plan, and organization admins can restrict them. You can also bring your own API key.

Copilot can use MCP servers, plug-ins that give it extra tools like querying a database or reading tickets (the MCP and Tools lesson explains MCP). Workspace servers go in .vscode/mcp.json:

.vscode/mcp.json
{
  "servers": {
    "my-server": {
      "type": "stdio",
      "command": "npx",
      "args": ["example-mcp-server"]
    }
  }
}

Replace example-mcp-server with the package name and arguments from the server's own docs. A remote server uses "type": "http" with a "url" instead.

Copilot on GitHub

Two features work on github.com rather than in the editor:

Copilot cloud agent and code review
YouGitHubCopilotassign issue to Copilotissue + repoopens a pull requestPR comment: also handle nullsadd Copilot as reviewer

The cloud agent (formerly called the coding agent) picks up an issue you assign to it.

1/5

Copilot or Claude Code?

You do not have to choose. They coexist in the same editor and can read the same AGENTS.md or CLAUDE.md. A practical split:

Copilot shines atClaude Code shines at
Suggestions while you type, word by wordLong, multi-step tasks driven from a goal
Quick inline edits with Cmd+I / Ctrl+IFine-grained permission rules and modes
Issue to PR on GitHub with the cloud agentScripting with claude -p, hooks, subagents
Switching between many vendors' modelsWorking the same way in terminal, IDE and CI

A common setup: Copilot for completions and quick questions, an agent (Copilot's Agent or Claude Code) for bigger changes, and one shared instructions file so both follow the same rules.

Key terms
inline suggestion
Grey ghost text Copilot proposes as you type; Tab accepts it.
next edit suggestion
A predicted follow-on edit elsewhere in the file, shown by an arrow in the gutter.
inline chat
A chat box that opens at your cursor in the editor or terminal for a quick change.
Agent (Copilot)
The built-in agent that edits across files and runs commands with your approval.
custom instructions
Repo files like copilot-instructions.md that Copilot reads automatically for every request.
prompt file
A reusable prompt in .github/prompts that runs as a slash command.
cloud agent
Copilot working on an assigned GitHub issue in a cloud environment and opening a PR.