Creating Custom Agents

Build specialized AI agents tailored to your specific needs and workflows.

🚀 Quick Start Command

bash
# Generate a new agent with a single command
/generate-agent "security-audit-specialist"

# Or manually create an agent
touch .claude/agents/my-specialist.md

🛠️ Creation Process

Four simple steps to create your custom agent.

1. Define Specialty

Identify the agent's unique expertise and capabilities

Example: Code review specialist, Performance optimizer, Security auditor

5 min

2. Create Definition

Write the agent definition file in Markdown format

Example: .claude/agents/my-specialist.md

10 min

3. Configure Tools

Assign MCP servers and tools for the agent

Example: Testing tools, database connections, API integrations

5 min

4. Test & Deploy

Validate agent behavior and deploy to system

Example: Run test tasks, verify outputs, monitor performance

15 min

📦 Agent Components

Essential components that make up an agent definition.

System Prompt

Required

Defines the agent's role and expertise

You are a performance optimization specialist...

Capabilities

Required

List of specific skills and knowledge areas

- Code profiling - Memory optimization - Query tuning

MCP Tools

Associated Model Context Protocol servers

lighthouse, web-vitals, performance-monitor

Task Templates

Predefined templates for common tasks

Performance audit template, optimization checklist

📄 Example Agent Definition

Performance Optimization Specialist

markdown
# Performance Optimization Specialist

## Role
You are a performance optimization specialist focused on improving application speed, reducing resource usage, and enhancing user experience.

## Capabilities
- Analyze code for performance bottlenecks
- Optimize database queries and indexes
- Implement caching strategies
- Reduce bundle sizes and load times
- Profile memory usage and fix leaks

## MCP Tools
- lighthouse
- web-vitals
- performance-monitor
- bundle-analyzer

## Task Templates
### Performance Audit
1. Run Lighthouse analysis
2. Identify Core Web Vitals issues
3. Analyze bundle composition
4. Profile runtime performance
5. Generate optimization report

## Success Metrics
- Page load time < 2s
- First Contentful Paint < 1s
- Time to Interactive < 3s
- Bundle size reduction > 30%

✨ Best Practices

Guidelines for creating effective and maintainable agents.

Single Responsibility

Each agent should focus on one specialty

Clear Documentation

Document capabilities and limitations clearly

Tool Integration

Leverage existing MCP servers and tools

Testing Coverage

Include test scenarios and validation

Advanced Agent Features

Dynamic Capabilities

  • • Self-improving with experience
  • • Learning from task outcomes
  • • Adaptive tool selection
  • • Performance optimization

Collaboration Features

  • • Inter-agent communication
  • • Shared context and knowledge
  • • Task delegation capabilities
  • • Consensus decision making