How to Use GitHub Copilot Agent Mode in VS Code: Autonomous Coding in 2026

Coding Liquids blog cover featuring Sagnik Bhattacharya for How to Use GitHub Copilot Agent Mode in VS Code, showing autonomous AI coding workflow in the editor.
Coding Liquids blog cover featuring Sagnik Bhattacharya for How to Use GitHub Copilot Agent Mode in VS Code, showing autonomous AI coding workflow in the editor.

If you have been using GitHub Copilot for inline completions or quick chat questions, Agent Mode is a fundamentally different experience. It does not just suggest the next line of code. It reads your workspace, creates a plan, writes code across multiple files, runs terminal commands, checks the output, and iterates until the task is done — all from a single natural-language prompt. Think of it less as an autocomplete tool and more as a junior developer who can follow instructions autonomously inside your editor.

I have been using Agent Mode daily for the past several weeks across real projects — a Node.js API, a Flutter mobile app, and a Next.js marketing site. This guide covers everything from enabling it to the specific workflows where it genuinely saves time, along with an honest assessment of where it still falls short. Most coverage of Agent Mode so far has been news articles and feature announcements. This is the practical how-to guide I wish I had when I started.

Prerequisites

Before you can use Agent Mode, you need the following in place:

  1. Visual Studio Code — version 1.99 or later. Agent Mode is built into the Copilot Chat experience in VS Code, and older versions do not include it. Run code --version in your terminal to check. If you are below 1.99, update from code.visualstudio.com.
  2. GitHub Copilot subscription — either Copilot Individual ($19/month), Copilot Business ($39/user/month), or Copilot Enterprise ($39/user/month). Agent Mode is included in all paid tiers. The free Copilot tier does not include Agent Mode at the time of writing.
  3. GitHub Copilot extension — install both "GitHub Copilot" and "GitHub Copilot Chat" from the VS Code marketplace. These are separate extensions. Agent Mode lives inside the Chat extension, but both need to be installed and up to date.
  4. Signed in to GitHub — open the command palette (Ctrl+Shift+P), type "GitHub Copilot: Sign In", and authenticate with your GitHub account that has an active Copilot subscription.

Once all four are in place, you are ready to enable Agent Mode.

Enabling Agent Mode

Agent Mode is accessed through the Copilot Chat panel, not through inline completions. Here is how to find and activate it:

  1. Open the Copilot Chat panel by clicking the Copilot icon in the sidebar or pressing Ctrl+Shift+I (Cmd+Shift+I on Mac).
  2. At the top of the chat panel, you will see a mode selector dropdown. By default, it is set to "Ask" or "Edit". Click the dropdown and select Agent.
  3. You are now in Agent Mode. The chat input will show a slightly different placeholder text indicating that Copilot can now take autonomous actions.

If you do not see the Agent option in the dropdown, check that your VS Code version is 1.99 or later and that your Copilot Chat extension is fully updated. You can also enable it explicitly in settings by opening settings.json and adding:

{
  "chat.agent.enabled": true,
  "github.copilot.chat.agent.enabled": true
}

Once enabled, Agent Mode persists as your selected mode until you switch back. I recommend keeping it as your default — you can always give it a simple question and it will respond normally, but having agent capabilities available means you do not need to switch modes when you want it to take autonomous action.

How Agent Mode Works

Understanding the internal loop Agent Mode follows helps you write better prompts and anticipate its behaviour. The process works in four stages:

1. Plan

When you submit a prompt, Agent Mode first analyses what you are asking for. It reads relevant files in your workspace, examines your project structure, and creates an internal plan of steps needed to complete the task. You can see this plan in the chat — it will list out what it intends to do before taking action.

2. Execute

Agent Mode begins carrying out the plan. This can include creating new files, editing existing files, running terminal commands (like npm install, pip install, or dotnet build), and reading command output. Each action appears in the chat panel so you can follow along. Critically, Agent Mode asks for your confirmation before running terminal commands — it will not silently execute anything destructive.

3. Verify

After making changes, Agent Mode checks its own work. It may run your test suite, check for linting errors, or verify that a build succeeds. If it detects problems — a failing test, a compilation error, a linter warning — it moves to the next stage.

4. Iterate

