Mastering GitHub Copilot: When to use AI agent mode

Discover the differences between agent mode and Copilot Edits with GitHub Copilot—and when to use them in your workflows.

A designed image of the GitHub Copilot logo on a graphic background.
| 8 minutes

Ever find yourself staring at an AI coding assistant, wondering why it’s not quite nailing what you need? Maybe it’s spitting out code that’s close but not quite right, or you’re stuck wrestling with a problem that spans multiple files, wishing it could just get the bigger picture. Often, when developers hit these snags, it’s less about the tool, and more about knowing how to use it.

So here’s the key question you should ask yourself: “Do I need a quick answer or a thoughtful conversation?” That’s the secret to unlocking AI coding tools like GitHub Copilot.

Because different aspects of Copilot serve different needs, and we’re here to help you discern when is the best time for agent mode and when you should be using Copilot Edits instead. Both are powerhouse Copilot features, built to supercharge your coding, but they shine in different scenarios.

Copilot Edits is your go-to for fast, precise tweaks—think refactoring a function, squashing a bug, or applying consistent changes across files without losing your flow.

Agent mode, on the other hand, steps up as your AI collaborator for thornier, multi-file challenges—analyzing your codebase, proposing architectural fixes, and even running terminal commands while you steer the ship and approve each move.

Figuring out which one fits your needs doesn’t just save time, it turns your AI assistant into a seamless extension of your own coding instincts.

Copilot command center: Your chat window

Before learning more about agent mode and Copilot Edits, it’s essential to understand the Copilot chat window in VS Code—your central hub for AI interactions.

GitHub Copilot chat interface showing the 'Ask Copilot' panel. The interface displays the Copilot robot logo at the top, followed by 'Ask Copilot' heading. Below that is a disclaimer stating 'Copilot is powered by AI, so mistakes are possible. Review output carefully before use.' The interface includes instructions: 'or type \# to attach context', 'to chat with extensions', and 'Type / to use commands'. At the bottom is a chat input field with the placeholder text 'Ask Copilot' and buttons to add context, with 'GPT-4o' shown as the current model.

This is where you can:

  • Ask coding questions like “How do I implement JWT authentication in Node.js?”
  • Use /explain to understand complex code blocks
  • Debug issues with /fix
  • Generate tests with /tests
  • Access both Edits and agent mode features

With the chat window giving you a solid grasp of your code’s context, you’re in the driver’s seat to pick the perfect Copilot tool: Edits or agent mode, for whatever’s next.

Let me take you through a real-world example of how I’ve been using GitHub Copilot to evolve my personal website. It started with a simple idea: create an interactive terminal-style easter egg that showcases my skills in a developer-friendly way.

I began with a basic command processing function that handled a few simple commands:

function processCommand(command) {
try {
if (!command?.trim()) {
return 'Please enter a command. Type "more" for available commands.';
}

const sanitizedCommand = command.toLowerCase().trim();

switch (sanitizedCommand) {
case 'more':
return commands.more;
case 'about':
return commands.about;
case 'skills':
return commands.skills;
case 'projects':
return commands.projects;
case 'contact':
return commands.contact;
default:
return `Command not found: "${command}". Type 'more' for available commands.`;
}
} catch (error) {
console.error('[Terminal] Error processing command:', error);
return 'An error occurred while processing the command.';
}
}

Initially, I used Copilot Edits to quickly add new features. For instance, I wanted to add a ‘github’ command to showcase my repositories:

VS Code editor showing a web development project for ag11.dev. The left sidebar displays a file explorer with various components including ContentLinks.astro, DarkModeToggle, and TerminalEasterEgg files. The main editor shows TerminalService.ts file with a COMMANDS object being exported, listing GitHub repositories including github-commenter-raffle, octogatosconf, and dependabot-automation projects. The right sidebar shows GitHub Copilot suggesting steps to add a new 'github' command to the terminal that will display links to repositories. The bottom panel shows a terminal running a development server with local and network URLs. The interface has a dark theme with syntax highlighting in various colors. Add a new command called 'github' to the TerminalEasterEgg that displays links to my GitHub repositories with a short description of each. Update both the processCommand function and the commands object.

Copilot Edits made targeted changes to the switch statement in the processCommand function and added the new command to the commands object—a perfect example of quick, focused modifications to existing code.

As my terminal interface matured, I wanted to implement several interactive features that would require more comprehensive improvements. To get animation effects, keyboard navigation controls, and an extensible theming system that spanned multiple files to work together seamlessly, I turned to agent mode.

The agent mode advantage

When we designed agent mode, we didn’t want to create a tool that’s a simple AI feature: We wanted to create an AI that could pair with you! Rather than working on specific, limited changes where you might be reinventing the wheel, you’re now providing higher-level direction while the AI tackles the implementation details across multiple files or systems.

That being said, with agent mode, you’re still in control of the process. The AI has more latitude to explore your codebase and suggest comprehensive solutions, but you always review and approve the changes before they’re applied. It’s not about surrendering control, it’s about effectively delegating implementation details while you focus on the bigger picture.

