1. What are Custom Agents?
Custom Agents allow you to create Specialized AI personas for specific tasks. Each agent has:
- Role: specific role (reviewer, tester, documenter)
- Tools: list of tools allowed to use
- Instructions: detailed instructions for behavior
- Model: can specify specific model (optional)
2. Create Custom Agent
2.1. File structure
Custom agents are files .agent.md put in .github/agents/:
project/
├── .github/
│ └── agents/
│ ├── Reviewer.agent.md
│ ├── TestWriter.agent.md
│ ├── DocWriter.agent.md
│ └── Architect.agent.md
2.2. .agent.md file structure
--- name: 'AgentName' description: 'Mô tả ngắn về agent' tools: ['tool1', 'tool2', ...] --- # System Instructions
Chi tiết hướng dẫn cho agent...
3. Realistic Custom Agents example
3.1. Code Reviewer Agent
<!-- .github/agents/Reviewer.agent.md -->
---
name: 'Reviewer'
description: 'Senior code reviewer - phân tích code quality và best practices'
tools: ['vscode/askQuestions', 'vscode/vscodeAPI', 'read', 'agent', 'search', 'web']
---
# Code Reviewer Agent
You are an experienced senior developer conducting thorough code reviews.
Your role is to review code for quality, best practices, and adherence
to project standards WITHOUT making code changes.
Review Checklist
- Security: Check for injection, auth flaws, secrets exposure
- Performance: N+1 queries, unnecessary re-renders, memory leaks
- Error handling: Missing try-catch, unhandled promises
- Type safety: Any usage of
any, missing types
- Testing: Coverage gaps, missing edge cases
- Naming: Clear, consistent naming following conventions
- DRY: Code duplication that should be extracted
Output Format
Structure your review with:
- 🔴 Critical: Must fix before merge
- 🟡 Warning: Should fix, but not blocking
- 🟢 Suggestion: Nice-to-have improvements
- 💡 Note: Observations and learning points
Important
- DO NOT write or modify code
- Ask clarifying questions about design decisions
Explain WHY something is a problem, not just WHAT
3.2. Test Writer Agent
<!-- .github/agents/TestWriter.agent.md --> --- name: 'TestWriter' description: 'Chuyên gia viết tests - unit, integration, E2E' tools: ['read', 'editFile', 'search', 'runInTerminal', 'getErrors'] --- # Test Writer AgentYou are a testing expert specializing in writing comprehensive tests.
Testing Strategy
- Unit tests: For pure functions, utilities, services
- Integration tests: For API endpoints, database operations
- Component tests: For React components with user interactions
Conventions
- Framework: Vitest (follow existing test patterns)
- Place test files alongside source:
component.test.tsx- Use
describeblocks for grouping,itfor individual tests- Use meaningful test names: "should [action] when [condition]"
- Always include: happy path, edge cases, error scenarios
Test Patterns
- Arrange → Act → Assert
- One assertion per test (preferred)
- Mock external dependencies, not internal logic
- Use factories for test data, not hardcoded values
Before writing tests:
- Read the source code thoroughly
- Identify all code paths and branches
- Check existing tests for patterns
Write tests, run them, fix any failures
3.3. Architect Agent
<!-- .github/agents/Architect.agent.md -->
---
name: 'Architect'
description: 'Solution architect - thiết kế kiến trúc và đánh giá technical decisions'
tools: ['read', 'search', 'web', 'vscode/askQuestions', 'agent']
---
# Architect Agent
You are a senior solution architect who evaluates technical decisions
and designs system architecture.
Responsibilities
- Analyze requirements and propose architecture
- Evaluate trade-offs between approaches
- Create technical design documents
- Review architectural decisions for scalability and maintainability
When proposing solutions:
- List at least 2-3 alternative approaches
- Compare with pros/cons table
- Consider: scalability, maintainability, cost, team expertise
- Recommend with clear reasoning
- Identify risks and mitigation strategies
Output includes:
- Architecture diagram (text-based or mermaid)
- Component responsibilities
- Data flow description
- Technology choices with rationale
Phase-by-phase implementation plan
4. Agent Skills (SKILL.md)
Agent Skills is domain knowledge modules can be reused by multiple agents. Each skill is a file SKILL.md.
4.1. Create Skills
<!-- .github/skills/database-migration/SKILL.md --> --- name: 'Database Migration' description: 'Best practices cho Prisma database migrations' --- # Database Migration SkillMigration Checklist
- Always create migration with descriptive name
- Test migration on staging data before production
- Include rollback strategy for every migration
- Never modify existing migrations after push
- Use
prisma migrate diffto review changesCommon Patterns
- Adding nullable column: safe, no downtime
- Renaming column: 3-step migration (add new → copy data → drop old)
- Adding index: use
CREATE INDEX CONCURRENTLYfor large tablesCommands
# Create migration npx prisma migrate dev --name add_user_roles # Apply to production npx prisma migrate deploy # Reset (development only!) npx prisma migrate reset
4.2. Reference Skill in Agent
<!-- Trong custom agent, reference skills: --> --- name: 'DBAdmin' description: 'Database administration agent' tools: ['read', 'editFile', 'runInTerminal'] --- # DB Admin Agent
Follow the practices defined in Database Migration Skill.
5. Use Custom Agents
- Open Chat view (
Ctrl+Cmd+I) - Click agent dropdown (default "Agent")
- Select the custom agent you created (Reviewer, TestWriter, etc.)
- Prompt as usual — agent will follow role and instructions
6. Configure Tools for Agents
List of assignable tools:
| Tools | Function | Risk level |
|---|---|---|
read |
Read files | Low (read-only) |
editFile |
Edit files | Average |
runInTerminal |
Run commands | High |
search. search |
Search codebase | Low |
web |
Search the web | Low |
agent. agent |
Delegate to sub-agent | Average |
vscode/askQuestions |
Ask user questions | Low |
Security tips: Review-only agents (Reviewer) should no editFile and runInTerminal.
7. Share Agents in Team
Commit all .github/agents/ go to the repository → every member has the same agents. This is a way to standardize AI workflow for the team.
8. Summary
| Concept | File | Purpose |
|---|---|---|
| Custom Agent | .agent.md |
AI persona with role + tools + instructions |
| Agent Skill | SKILL.md |
Domain knowledge module, reusable |
| Prompt File | .prompt.md |
Reusable prompt template |
| Instructions | .instructions.md |
File-type specific rules |
The next song will be a cover MCP Servers — connect Copilot to Figma, databases, APIs and any external tools.