When verification reveals issues, Agent Mode automatically attempts to fix them. It reads the error output, identifies the cause, modifies the relevant code, and runs the verification step again. This loop continues until the task passes or it determines it cannot resolve the issue and asks for your input.

This plan-execute-verify-iterate loop is what makes Agent Mode fundamentally different from regular Copilot Chat. Chat mode gives you an answer and stops. Agent Mode gives you an answer, checks whether it actually works, and fixes it if it does not. In practice, this means that roughly 70% of the tasks I give it are completed without any manual intervention beyond reviewing and accepting the final result.

Practical Workflows

Here are the workflows where I have found Agent Mode most valuable in day-to-day development.

Adding a New Feature End-to-End

This is where Agent Mode truly shines. Give it a prompt like: "Add a /api/users/:id/avatar endpoint that accepts a PNG or JPEG upload, resizes it to 256x256 using sharp, stores it in the uploads directory, and returns the URL. Include input validation and error handling. Write tests." Agent Mode will create the route file, install the sharp package, write the handler with validation, create the test file, and run the tests. When a test fails (and it usually does on the first pass), it reads the error, fixes the code, and reruns.

For a feature like this, which might take a developer 30-45 minutes of focused work, Agent Mode typically completes it in 3-5 minutes. The code is not always production-ready — you still need to review it, check edge cases, and ensure it follows your project conventions — but it gets you 80-90% of the way there.

Fixing Bugs with Multi-File Changes

Describe the bug and point Agent Mode at the relevant files: "Users report that the date picker on the booking form shows dates in US format (MM/DD/YYYY) instead of the UK format (DD/MM/YYYY). The form component is in src/components/BookingForm.tsx and the date utility functions are in src/utils/dates.ts. Fix this and update any related tests." Agent Mode reads both files, identifies the formatting issue, makes changes across both files, and updates the test assertions to match the new format.

Writing Tests for Existing Code

This is one of the most time-saving workflows. Select a file or module and prompt: "Write comprehensive unit tests for src/services/payment.ts using Jest. Cover all public methods, including happy paths, error conditions, edge cases with empty inputs, and mock the Stripe API calls." Agent Mode reads the service file, creates a test file, writes the tests, runs them, and fixes any failures. In my experience, it produces tests that cover 75-85% of meaningful scenarios on the first pass.

Refactoring Across Files

Agent Mode handles cross-file refactoring well because it can read multiple files and understand dependencies. Prompt: "Refactor the authentication middleware to use a shared validateToken utility. Currently, token validation logic is duplicated in src/middleware/auth.ts, src/middleware/adminAuth.ts, and src/routes/webhook.ts. Extract it into src/utils/auth.ts and update all three files to use it." Agent Mode creates the shared utility, updates all three consuming files, and ensures imports are correct.

Built-In Tools and Participants

Agent Mode has access to several built-in tools and extension-provided participants that expand what it can do.

@workspace

This tool lets Agent Mode search and read files across your entire project. When you ask it to make changes, it uses @workspace automatically to find relevant files, understand your project structure, and locate dependencies. You do not need to type @workspace explicitly in Agent Mode — it is always available.

@terminal

Agent Mode can run commands in your VS Code integrated terminal. It uses this to install packages, run builds, execute tests, and check command output. Every terminal command requires your approval before execution — you will see a "Run in Terminal" button that you must click. This is a sensible safety measure.

File Creation and Editing

Agent Mode can create new files and edit existing files directly in your workspace. Changes appear as diffs in the editor, and you can accept or reject each change individually. This gives you granular control over what actually gets written to disc.

Extension-Provided Participants

If you have other extensions installed that provide Copilot Chat participants, Agent Mode can use them. Common examples include:

  • @docker — generate and modify Dockerfiles, docker-compose configurations, and troubleshoot container issues.
  • @azure — deploy resources, configure Azure services, and troubleshoot cloud infrastructure.
  • @github — interact with GitHub issues, pull requests, and Actions workflows directly from Agent Mode.

The participant ecosystem is growing. Check the VS Code marketplace for extensions that advertise Copilot Chat participant support.

Agent Mode vs Chat Mode vs Inline Completions

Copilot now offers three distinct modes of interaction. Choosing the right one for each task matters for productivity.

