Reusing Copilot Custom Agents
“Custom Agents” is a term used in GitHub Copilot for specialized prompts for behaviors for specific tasks. They are markdown documents stored in the .github/agents/ directory and imported via the imports field. Copilot supports agents natively, while other engines (Claude, Codex) inject the markdown body as a prompt.
Creating a Copilot Custom Agent
Section titled “Creating a Copilot Custom Agent”Create a markdown file in .github/agents/ with agent-specific instructions:
---name: My Copilot Custom Agentdescription: Specialized prompt for code review tasks---
# Agent Instructions
You are a specialized code review agent. Focus on:- Code quality and best practices- Security vulnerabilities- Performance optimizationUsing Copilot Custom Agents from Agentic Workflows
Section titled “Using Copilot Custom Agents from Agentic Workflows”Import agent files in your workflow using the imports field. Agents can be imported from local .github/agents/ directories or from external repositories.
Local Agent Import
Section titled “Local Agent Import”Import an agent from your repository:
---on: pull_requestengine: copilotimports: - .github/agents/my-agent.md---
Review the pull request and provide feedback.Remote Agent Import
Section titled “Remote Agent Import”Import an agent from an external repository using the owner/repo/path@ref format:
---on: pull_requestengine: copilotimports: - acme-org/shared-agents/.github/agents/code-reviewer.md@v1.0.0---
Perform comprehensive code review using shared agent instructions.Remote agent imports support versioning:
- Semantic tags:
@v1.0.0(recommended for production) - Branch names:
@main,@develop(for development) - Commit SHAs:
@abc123def(for immutable references)
The agent instructions are merged with the workflow prompt, customizing the AI engine’s behavior for specific tasks.
Agent File Requirements
Section titled “Agent File Requirements”- Location: Must be in a
.github/agents/directory (local or remote repository) - Format: Markdown with YAML frontmatter
- Frontmatter: Can include
name,description,tools, andmcp-servers - One per workflow: Only one agent file can be imported per workflow
- Caching: Remote agents are cached by commit SHA in
.github/aw/imports/
The Copilot Custom Agent for Agentic Workflows
Section titled “The Copilot Custom Agent for Agentic Workflows”The Copilot Custom Agent for Agentic Workflows (agentic-workflows.agent.md) is a specialized custom agent designed to assist with creating, updating, importing, and debugging agentic workflows. It provides tailored instructions and behaviors to streamline workflow management tasks.