What makes agent mode special:

  • Codebase search: It searches your codebase to find relevant files without you explicitly specifying them.
  • Self-iteration: It can iterate on its own output to complete your entire request in one go.
  • Error identification and repair: It automatically recognizes and fixes errors in suggested code.
  • Terminal command execution: It suggests and runs terminal commands with your permission.
  • Build and run capabilities: It can build and run your application to check if changes work correctly.

I reach for agent mode when:

  • Building complete features: “Add analytics tracking throughout the app”
  • Navigating unfamiliar codebases: “Help me understand how authentication works in this project”
  • Writing and verifying tests: “Write tests for the UserService and make sure they pass”
  • Implementing terminal-heavy tasks: “Set up a new React project with TypeScript, Redux, and styled-components”
  • Doing complex refactoring: “Refactor our API calls to use the new error handling pattern”

Continuing with my terminal easter egg, let’s say I want to implement a much more extensive upgrade with multiple features, like adding a typing animation effect for responses, command history navigation with up/down arrows, and tab completion for commands. At the same time, I want to create a new TerminalThemes.css file with different color scheme options that users can switch between with a ‘theme’ command.

GitHub Copilot interface showing a chat panel with 'COPILOT EDITS' tab selected. A user named AndreaGriffiths11 (with profile picture) has requested several enhancements to a TerminalEasterEgg component, including adding a typing animation effect for responses, command history navigation with up/down arrows, tab completion for commands, and creating a new TerminalThemes.css file with theme switching options. The interface shows 'TerminalEasterEgg.astro:1-21' as the current file. Below, GitHub Copilot has started responding with 'I'll help enhance the terminal with those features. Let's break this down into steps:' and indicates it 'Used 1 reference'." Enhance our TerminalEasterEgg to include a typing animation effect for responses, add command history navigation with up/down arrows, and implement tab completion for commands. Also create a new TerminalThemes.css file with different color scheme options that users can switch between with a 'theme' command.

This is where agent mode truly shines. The task spans multiple files, requires an understanding of the existing codebase, and involves creating entirely new functionality. Here, agent mode would:

  1. Search through the codebase to understand the terminal implementation.
  2. Create the new CSS file for themes.
  3. Add typing animation functionality to terminal responses.
  4. Implement keyboard handlers for history navigation.
  5. Build the tab completion system.
  6. Add the theme command to the switch statement.
  7. Test the implementation to ensure everything works correctly.

This is the beauty of agent mode: it has a complex understanding of patterns and relationships in different parts of the codebase! Agent mode can ensure that the typing animation did not interfere with existing functionality, check that the history navigation was compatible with the current command processing, and confirm that the theme switching properly modified the UI. It is precisely in this multi-file feature implementation with interlinking components that agent mode can shine compared to the more laser-focused Copilot Edits.

In the below episode of GitHub Checkout, you can see agent mode implementing a complete water consumption tracker feature in an iOS app. It not only writes the code but also builds, runs, and tests the app, all from a single prompt, without the developer needing to touch the editor directly.

The secret: use both together!

After many hours with both tools, here’s my takeaway: It’s not about picking one, or one being better than the other. It’s about wielding them together for different purposes. Copilot Edits and agent mode work well together to augment our coding abilities, whether that’s a more prompt-centric style of development with agent mode, or maintaining granular file edit control via Copilot Edits.

Regardless of which tool you are using, you are still the pilot, steering the AI to supercharge your own productivity. The more context you provide in your prompts, the better results you’ll get—and remember, you always have the final say on any suggested changes.

If you’re just jumping into the world of AI, check out our new Getting started with GitHub Copilot tutorial series, where we walk you through everything from initial setup to advanced techniques. It’s perfect for developers at any skill level who want to quickly become productive with AI-assisted coding.

Happy coding, everyone! 💻✨

How to get started

Want to try these features? Here’s my quick setup guide:

For Copilot Edits:

  1. Open VS Code and look for the Copilot Chat window.
  2. Click the “Edit with Copilot” button to open the Copilot Edits view.
  3. Add your relevant files to the working set. Copilot will only make changes to files in this set (unless it’s creating a new file).
  4. Type your prompt describing what changes you need.
  5. Review the “diff” of all proposed changes before accepting them.

For agent mode:

  1. Make sure you’re using VS Code version 1.99 or higher (as of original publish date, available in VS Code Insiders).
  2. Switch from “Edit” to “Agent” mode.
  3. Type your prompt, describing the complex task or feature you want to implement.
  4. Agent mode will work autonomously, but still require your approval for changes.
  5. For best results, consider using custom instructions to personalize how agent mode works with your codebase.

Try GitHub Copilot free
Ready to automate your dependency management with AI? Learn more about GitHub Copilot for Business or start your free trial of GitHub Enterprise today.

Written by

Andrea Griffiths

Andrea Griffiths

@AndreaGriffiths11

Andrea is a Senior Developer Advocate at GitHub with over a decade of experience in developer tools. She combines technical depth with a mission to make advanced technologies more accessible. After transitioning from Army service and construction management to software development, she brings a unique perspective to bridging complex engineering concepts with practical implementation. She lives in Florida with her Welsh partner, two sons, and two dogs, where she continues to drive innovation and support open source through GitHub's global initiatives. Find her online @alacolombiadev.

Related posts