This guide explains how to create a new agent for the Claude Sub-Agents system that is fully compatible with Claude Code's native format.
Each agent is now a single .md file with YAML frontmatter:
This is the core agent definition with YAML frontmatter and detailed instructions.
---
name: your-agent-name
description: Brief description of what the agent does. Shown in agent listings.
tools: Read, Grep, Glob, Bash # List required tools
---
You are a [role description]. Your role is to [primary responsibility].
## Process
When invoked, immediately:
1. [First action]
2. [Second action]
3. Begin systematic work without delay
## Checklist
### Category 1
- [ ] Task item 1
- [ ] Task item 2
- [ ] Task item 3
### Category 2
- [ ] Task item 1
- [ ] Task item 2
## Output Format
Organize your output by sections:
### 📋 Section 1
Description of section 1 content
### 🔍 Section 2
Description of section 2 content
## Guidelines
1. **Be Specific**: Include concrete examples
2. **Be Thorough**: Cover all aspects
3. **Be Actionable**: Provide clear next steps
## Example Output
Example content here...
Remember: Your goal is to [restate primary objective].
---
name: your-agent-name
description: Clear description with trigger words for auto-delegation. Use when dealing with specific tasks.
tools: Read, Grep, Glob # Optional - inherits all tools if omitted
version: 1.0.0 # Optional
author: Your Name # Optional
tags: [tag1, tag2] # Optional
---
You are a [role description]. Your role is to [primary responsibility].
## Process
When invoked, immediately:
1. [First action]
2. [Second action]
3. Begin systematic work without delay
## Output Format
[Describe expected output format]Important Notes:
- No separate metadata.json file needed
- No slash commands - agents use description-based auto-delegation
- Tools field is optional - agents inherit all tools if not specified
- Description should include trigger words for better matching
-
Create the agent file:
# Create your agent file directly touch agents/your-agent-name.md -
Write the agent definition:
- Add YAML frontmatter with:
name: Agent identifier (lowercase with hyphens)description: Clear description with trigger wordstools: Optional tool restrictions
- Write the system prompt below the frontmatter
- Include clear instructions and output format
- Add YAML frontmatter with:
-
Optimize the description:
# Use the optimize command to improve auto-delegation claude-agents optimize your-agent-name -
Validate the agent:
# Check agent format and quality claude-agents validate your-agent-name
- Single Responsibility: Each agent should focus on one primary task
- Clear Instructions: Use imperative language and numbered steps
- Immediate Action: Design agents to start work immediately when invoked
- Structured Output: Use consistent formatting with emojis for sections
- Checklists: Include comprehensive checklists for thorough coverage
- Include trigger words that users might naturally use
- Start with action verbs (e.g., "Analyzes", "Creates", "Scans")
- Mention when the agent should be used
- Keep descriptions under 200 characters for readability
- Agent names: lowercase with hyphens (e.g.,
code-reviewer,requirements-analyst) - Tags: descriptive keywords for discoverability
- Only include tools the agent actually needs
- Common tools:
Read: For reading filesGrep: For searching codeGlob: For finding files by patternBash: For running commandsEdit/MultiEdit: For code modificationsWrite: For creating files
- Only restrict tools if the agent needs specific limitations
- Most agents should omit the tools field to inherit all available tools
- Common tool restrictions:
- Analysis agents:
Read, Grep, Glob - Modification agents:
Read, Edit, MultiEdit, Grep, Glob - Generation agents:
Read, Write, Grep, Glob
- Analysis agents:
-
Create the agent file:
touch agents/performance-analyzer.md
-
Write the agent:
--- name: performance-analyzer description: Analyzes code performance bottlenecks and suggests optimizations. Use when code is slow or needs performance tuning. tools: Read, Grep, Glob, Bash version: 1.0.0 tags: [performance, optimization, profiling] --- You are a performance optimization specialist with expertise in profiling and optimizing code. ## Process When invoked, immediately: 1. Identify the code or system to analyze 2. Look for common performance bottlenecks 3. Measure or estimate performance impact 4. Suggest specific optimizations ## Analysis Areas - Algorithm complexity (time and space) - Database query optimization - Memory usage and leaks - I/O operations - Caching opportunities - Parallel processing potential ## Output Format ### 🔴 Critical Performance Issues [Issues causing major slowdowns] ### 🟡 Optimization Opportunities [Areas for improvement] ### 🟢 Performance Best Practices [Good patterns already in use] ### 📊 Recommendations [Prioritized list of optimizations]
After creating your agent files:
# Install your agent
claude-agents install performance-analyzer
# Or install directly from file
cp agents/performance-analyzer.md ~/.claude/agents/# Check if your agent is installed
npm start -- list | grep your-agent-nameThe agent will be triggered automatically when users mention relevant keywords:
- "analyze performance"
- "code is slow"
- "optimize this function"
- "performance bottleneck"
Here's a minimal agent template:
---
name: my-agent
description: Does X when Y happens. Use for Z tasks.
tools: Read, Grep, Glob
---
You are an expert in [DOMAIN]. Your primary role is to [PURPOSE].
When invoked, immediately:
1. [FIRST ACTION]
2. [SECOND ACTION]
3. [DELIVER RESULTS]
## Output Format
[DESCRIBE OUTPUT STRUCTURE]Save this as agents/my-agent.md and install with claude-agents install my-agent.
- Agent not triggering: Improve description with better trigger words
- Tools not available: Remove tools field to inherit all tools
- Validation fails: Run
claude-agents validateto see specific issues - Poor auto-delegation: Use
claude-agents optimizeto improve description
When creating agents for the community:
- Follow the established patterns
- Test thoroughly before sharing
- Document any special requirements
- Consider edge cases and error handling
- Make the agent's purpose clear and focused