December 27, 2025
💡 Templates & Examples: Looking for ready-to-use agent templates? Check out the gh-copilot-templates repository:
- Generalized templates to copy and customize
- Personalized examples showing specialized agents in action
Instruction files give Copilot your conventions. Prompt files give you reusable commands. Agent files give you specialized personas.
An agent file (.agent.md) is a configured instance of a Copilot agent with a specific role, limited tools, and tailored instructions. The default Copilot agent is a generalist. Custom agents are specialists: a planner that only reads and researches, a tester that only writes tests, a reviewer that critiques without editing.
The power comes from constraint. By limiting what an agent can do, you make it better at what it should do.
Different tasks need different capabilities. A planner shouldn't edit code. An implementer needs write access. A reviewer should critique without making changes.
Without custom agents, you're constantly specifying constraints in prompts: "Don't edit, just review." That's friction. Agent files encode constraints once, then you switch agents like switching tools.
The other benefit is handoffs. You can design workflows where one agent completes its task, then passes context to the next agent. Plan → Implement → Review, each step handled by a specialist.
But the real reason custom agents matter is subagents. When the main agent delegates work via runSubAgent, the subagent is context-isolated. It doesn't inherit your chat history, conventions, or instructions. Without custom agents, subagents run with default settings: no knowledge of your codebase, access to all tools, no constraints. It's random whether they follow your patterns.
With custom agents, you define exactly what runSubAgent calls. Your main agent becomes an orchestrator that delegates to the right specialist, each with proper tools and instructions. This dramatically reduces deviation from expected results.
This is why agents feel like a team instead of one confused generalist. It's also why you should start new chats frequently: models suffer from context pollution. Fresh chats, specialized agents, and deliberate delegation.
Quick clarification:
AGENTS.md: Repo-wide conventions for all agents across tools (Cursor, Copilot, Windsurf). See Instruction Files.copilot-instructions.md: Repo-wide conventions specific to GitHub Copilot..instructions.md: Path-specific conventions that auto-inject for matching files..prompt.md: Reusable commands you invoke manually with /command. See Custom Prompts..agent.md: Configured Copilot personas with specific tools, models, and instructions.Agent files change who Copilot is, not just what it knows.
Agent files are markdown with YAML frontmatter. See the planner template for a complete example.
| Property | Purpose |
|---|---|
name | Agent name shown in dropdown (defaults to filename) |
description | Short description shown in chat input placeholder |
tools | List of tools available to this agent (omit for all tools) |
model | AI model to use (defaults to currently selected model) |
handoffs | Buttons that transition to other agents with pre-filled prompts |
target | Restrict to vscode or github-copilot environments |
infer | Enable/disable use as subagent (default: true) |
The tools property is the key constraint:
['search', 'read', 'web'] for research without edits['edit', 'execute'] for code modificationtools entirely for all capabilitiesFind available tools by clicking Configure Tools in the chat view (right of the model selector).
Think of agents like developer roles. Instead of one generalist, imagine distinct hats:
search, web, readsearch, read, todosearch, edit, readsearch, edit, read, executesearch, readSee the templates for complete configurations.
Handoffs chain agents together. After an agent responds, handoff buttons appear to transition to the next agent with context.
Example workflow: Plan → Implement → Review
Each agent's handoffs property defines buttons. With send: false, the prompt pre-fills but doesn't auto-submit. Set send: true for automated transitions (use cautiously).
See the handoff examples for complete configurations with circular workflows.
.github/agents/*.agent.md for team-shared, project-specific agentsTo create one in VS Code:
VS Code creates the file with autocomplete for frontmatter properties.
Custom agents add complexity. Skip them if:
Use them when:
Agent files are processed on every request. Wasteful formatting burns tokens:
**bold** and _italic_. LLMs ignore visual formatting.- not - [ ]. Checkboxes are for humans.Long files make models less likely to follow all instructions. If you're using an LLM to draft agent files, watch for this. Models add formatting "for readability" that wastes your token budget.
Some features are experimental (APIs may change):
Custom agents are powerful, but stochastic limitations apply. Agents will sometimes ignore instructions or misuse tools.
Use agents for the "vibe" of the workflow. Use deterministic tools (ESLint, tests, CI) for enforcement.
Start simple:
Don't over-engineer. If you're spending more time configuring agents than saving, you've gone too far.
Model Note: This article was written with the help of Claude Sonnet 4. No other models involved.