Feature Inline Completions Chat Mode (Ask/Edit) Agent Mode
How it activates Automatic as you type You open chat and ask You open chat in Agent mode and describe a task
Scope of action Current line or block Single response, single file Multi-file, multi-step, terminal access
Autonomy level None — you accept or reject Low — responds once High — plans, executes, iterates
Can run terminal commands No No Yes (with approval)
Self-corrects on errors No No Yes
Best for Boilerplate, line-by-line coding Quick questions, single-file edits Multi-file features, refactoring, test generation
Speed Instant (100-300ms) Fast (2-5 seconds) Slower (30 seconds to several minutes)
Token usage Low Moderate High

My recommended workflow: keep inline completions enabled at all times for routine coding. Use Chat Mode for quick questions ("What does this function do?" or "Write a regex for UK postcodes"). Switch to Agent Mode when you have a task that spans multiple files, requires terminal commands, or involves more than two or three steps.

Tips for Better Results

Agent Mode is powerful, but the quality of its output depends heavily on the quality of your prompts and project setup. Here is what I have learnt from daily use.

Write Clear, Specific Task Descriptions

Vague prompts produce vague results. Instead of "add authentication", write "Add JWT-based authentication middleware to the Express API in src/middleware/. Use the jsonwebtoken package. Tokens should expire after 24 hours. Protect all routes in src/routes/api/ except /api/health and /api/auth/login. Include tests using Jest." The more specific you are about requirements, file paths, packages, and conventions, the better the output.

Use Project Context Files

Create a .github/copilot-instructions.md file in your repository root. Agent Mode reads this file automatically and uses it as context for every interaction. Include your project's coding standards, preferred libraries, naming conventions, and architectural decisions. For example:

# Project Context
- Framework: Express.js with TypeScript
- Testing: Jest with supertest for API tests
- Style: ESLint with Airbnb config, Prettier
- Database: PostgreSQL with Prisma ORM
- Auth: JWT tokens, stored in HTTP-only cookies
- Error handling: Always use AppError class from src/utils/errors.ts
- Naming: camelCase for variables, PascalCase for types, kebab-case for files

Review Each Step, Not Just the Final Result

Agent Mode shows you what it is doing as it works. Read the plan before it starts executing. If the plan looks wrong — it is about to install a package you do not want, or it misunderstood which file to edit — stop it early and correct the prompt. It is far quicker to redirect Agent Mode after step one than to undo ten steps of changes.

Break Large Tasks into Smaller Ones

Agent Mode handles focused, well-defined tasks much better than sprawling ones. Instead of "build the entire user management system", break it down: first "create the user database schema and Prisma migration", then "add CRUD API endpoints for users", then "add authentication middleware", then "write integration tests". Each prompt builds on the previous work, and you can review and course-correct between steps.

Use the Undo Button Liberally

If Agent Mode takes a wrong turn, use VS Code's undo (Ctrl+Z) or the "Discard" button on the proposed changes. Agent Mode's changes are not committed to git automatically — they are just file edits — so you can always revert. I recommend committing your work before starting a complex Agent Mode task so you have a clean rollback point.

Agent Mode vs Claude Code vs Cursor Composer

Agent Mode is not the only autonomous coding tool available. Here is how it compares to the two main alternatives I have used extensively.

Feature Copilot Agent Mode Claude Code (CLI) Cursor Composer
Interface VS Code chat panel Terminal / CLI Cursor editor chat panel
Autonomy level High — plans, executes, iterates Very high — full shell access, git operations High — multi-file edits, codebase-aware
Terminal command execution Yes (with approval per command) Yes (configurable auto-approval) Limited
Self-correction loop Yes Yes — often more persistent Yes
Underlying model GPT-4o / Claude 3.5 (varies) Claude Opus / Sonnet GPT-4o / Claude (user choice)
Pricing $19/month (Copilot Individual) Usage-based (Anthropic API) or $20/month (Max plan) $20/month (Pro) / $40/month (Business)
Editor lock-in VS Code only Editor-agnostic (terminal) Cursor editor only
Extension ecosystem Full VS Code marketplace N/A — terminal-based Fork of VS Code, most extensions work
Git integration Basic (through terminal) Deep — commits, branches, PRs Basic (through terminal)
Best for VS Code users wanting integrated AI Power users comfortable in terminal Developers wanting AI-native editor

