How to Use GitHub Copilot Chat: AI Pair Programming in VS Code (2026)

GitHub Copilot Chat transforms VS Code into an AI pair programming environment. Beyond simple code completion, Copilot Chat lets you have conversations about your code, generate tests, fix bugs, explain complex logic, and refactor with natural language instructions — all without leaving your editor.

This tutorial covers everything from basic chat interactions to advanced slash commands and workspace-aware queries that make Copilot Chat an indispensable coding companion.

TL;DR — Quick Start

  1. Install the GitHub Copilot extension in VS Code
  2. Open chat: Click the chat icon in the sidebar or press Ctrl+Shift+I
  3. Ask anything: “Explain this function” or “Write tests for this code”
  4. Use slash commands: /fix, /tests, /explain, /doc for quick actions
  5. Use @workspace for project-wide questions

Prerequisites

  • GitHub Copilot subscription: Individual ($10/mo), Business ($19/user/mo), or Enterprise ($39/user/mo)
  • VS Code 1.85 or later
  • GitHub Copilot and GitHub Copilot Chat extensions installed

Getting Started

Step 1: Install Extensions

In VS Code:

  1. Open Extensions (Ctrl+Shift+X)
  2. Search “GitHub Copilot”
  3. Install both GitHub Copilot and GitHub Copilot Chat
  4. Sign in with your GitHub account

Step 2: Open Copilot Chat

Three ways to open chat:

  • Sidebar: Click the Copilot icon in the Activity Bar
  • Inline: Press Ctrl+I (Cmd+I on Mac) for inline chat
  • Quick Chat: Press Ctrl+Shift+I for a quick chat popup

Step 3: Start a Conversation

Select some code and ask:

  • “What does this function do?”
  • “How can I optimize this?”
  • “Are there any bugs in this code?”

Chat Modes

Sidebar Chat

A persistent conversation panel. Best for:

  • Extended discussions about architecture
  • Multi-step code generation
  • Exploring different approaches
  • Learning and asking questions

Inline Chat (Ctrl+I)

Opens directly in the editor at your cursor position. Best for:

  • Quick code modifications
  • Generating code at a specific location
  • Inline explanations
  • Fast refactoring

Quick Chat (Ctrl+Shift+I)

A lightweight popup for quick questions. Best for:

  • One-off questions
  • Quick syntax lookups
  • Simple code generation
  • Fast explanations

Slash Commands

Slash commands are shortcuts for common actions:

Command Description Example
`/explain` Explain selected code Select code → `/explain`
`/fix` Fix bugs in selected code Select buggy code → `/fix`
`/tests` Generate unit tests Select function → `/tests`
`/doc` Add documentation Select function → `/doc`
`/new` Create new project scaffold `/new express api with typescript`
`/newNotebook` Create Jupyter notebook `/newNotebook data analysis with pandas`
`/clear` Clear chat history `/clear`

Using Slash Commands Effectively

/explain — Understanding complex code:


Select a complex regex or algorithm → /explain

Copilot breaks down the code step by step, explaining what each part does and why.

/fix — Bug fixing:


Select code with an error → /fix the null reference error

Copilot identifies the bug and provides a corrected version with explanation.

/tests — Test generation:


Select a function → /tests using jest with edge cases

Generates comprehensive test suites including edge cases, error scenarios, and happy paths.

/doc — Documentation:


Select a function → /doc

Generates JSDoc/docstring with parameter descriptions, return types, and usage examples.

Context Providers (@mentions)

Use @ mentions to give Copilot specific context:

Provider What It Does Example
`@workspace` Searches your entire project “How does auth work in @workspace?”
`@vscode` VS Code settings and features “@vscode how to change font size”
`@terminal` Terminal content and commands “@terminal explain the last error”
`#file` Specific file context “Explain #file:auth.ts”
`#selection` Currently selected code “/fix #selection”
`#editor` Current editor content “Refactor #editor”

@workspace — Project-Wide Intelligence

@workspace is one of the most powerful features. It indexes your project and answers questions about your entire codebase:

  • “@workspace where is the database connection configured?”
  • “@workspace what API endpoints are defined?”
  • “@workspace how does the error handling middleware work?”
  • “@workspace find all uses of the UserService class”

Combining Context Providers


@workspace how does #file:auth.ts relate to the user registration flow?

This tells Copilot to search the workspace for context while focusing on a specific file.

Practical Use Cases

Code Explanation

Select unfamiliar code and ask:

  • “What does this regex pattern match?”
  • “Why is this using a WeakMap instead of a Map?”
  • “What’s the time complexity of this algorithm?”

Bug Fixing

When you encounter an error:

  1. Select the problematic code
  2. Use /fix or describe the issue: “This throws a TypeError when the array is empty”
  3. Review the suggested fix
  4. Click “Apply” to implement it

Code Generation

Ask Copilot to write code:

  • “Write a debounce function with TypeScript generics”
  • “Create a React hook for infinite scroll pagination”
  • “Generate a SQL migration to add a role column to the users table”

Refactoring

Select code and request improvements:

  • “Refactor to use async/await instead of callbacks”
  • “Convert this to use the Strategy pattern”
  • “Extract the validation logic into a separate function”
  • “Make this function pure by removing side effects”

