How to Use VS Code Agent Mode (2026)
Master the built-in AI agent in Visual Studio Code
Start Building with Hypereal
Access Kling, Flux, Sora, Veo & more through a single API. Free credits to start, scale to millions.
No credit card required • 100k+ developers • Enterprise ready
How to Use VS Code Agent Mode (2026)
VS Code Agent Mode transforms GitHub Copilot from an inline autocomplete tool into a full autonomous coding agent. Instead of suggesting one line at a time, Agent Mode can plan multi-step tasks, edit multiple files, run terminal commands, fix errors iteratively, and use external tools through MCP -- all from a single natural language prompt.
This guide covers how to enable Agent Mode, configure it, and use it effectively for real development work.
What Is VS Code Agent Mode?
Agent Mode is a feature of GitHub Copilot Chat in VS Code that gives the AI assistant autonomous capabilities. When you switch from "Ask" or "Edit" mode to "Agent" mode in the Copilot Chat panel, the AI gains the ability to:
- Plan and execute multi-step coding tasks
- Create, edit, and delete files across your project
- Run terminal commands and react to output
- Automatically fix linting and compilation errors
- Use MCP tools to interact with external services
- Iterate on its own work until the task is complete
Agent Mode vs. Other Copilot Modes
| Feature | Ask Mode | Edit Mode | Agent Mode |
|---|---|---|---|
| Answer questions | Yes | No | Yes |
| Edit single file | No | Yes | Yes |
| Edit multiple files | No | Yes | Yes |
| Run terminal commands | No | No | Yes |
| Auto-fix errors | No | No | Yes |
| Use MCP tools | No | No | Yes |
| Iterate autonomously | No | No | Yes |
| File creation/deletion | No | Limited | Yes |
Prerequisites
| Requirement | Details |
|---|---|
| VS Code | Version 1.99 or higher (Insiders recommended for latest features) |
| GitHub Copilot subscription | Copilot Individual, Business, or Enterprise |
| GitHub Copilot extension | Latest version from the VS Code marketplace |
| GitHub Copilot Chat extension | Latest version (often bundled with Copilot) |
Step 1: Enable Agent Mode
Agent Mode is available by default in VS Code 1.99+. To use it:
- Open the Copilot Chat panel by pressing
Ctrl+Shift+I(orCmd+Shift+Ion macOS), or click the Copilot icon in the activity bar. - At the top of the chat panel, you will see a mode selector dropdown.
- Switch from "Ask" or "Edit" to "Agent".
If you do not see the Agent option, make sure you are on the latest VS Code version:
# Check your VS Code version
code --version
# Update VS Code (macOS via Homebrew)
brew update && brew upgrade --cask visual-studio-code
Step 2: Choose Your Model
Agent Mode supports multiple LLM providers. Click the model selector in the Copilot Chat panel to choose:
| Model | Best For | Speed | Quality |
|---|---|---|---|
| GPT-4o | General coding tasks | Fast | High |
| Claude Sonnet 4 | Complex reasoning, refactoring | Fast | Very High |
| Claude Opus 4 | Hardest problems, architecture | Slower | Highest |
| Gemini 2.5 Pro | Large codebases, long context | Fast | High |
| o3-mini | Quick edits, simple tasks | Fastest | Good |
You can switch models mid-conversation depending on the task complexity.
Step 3: Your First Agent Task
Type a natural language request in the Agent Mode chat. Start with something practical:
Create a REST API endpoint for user registration. It should:
- Accept POST requests at /api/auth/register
- Validate email format and password strength
- Hash the password with bcrypt
- Store the user in the database
- Return a JWT token
- Include input validation middleware
- Add error handling for duplicate emails
Agent Mode will:
- Analyze your existing project structure and tech stack.
- Create or modify multiple files (route, controller, middleware, model).
- Install any missing npm packages by running terminal commands.
- Check for TypeScript or linting errors and fix them automatically.
- Present all changes for your review.
You can accept individual changes, reject them, or ask the agent to revise.
Step 4: Use Participants and Context
Agent Mode supports @ participants and # context references to provide more targeted assistance:
Participants
| Participant | Description |
|---|---|
@workspace |
Access to your full project context |
@vscode |
VS Code settings and configuration help |
@terminal |
Terminal output and command history |
Context References
Look at #file:src/lib/database.ts and #file:src/types/user.ts
and create a new user service that handles CRUD operations.
Use #file:, #selection, or #terminalLastCommand to give the agent specific context.
Step 5: Configure MCP Servers
Agent Mode supports MCP (Model Context Protocol) servers, which extend the agent's capabilities with external tools. Configure them in your VS Code settings or in a .vscode/mcp.json file:
// .vscode/mcp.json
{
"servers": {
"github": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-github"],
"env": {
"GITHUB_PERSONAL_ACCESS_TOKEN": "ghp_xxxxxxxxxxxx"
}
},
"playwright": {
"command": "npx",
"args": ["@playwright/mcp@latest"]
},
"postgres": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-postgres"],
"env": {
"POSTGRES_CONNECTION_STRING": "postgresql://user:pass@localhost:5432/mydb"
}
}
}
}
With MCP servers connected, Agent Mode can:
- Create GitHub issues and pull requests
- Query your database directly
- Browse web pages and take screenshots
- Interact with any MCP-compatible service
Step 6: Use Custom Instructions
Create a .github/copilot-instructions.md file in your repository root to give Agent Mode persistent instructions:
# Coding Standards
- Use TypeScript strict mode for all files
- Use functional React components with hooks
- Style with Tailwind CSS utility classes
- Write unit tests with Vitest for all new functions
- Use Zod for runtime type validation
- Follow the existing project structure in src/
# Naming Conventions
- Components: PascalCase (UserProfile.tsx)
- Utilities: camelCase (formatDate.ts)
- Constants: UPPER_SNAKE_CASE
- Types/Interfaces: PascalCase with T or I prefix
# Error Handling
- Always use try/catch for async operations
- Return structured error responses from API endpoints
- Log errors with the project's logger utility
Agent Mode reads this file automatically and follows the instructions for every task.
Practical Workflows
Bug Fix Workflow
I'm getting this TypeScript error:
Type 'string | undefined' is not assignable to type 'string'.
It's happening in src/components/UserCard.tsx on line 42.
Fix the error and add proper null handling throughout the component.
The agent will read the file, identify the issue, apply a fix, check for similar issues in the same file, and verify the fix compiles.
Test Generation
Generate comprehensive unit tests for src/lib/validators.ts.
Cover all edge cases including:
- Empty inputs
- Invalid formats
- Boundary values
- Special characters
- Unicode strings
Refactoring
Refactor the authentication module:
1. Move all auth logic from src/pages/api/auth/ into a service layer at src/services/auth/
2. Create a clean interface for the auth service
3. Update all imports across the project
4. Make sure all existing tests still pass
The agent handles the entire refactoring, including updating imports in files you did not even mention.
Documentation
Add JSDoc comments to every exported function in src/lib/.
Include @param, @returns, and @example tags.
Tips for Getting the Best Results
Be specific about what you want. Instead of "make the code better," say "refactor the UserService class to use dependency injection and add error handling to all database calls."
Reference files explicitly. Use
#file:path/to/fileto point the agent to relevant code.Let the agent iterate. Agent Mode can fix its own mistakes. If the first attempt has errors, it will detect them and try again automatically.
Use checkpoints. After a series of changes, commit your code. If the agent makes unwanted changes later, you can easily revert.
Switch models for different tasks. Use a fast model like GPT-4o for simple edits and Claude Opus for complex architectural tasks.
Agent Mode vs. Other AI Coding Tools
| Feature | VS Code Agent Mode | Cursor Composer | Cline | Claude Code |
|---|---|---|---|---|
| Multi-file editing | Yes | Yes | Yes | Yes |
| Terminal commands | Yes | Yes | Yes | Yes |
| MCP support | Yes | Yes | Yes | Yes |
| Built-in to editor | Yes | Yes (own editor) | Extension | CLI |
| Model selection | Multiple | Multiple | Multiple | Claude only |
| Free tier | Limited (Copilot Free) | No | Yes (BYO key) | No |
| Auto-error fixing | Yes | Yes | No | Yes |
Troubleshooting
Agent Mode option is not visible: Update VS Code to version 1.99 or higher. Also update the GitHub Copilot and Copilot Chat extensions to their latest versions.
Agent is slow or unresponsive: Switch to a faster model like GPT-4o or o3-mini for simple tasks. Claude Opus is powerful but slower.
Agent makes incorrect changes:
Provide more context by referencing specific files. Add a .github/copilot-instructions.md file with your coding standards.
Terminal commands fail: Make sure the commands the agent wants to run are available in your PATH. Review and approve commands carefully before execution.
MCP servers not showing up:
Check your .vscode/mcp.json syntax. Restart VS Code after adding new MCP servers. Check the Output panel for MCP-related errors.
Wrapping Up
VS Code Agent Mode is one of the most significant upgrades to the Copilot experience. It transforms a code completion tool into an autonomous development partner that can handle complex, multi-step tasks across your entire codebase. Combined with MCP support and custom instructions, it adapts to any project and workflow.
If you are building applications that need AI-generated media -- images, videos, audio, or talking avatars -- check out Hypereal AI for a unified API with pay-as-you-go pricing and fast generation times.
Try Hypereal AI free -- 35 credits, no credit card required.
Related Articles
Start Building Today
Get 35 free credits on signup. No credit card required. Generate your first image in under 5 minutes.