My honest assessment: Claude Code is the most capable of the three for complex, multi-step tasks — its understanding of large codebases and ability to self-correct through multiple iterations is noticeably better. But it requires comfort with a terminal-based workflow. Copilot Agent Mode is the best choice if you want everything inside VS Code with zero context-switching. Cursor Composer is a strong middle ground but requires switching away from VS Code, which is a dealbreaker for developers with heavily customised VS Code setups.

For most developers already paying for Copilot and working in VS Code, Agent Mode is the practical choice. You do not need to install anything new, learn a new tool, or pay for an additional subscription. It is already there — you just need to switch the dropdown from "Ask" to "Agent".

Limitations and Honest Caveats

Agent Mode is impressive, but it is not magic. Here are the limitations I have encountered in real use.

  • Looping behaviour. Sometimes Agent Mode gets stuck in a loop — it makes a change, the test fails, it reverts the change, tries something slightly different, the test fails again, and it cycles. When you notice this pattern (usually after 2-3 iterations on the same error), stop it and provide a specific hint about what the actual fix should be. The loop usually happens when the error is ambiguous or the fix requires domain knowledge the model does not have.
  • Incorrect assumptions about your project. Agent Mode reads your workspace, but it does not always understand your architectural intentions. It might create a new utility file when you already have one that does the same thing, or use a different naming convention than the rest of your codebase. The .github/copilot-instructions.md file helps, but it does not eliminate this issue entirely.
  • Token usage and cost. Agent Mode uses significantly more tokens than Chat Mode because it reads files, generates plans, makes changes, reads error output, and iterates. On the Copilot Individual plan, you have a monthly usage allowance. Complex Agent Mode tasks can consume a meaningful portion of that allowance. Monitor your usage in the GitHub Copilot settings dashboard.
  • Context window limitations. For very large files or projects with deeply interconnected modules, Agent Mode may lose track of context mid-task. If you notice it forgetting earlier decisions or contradicting itself, break the task into smaller pieces and provide explicit reminders of decisions made in previous steps.
  • Security considerations. Agent Mode can run terminal commands. While it always asks for approval, be mindful of what you approve — especially in projects with scripts that modify infrastructure, databases, or deployment configurations. Read the command before clicking "Run".
  • Not a replacement for code review. Agent Mode produces functional code, but it does not always produce optimal code. Variable names may be generic, error messages may be vague, and performance-sensitive paths may use naive implementations. Always review Agent Mode's output as you would review a pull request from a colleague.

Frequently Asked Questions

Is Agent Mode included in the free GitHub Copilot tier?

At the time of writing (April 2026), Agent Mode is only available on paid Copilot plans — Individual ($19/month), Business ($39/user/month), and Enterprise ($39/user/month). The free Copilot tier includes inline completions and basic chat, but not the Agent Mode toggle. GitHub has not announced plans to include it in the free tier, though this could change. Check the official Copilot pricing page for the latest details.

Can Agent Mode break my project or delete files?

Agent Mode can edit and create files, and it can run terminal commands — but every terminal command requires your explicit approval before execution. It will not run rm -rf or git push --force without showing you the command first and waiting for you to click "Run". That said, its file edits are applied immediately (though shown as diffs you can discard). My recommendation: always commit your current work to git before starting a complex Agent Mode task, so you can git checkout . if anything goes wrong.

Does Agent Mode work with programming languages other than JavaScript and Python?

Yes. Agent Mode works with any language supported by GitHub Copilot, which includes virtually every mainstream programming language — TypeScript, Java, C#, Go, Rust, Ruby, PHP, Swift, Kotlin, Dart, and many others. Its effectiveness varies by language. It is strongest in JavaScript/TypeScript and Python (where training data is most abundant) and slightly weaker in less common languages. For specialised frameworks or domain-specific languages, provide extra context in your prompts or in the .github/copilot-instructions.md file.

Sources and Further Reading

Related Posts

Want to use AI tools more effectively?

My courses cover practical AI workflows, from spreadsheet formulas to app development, with real projects and honest tool comparisons.

Browse all courses