Code Review

Paste or select code and ask:

  • “Review this code for potential issues”
  • “Are there any security vulnerabilities here?”
  • “What edge cases am I missing?”
  • “How would you improve the error handling?”

Learning

Use Copilot as a tutor:

  • “Explain the difference between useMemo and useCallback
  • “When should I use a linked list instead of an array?”
  • “What’s the best practice for handling concurrent database writes?”

Advanced Techniques

Multi-Turn Conversations

Build on previous answers:


You: "Create a User class with name and email"
Copilot: [generates class]
You: "Add input validation with descriptive errors"
Copilot: [updates class with validation]
You: "Now add a static method to create from JSON"
Copilot: [adds the method, aware of the full context]

Using Chat for Architecture


@workspace I need to add a caching layer. Based on the current architecture, what approach would you recommend? Consider the existing database patterns and API structure.

Copilot analyzes your project structure and recommends an approach consistent with your codebase.

Test-Driven Development


You: "Write tests for a function that calculates shipping cost based on weight, distance, and express delivery option"
Copilot: [generates test suite]
You: "Now write the implementation that passes all these tests"
Copilot: [generates the function]

Commit Messages and Documentation


@terminal summarize the changes I've made for a commit message

@workspace generate a README for this project based on the codebase structure

Copilot Chat vs Competitors

Feature Copilot Chat Cursor AI Windsurf
Editor VS Code extension Standalone Standalone
Inline editing Ctrl+I Cmd+K Cmd+K
Multi-file edits Limited Composer Cascade
Workspace search @workspace @codebase Automatic
Slash commands 7 commands Limited Limited
Terminal integration @terminal Cmd+K terminal Automatic
Price $10/mo $20/mo $15/mo
Model GPT-4o Multiple Multiple

Configuration Tips

Customize Chat Behavior

In VS Code settings (settings.json):


{
  "github.copilot.chat.localeOverride": "en",
  "github.copilot.chat.useProjectTemplates": true,
  "github.copilot.chat.scopeSelection": true
}

Custom Instructions

Create a .github/copilot-instructions.md file in your project:


## Project Context
This is a Next.js 15 project using App Router with TypeScript.

## Coding Standards
- Use functional components with hooks
- Prefer server components unless client interaction is needed
- Use Zod for runtime validation
- Write tests with Vitest and React Testing Library

Copilot reads this file to provide project-specific suggestions.

Keyboard Shortcuts

Shortcut Action
Ctrl+Shift+I Quick chat
Ctrl+I Inline chat
Ctrl+Enter Send message
Ctrl+/ Toggle sidebar chat
Esc Close inline chat
Tab Accept suggestion

Troubleshooting

Chat Not Responding

  • Verify your Copilot subscription is active
  • Check internet connection
  • Reload VS Code: Ctrl+Shift+P → “Reload Window”
  • Sign out and back into GitHub

Inaccurate Responses

  • Provide more context with @workspace or #file
  • Select relevant code before asking
  • Be more specific in your question
  • Use slash commands for structured interactions

Extensions Conflicting

  • Disable other AI extensions temporarily
  • Check for keybinding conflicts
  • Update all extensions to latest versions

FAQ

Is Copilot Chat included with GitHub Copilot?

Yes. Copilot Chat is included in all GitHub Copilot plans at no additional cost. The Individual plan is $10/month, Business is $19/user/month, and Enterprise is $39/user/month.

Which AI model does Copilot Chat use?

Copilot Chat uses GPT-4o by default. GitHub periodically upgrades the underlying model. Enterprise users may have access to additional model options.

Can Copilot Chat modify my files directly?

In inline mode (Ctrl+I), Copilot can suggest edits that you accept or reject in a diff view. In sidebar chat, it shows code suggestions that you can copy or click “Apply” to insert. It never modifies files without your confirmation.

Does Copilot Chat send my code to the cloud?

Code is sent to GitHub’s servers for processing. GitHub Copilot Business and Enterprise plans include data privacy commitments — your code is not used to train models. Individual plan users should review GitHub’s data usage policy.

Can I use Copilot Chat in other editors?

Yes. Copilot Chat is available in VS Code, Visual Studio, JetBrains IDEs (IntelliJ, PyCharm, etc.), and Neovim. The feature set varies slightly by editor, with VS Code having the most complete implementation.

Conclusion

GitHub Copilot Chat turns VS Code into an AI-powered development environment. The combination of inline editing, slash commands, and workspace-aware conversations covers nearly every coding task — from writing new code to understanding legacy systems, debugging issues, and generating tests.

Start with /explain and /fix on your existing code to see immediate value. Graduate to @workspace queries for project-wide understanding, and use inline chat (Ctrl+I) for quick, context-aware edits. The more you use it, the more natural the interaction becomes.

Ready to get started?

Try GitHub Copilot Free →

Find the Perfect AI Tool for Your Needs

Compare pricing, features, and reviews of 50+ AI tools

Browse All AI Tools →

Get Weekly AI Tool Updates

Join 1,000+ professionals. Free AI tools cheatsheet included.

Similar Posts