Use custom agents
A custom agent is a specialized version of Copilot. Custom agents help Copilot handle unique workflows, particular coding conventions, and specialist use cases.
Copilot CLI includes a default group of custom agents for common tasks:
| Agent | Description |
|---|---|
| Explore | Performs quick codebase analysis, allowing you to ask questions about your code without adding to your main context. |
| Task | Executes commands such as tests and builds, providing brief summaries on success and full output on failure. |
| General-purpose | Handles complex, multi-step tasks that require the full toolset and high-quality reasoning, running in a separate context to keep your main conversation clearly focused. |
| Code-review | Reviews changes with a focus on surfacing only genuine issues, minimizing noise. |
The AI model being used by the CLI can choose to delegate a task to a subsidiary subagent process, that operates using a custom agent with specific expertise, if it judges that this would result in the work being completed more effectively. The model may equally choose to handle the work directly in the main agent.
You can define your own custom agents using Markdown files, called agent profiles, that specify what expertise the agent should have, what tools it can use, and any specific instructions for how it should respond.
You can define custom agents at the user, repository, or organization/enterprise level:
| Type | Location | Scope |
|---|---|---|
| User-level custom agent | local ~/.copilot/agents directory | All projects |
| Repository-level custom agent | .github/agents directory in your local and remote repositories | Current project |
| Organization and Enterprise-level custom agent | /agents directory in the .github-private repository in an organization or enterprise | All projects under your organization and enterprise account |
In the case of naming conflicts, a system-level agent overrides a repository-level agent, and the repository-level agent would override an organization-level agent.
Custom agents can be used in three ways:
-
Using the slash command in the CLI's interactive interface to select from the list of available custom agents:
/agent -
Calling out to the custom agent directly in a prompt:
Use the refactoring agent to refactor this code blockCopilot will automatically infer the agent you want to use.
-
Specifying the custom agent you want to use with the command-line option. For example:
copilot --agent=refactor-agent --prompt "Refactor this code block"
For more information, see Creating custom agents for Copilot coding agent.
Use skills
You can create skills to enhance the ability of Copilot to perform specialized tasks with instructions, scripts, and resources.
For more information, see Creating agent skills for GitHub Copilot CLI.
Add an MCP server
Copilot CLI comes with the GitHub MCP server already configured. This MCP server allows you to interact with resources on GitHub.com—for example, allowing you to merge pull requests from the CLI.
To extend the functionality available to you in Copilot CLI, you can add more MCP servers:
-
Use the following slash command:
/mcp add -
Fill in the details for the MCP server you want to add, using the Tab key to move between fields.
-
Press Ctrl+S to save the details.
Details of your configured MCP servers are stored in the mcp-config.json file, which is located, by default, in the ~/.copilot directory. This location can be changed by setting the XDG_CONFIG_HOME environment variable. For information about the JSON structure of a server definition, see Extending GitHub Copilot coding agent with the Model Context Protocol (MCP).
For more detailed information on adding and managing MCP servers in Copilot CLI, see Adding MCP servers for GitHub Copilot CLI.
Next steps
To learn how to guide and refine agent behavior during task execution to keep work on track, see Steering agents in GitHub Copilot CLI.