Advanced

Advanced Features

Unlock the full power of Copilot Chat with custom instructions, multi-model support, agent mode, Copilot Edits, vision capabilities, and extensibility.

Custom Instructions

Custom instructions let you define project-specific guidelines that Copilot Chat follows in every conversation. Create a file at .github/copilot-instructions.md in your repository root.

.github/copilot-instructions.md
# Copilot Custom Instructions

## Code Style
- Use TypeScript with strict mode enabled
- Prefer functional programming patterns
- Use named exports, not default exports
- All functions must have JSDoc comments
- Use Zod for runtime validation

## Architecture
- Follow the repository pattern for data access
- Use dependency injection via constructor parameters
- Keep controllers thin; business logic belongs in services
- Use Result types instead of throwing exceptions

## Testing
- Use Vitest for unit tests
- Use Testing Library for component tests
- Aim for 80% code coverage minimum
- Mock external dependencies, not internal modules

## Naming Conventions
- Files: kebab-case (user-service.ts)
- Classes: PascalCase (UserService)
- Functions/variables: camelCase (getUserById)
- Constants: UPPER_SNAKE_CASE (MAX_RETRY_COUNT)
- Types/interfaces: PascalCase with descriptive names
Team alignment: Custom instructions are checked into your repository, so every team member gets the same Copilot behavior. This ensures consistent code style and architectural patterns across the team.

Chat Participants and Extensions

Beyond the built-in participants (@workspace, @vscode, @terminal), Copilot Chat supports third-party extensions that add new participants with specialized capabilities.

Participant Source Purpose
@workspace Built-in Project-wide code understanding and search
@vscode Built-in VS Code editor help and configuration
@terminal Built-in Terminal errors and shell commands
@github Extension GitHub issues, PRs, repos, and actions
@azure Extension Azure cloud resources and deployment
@docker Extension Docker containers and compose files
Extension Participant Examples
// GitHub integration
@github What are the open issues assigned to me?

// Azure deployment
@azure How do I deploy this app to Azure App Service?

// Docker help
@docker Create a multi-stage Dockerfile for this
Node.js application

Vision (Image Understanding)

Copilot Chat can analyze images you share in the chat. This is particularly useful for implementing designs, debugging visual issues, and understanding diagrams.

Vision Use Cases
// Drag and drop a screenshot into the chat

// Implement a design from a mockup
Implement this UI design as a React component using
Tailwind CSS. Match the colors and layout exactly.

// Debug visual issues
Why does my component look like this? The button
should be aligned to the right.

// Understand diagrams
Explain this architecture diagram and suggest how
to implement it in our project.
💡
Image formats: Copilot Chat supports PNG, JPEG, GIF, and WebP images. You can paste screenshots from your clipboard or drag and drop image files directly into the chat panel.

Multi-Model Support

Copilot Chat supports multiple AI models, allowing you to choose the best model for each task. You can switch models using the model picker in the chat panel.

Model Strengths Best For
GPT-4o Fast, good all-around performance General coding tasks, quick questions
Claude 3.5 Sonnet Strong reasoning, careful analysis Complex debugging, architecture decisions
o1-preview Deep reasoning, step-by-step thinking Algorithm design, complex problem solving
o1-mini Fast reasoning model Code generation, straightforward logic
Model selection strategy: Use GPT-4o for everyday tasks, switch to Claude 3.5 Sonnet or o1-preview when you need deeper analysis or are debugging complex issues. The model picker is at the bottom of the chat input area.

Agent Mode

Agent mode transforms Copilot Chat from a Q&A tool into an autonomous coding agent. In agent mode, Copilot can plan multi-step tasks, read and write files, run terminal commands, and iterate on solutions.

Agent Mode Example
// Enable agent mode by selecting it in the chat mode picker
// Then give it a complex, multi-step task:

Add a dark mode toggle to the application. This should:
1. Create a ThemeContext with React context
2. Add a toggle button in the header
3. Update the CSS to support dark mode variables
4. Persist the preference in localStorage
5. Respect the system preference on first visit

In agent mode, Copilot will:

  • Analyze your project structure to understand the codebase
  • Create a plan with multiple steps
  • Create and modify multiple files
  • Run commands (like npm install) if needed
  • Show a diff preview for each change and ask for approval
Review each step: Agent mode asks for approval before applying changes. Always review the proposed edits carefully, especially when the agent modifies multiple files or runs terminal commands.

Copilot Edits (Multi-File Editing)

Copilot Edits is a dedicated mode for making changes across multiple files simultaneously. Open it with Ctrl+Shift+I and select the "Edits" mode.

  1. Add Working Set Files

    Select the files you want Copilot to consider and potentially modify. Click "Add Files" or drag files into the working set.

  2. Describe the Change

    Write a natural language description of what you want to change across those files.

  3. Review Diffs

    Copilot shows a diff for each modified file. Accept or reject changes file by file.

  4. Iterate

    If the changes are not quite right, provide feedback and Copilot will adjust.

Copilot Edits Example
// Working set: user.model.ts, user.service.ts,
// user.controller.ts, user.routes.ts

Rename the "username" field to "displayName" across
all files. Update the validation schema, database
queries, API responses, and route handlers accordingly.

Custom Slash Commands

You can create custom slash commands by defining prompt files in your project. These are reusable prompts that your whole team can use.

.github/copilot-prompts/review.md
# Code Review Prompt

Review the selected code for:
1. **Correctness** - Logic errors, edge cases, off-by-one
2. **Performance** - Time/space complexity, unnecessary operations
3. **Security** - Input validation, injection, auth issues
4. **Readability** - Naming, comments, code organization
5. **Testing** - Missing test cases, untested paths

For each issue found, provide:
- Severity (critical, warning, suggestion)
- Line reference
- Explanation
- Suggested fix

After creating this file, you can use /review as a custom slash command in the chat panel.

Context Management Strategies

Advanced users carefully manage the context provided to Copilot Chat to get better results. Here are key strategies:

Strategy How When
Scoped context Select only the relevant code before chatting When asking about a specific function or block
Multi-file context Use #file to reference multiple related files When the question spans across modules
Fresh context Use /clear to start a new conversation When switching topics or the chat has drifted
Project context Use @workspace for broad questions Architecture questions, finding code, project overview
Explicit context Paste relevant code, config, or errors directly When auto-context is not picking up what you need

💡 Try It: Create Custom Instructions

Create a .github/copilot-instructions.md file in your project with guidelines specific to your codebase. Include your preferred code style, architecture patterns, testing approach, and naming conventions. Then test it by asking Copilot to generate code and see if it follows your instructions.

Custom instructions are one of the most impactful features for teams. They ensure Copilot generates code that fits your project's patterns from the start, reducing review cycles.