Importing Copilot Agent Files
GitHub Copilot custom agents are Markdown prompt files stored in .github/agents/ and imported with imports. Copilot supports these files natively; other engines such as Claude and Codex receive the Markdown body as prompt text.
A typical agent file looks like this:
---name: My Copilot 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 Agent Files from Agentic Workflows
Section titled “Using Copilot Agent Files from Agentic Workflows”Use imports to load an agent file from your repository or from another repository.
Local Agent File Import
Section titled “Local Agent File 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 File Import
Section titled “Remote Agent File Import”Import an agent file from another repository with 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.The imported instructions are merged into the workflow prompt.
Agent File Requirements
Section titled “Agent File Requirements”Agent files must live in .github/agents/, use Markdown with YAML frontmatter, and may define fields such as name, description, tools, and mcp-servers. Remote imports are cached by commit SHA in .github/aw/imports/.
Copilot Agent File Collections
Section titled “Copilot Agent File Collections”Organizations can keep shared agent files in a dedicated repository:
acme-org/ai-agents/└── .github/ └── agents/ ├── code-reviewer.md # General code review ├── security-auditor.md # Security-focused analysis ├── performance-analyst.md # Performance optimization ├── accessibility-checker.md # WCAG compliance └── documentation-writer.md # Technical documentationTeams can then import the agent that fits the workflow:
---on: pull_requestengine: copilotimports: - acme-org/ai-agents/.github/agents/security-auditor.md@v2.0.0---
# Security Review
Perform comprehensive security review of this pull request.Combining Copilot Agent Files with Other Imports
Section titled “Combining Copilot Agent Files with Other Imports”Agent files can be combined with shared tools, MCP servers, and policy imports:
---on: pull_requestengine: copilotimports: - acme-org/ai-agents/.github/agents/security-auditor.md@v2.0.0 - acme-org/workflow-library/shared/tools/github-standard.md@v1.0.0 - acme-org/workflow-library/shared/mcp/database.md@v1.0.0 - acme-org/workflow-library/shared/config/security-policies.md@v1.0.0permissions: contents: readsafe-outputs: create-pull-request-review-comment: max: 10---
# Comprehensive Security Review
Perform detailed security analysis using specialized agent files and tools.Defining Copilot Sub-agents Inline
Section titled “Defining Copilot Sub-agents Inline”Instead of (or alongside) importing agent files from .github/agents/, you can define agents directly inside the workflow markdown. See Inline Sub-Agents for the complete syntax reference, including name constraints and frontmatter fields.
Related Documentation
Section titled “Related Documentation”- Imports Reference - Complete import system documentation
- Inline Sub-Agents - Defining Copilot sub-agents inside a workflow file
- Reusing Workflows - Adding and updating workflows from other repositories
- Frontmatter - Configuration options reference