You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Content/Tips/create-your-first-custom-copilot-agent.md
+46-48Lines changed: 46 additions & 48 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,9 +14,9 @@ featured: true
14
14
15
15
# Create Your First Custom Copilot Agent: Authoring .agent.md Files for Specialized AI Assistants
16
16
17
-
Custom Copilot agents let you create specialized AI assistants that appear in the `@` menu within Copilot Chat. Instead of one general-purpose assistant, you can build agents with specific roles—like a "code reviewer," "documentation writer," or "database expert"—each with its own expertise, boundaries, and tools.
17
+
Custom Copilot agents let you create specialized AI assistants that appear in the `@` menu within [Copilot Chat](https://docs.github.com/en/copilot/using-github-copilot/asking-github-copilot-questions-in-your-ide). Instead of one general-purpose assistant, you can build agents with specific roles—like a "code reviewer," "documentation writer," or "database expert"—each with its own expertise, boundaries, and tools.
18
18
19
-
If you've already explored `copilot-instructions.md` (global rules for your whole project) or SKILL.md files (reusable playbooks), agents are the next step: they're **named personas that Copilot activates when you call them by name**.
19
+
If you've already explored [`copilot-instructions.md`](https://docs.github.com/en/copilot/customizing-copilot/adding-repository-custom-instructions-for-github-copilot) (global rules for your whole project) or [`SKILL.md`](https://docs.github.com/en/copilot/customizing-copilot/adding-repository-custom-instructions-for-github-copilot#creating-a-skill-file) files (reusable playbooks), agents are the next step: they're **named personas that Copilot activates when you call them by name**.
20
20
21
21
## What's a Custom Copilot Agent?
22
22
@@ -119,85 +119,83 @@ mkdir -p .github/agents
119
119
touch .github/agents/code-reviewer.agent.md
120
120
```
121
121
122
-
### Step 2: Add the frontmatter
122
+
### Step 2: Start with frontmatter
123
123
124
-
Open the file and start with metadata:
125
-
126
-
```markdown
124
+
```yaml
127
125
---
128
126
name: code-reviewer
129
-
description: "Specialized code review agent. Reviews PRs for bugs, performance, security, and style alignment."
127
+
description: "Reviews pull requests for code quality, bugs, and best practices."
130
128
target: github-copilot
131
129
tools:
132
130
- git
133
131
- npm
134
132
disable-model-invocation: false
133
+
metadata:
134
+
owner: dev-team
135
+
version: "1.0"
135
136
---
136
137
```
137
138
139
+
This tells Copilot:
140
+
- The agent is called `@code-reviewer`
141
+
- It reviews code for quality and bugs
142
+
- It can use `git` and `npm` commands
143
+
- It's enabled for auto-invocation (e.g., when someone asks for a review)
144
+
138
145
### Step 3: Write the persona
139
146
140
147
```markdown
141
148
# Persona
142
149
143
-
You are an expert code reviewer. Your role is to:
144
-
- Spot bugs, performance bottlenecks, and security issues
145
-
- Check that new code follows our project's coding standards
146
-
- Suggest cleaner or more idiomatic solutions
147
-
- Verify tests exist and cover the changes
150
+
You are an experienced senior engineer with 10+ years of code review experience. Your job is to:
148
151
149
-
You are thorough, constructive, and kind. You explain *why* changes are needed, not just pointing out issues.
152
+
1.**Find bugs** before they reach production
153
+
2.**Suggest improvements** using best practices from our codebase
154
+
3.**Mentor** junior engineers through constructive feedback
155
+
4.**Enforce standards** without being pedantic
150
156
157
+
Your tone is friendly, specific, and actionable—never vague or dismissive.
151
158
```
152
159
153
-
### Step 4: Define boundaries
160
+
### Step 4: Set boundaries
154
161
155
162
```markdown
156
163
# Boundaries
157
164
158
-
You may:
159
-
- Review code in `/src`, `/components`, `/pages`, `/services`
160
-
- Suggest test additions in `/tests`
161
-
- Reference files in `/docs` as style guides
162
-
163
-
You must NOT:
164
-
- Modify production code directly (only suggest changes)
-`git diff` — See what changed in the current branch
175
-
-`npm test` — Run tests (make sure they still pass)
176
-
-`npm run lint` — Check formatting and style
177
-
178
185
# Code review checklist
179
186
180
-
When reviewing, ask these questions:
181
-
182
-
1.**Does it work?**
183
-
- Does the code solve the stated problem?
184
-
- Are there obvious bugs or edge cases missed?
185
-
186
-
2.**Is it maintainable?**
187
-
- Is the code clear and easy to understand?
188
-
- Are variable/function names descriptive?
189
-
- Is there unnecessary complexity?
187
+
When reviewing, use this checklist:
190
188
191
-
3.**Does it follow our standards?**
192
-
- Check `/docs/coding-standards.md` for naming conventions
193
-
- Verify TypeScript strict mode is used (see `copilot-instructions.md`)
194
-
- Look for consistent error handling
189
+
1.**Correctness?**
190
+
- Does the code do what the PR description says?
191
+
- Are there edge cases not handled?
195
192
196
-
4.**Is it tested?**
197
-
- Are there new tests for new code?
193
+
2.**Tests?**
194
+
- Are there tests for the new code?
195
+
- Do they cover happy path AND error cases?
198
196
- Do all tests pass locally?
199
197
200
-
5.**Performance & security?**
198
+
3.**Performance & security?**
201
199
- Any obvious performance issues?
202
200
- Are external inputs validated?
203
201
- No hardcoded secrets or sensitive data?
@@ -291,7 +289,7 @@ Now that you understand agents, you can:
291
289
292
290
1.**Create 2–3 agents** for your team's most common workflows.
293
291
2.**Combine with skills** — Have an agent that orchestrates a skill (e.g., "security-auditor" calls your "security-scan" skill).
294
-
3.**Integrate with MCP** — If you have the GitHub MCP server, agents can fetch live PR data, workflow logs, and more.
292
+
3.**Integrate with MCP** — If you have the [GitHub MCP server](https://github.com/github/github-mcp-server), agents can fetch live PR data, workflow logs, and more.
295
293
4.**Share organization-wide** — Move agents to `.github-private/agents/` so all your org's repos can use them.
0 commit comments