Custom Agents for GitHub Copilot
Table of Contents
Custom Agents for GitHub Copilot
GitHub Copilot allows you to create custom agents that can perform specific tasks based on your requirements.
How to Create Custom Agents for GitHub Copilot
Manual:
- Create a new file
namespace.angent-name.agent.mdin the.github/agents/directory of your repository. - Define the agent’s behavior using frontmatter and instructions in the file.
GUI:
- Open the GitHub Copilot chat sidebar in Visual Studio Code.
- Click on the “Create New Agent” button in the agent selection dropdown (at the bottom left of the chat input box).
- Define the agent’s name, description, and behavior using the provided interface.
Example of a Custom Agent Definition
---
description: This agent helps with code reviews by providing suggestions and improvements.
tools: ["file_search", "fetch_webpage"] # List of built-in tools the agent can use
handoffs:
model: Claude Sonnet 4.5
- label: Suggest Improvements
agent: agent
prompt: "Please suggest improvements for the following code:"
---
# Instructions for the agent
You are a professional code reviewer. Analyze the provided code and suggest improvements, optimizations, and best practices.
...
See the official documentation for more details on creating and configuring custom agents for GitHub Copilot.
How to Use Custom Agents
- Open the GitHub Copilot chat sidebar in Visual Studio Code.
- Select your custom agent from the agent selection dropdown (at the bottom left of the chat input box).
- Interact with the agent by typing prompts or commands in the chat input box.
Prompt Files vs. Custom Agents
| Feature | Prompt Files | Custom Agents |
|---|---|---|
| Purpose | Simple triggers to invoke agents | Full implementation logic for complex tasks |
| File Type | .prompt.md files |
.agent.md files |
| Complexity | Minimal frontmatter, just points to an agent | Detailed frontmatter with tools, handoffs, and instructions |
| Use Cases | Quick commands, simple tasks | Comprehensive workflows, multi-step processes |
| Persistence | Just one response per invocation | Can maintain context over multiple interactions in a session |
File Structure:
.github/
├── agents/
│ └── namespace.agent-name.agent.md # Custom agent
└── prompts/
└── namespace.prompt-name.prompt.md # Prompt file
.vscode/
└── settings.json # VSCode settings for prompt files (optional)