About 自定义代理
自定义智能体 are specialized versions of the Copilot agent that you can tailor to your unique workflows, coding conventions, and use cases. They act like tailored teammates that follow your standards, use the right tools, and implement team-specific practices. You define these agents once instead of repeatedly providing the same instructions and context.
You define 自定义代理 using Markdown files called 代理资料. These files specify prompts, tools, and MCP servers. This allows you to encode your conventions, frameworks, and desired outcomes directly into Copilot.
The 代理资料 defines the 自定义智能体's behavior. When you assign the agent to a task or issue, it instantiates the 自定义智能体.
In addition to any 自定义代理 you define yourself, Copilot includes a set of pre-built 自定义代理. See Built-in agents.
代理简介 format
代理概况 are Markdown files with YAML frontmatter. In their simplest form, they include:
- Name (optional): A display name for the 自定义智能体. If omitted, the agent's filename is used as its identifier and default display name.
- Description: Explains the agent's purpose and capabilities.
- Prompt: Custom instructions that define the agent's behavior and expertise.
- Tools (optional): Specific tools the agent can access. By default, agents can access all available tools, including built-in tools, and MCP server tools.
代理概况 can also include MCP server configurations using the mcp-servers property.
Example 代理资料
This example is a basic 代理资料 with name, description, and prompt configured.
---
name: readme-creator
description: Agent specializing in creating and improving README files
---
You are a documentation specialist focused on README files. Your scope is limited to README files or other related documentation files only - do not modify or analyze code files.
Focus on the following instructions:
- Create and update README.md files with clear project descriptions
- Structure README sections logically: overview, installation, usage, contributing
- Write scannable content with proper headings and formatting
- Add appropriate badges, links, and navigation elements
- Use relative links (e.g., `docs/CONTRIBUTING.md`) instead of absolute URLs for files within the repository
- Make links descriptive and add alt text to images
Where you can configure 自定义代理
You can define 代理资料 at different levels:
- Repository level: Create
.github/agents/CUSTOM-AGENT-NAME.mdin your repository for project-specific agents. - Organization or enterprise level: Create
/agents/CUSTOM-AGENT-NAME.mdin a.github-privaterepository for broader availability.
For more information, see 准备在组织中使用自定义代理 and 准备在企业中使用自定义代理.
Built-in agents
In addition to the main Copilot agent, which processes your request when you submit a prompt, Copilot 命令行界面(CLI) includes the following built-in agents which the main agent can run as subagents to assist with common development tasks. These agents are optimized for efficiency and accuracy, leveraging the capabilities of the underlying language models and tools to provide high-quality assistance in their respective domains.
Copilot will automatically use an appropriate built-in agent based on your prompt and the current context. For example, the prompt How does authentication work in this codebase? will typically trigger the Explore agent, and using the /research slash command will trigger the Research agent.
-
explore — A fast, lightweight codebase exploration agent. It uses code intelligence, grep, glob, view, and shell tools to search files and understand code structure. It will not change any files, so can be called in parallel to other subagents being run by the main Copilot agent. It has read-only access to GitHub MCP server tools.
-
task — A command execution agent that runs development commands (tests, builds, linters, formatters, dependency installs) and reports results efficiently. It returns a brief summary on success, and full output on failure, keeping the main context clean. It has access to all of the tools the parent agent can use (excluding some that are not appropriate in a subagent context), with the same permissions granted or denied.
-
general-purpose — This agent essentially has all of the same capabilities as the main Copilot agent. The main agent can run the general-purpose agent as a subagent to assist with any task that requires a separate context window, or to run in parallel when appropriate.
-
code-review — Reviews code changes with an extremely high signal-to-noise ratio. This agent analyzes staged/unstaged changes and branch diffs, surfacing only issues that genuinely matter: bugs, security vulnerabilities, race conditions, memory leaks, and logic errors. It never comments on style or formatting. It will not make any changes to files.
-
research — This agent operates as a staff-level software engineer and research specialist. It provides exhaustive, meticulously researched answers about codebases, APIs, libraries, and software architecture. It uses GitHub search/exploration tools, web fetch/search, and local tools. Unlike the other agents, the research agent can only be invoked by using the
/researchslash command. It cannot be automatically triggered by the main agent.
Running agents as subagents
One of the benefits of using custom agents you have defined yourself—or the built-in agents—is that the main Copilot agent can run them as subagents with a separate context window. This means that your custom agent, or built-in agent, can focus on a specific subtask without cluttering the context window of the main agent.
Where appropriate, tasks performed by subagents can be run in parallel, allowing the overall task to be completed more quickly.
For more information, see 比较 GitHub Copilot CLI 自定义功能.
Next steps
To create your own 自定义代理, see: