What Are Agents?
Agents are markdown files (.md) stored in .claude/agents/ that define:
- Expertise area - Domain knowledge and specialization
- Tools - Which Claude Code tools the agent can use
- Model - Which Claude model to use (sonnet, opus, haiku)
- Instructions - How the agent approaches tasks
- Communication patterns - How the agent interacts with users and other agents
Agents are essentially specialized prompts that Claude Code loads when invoked. They provide consistent, expert-level assistance for specific tasks.
Agent Structure
Agents use YAML frontmatter followed by markdown instructions:Frontmatter Fields
Agent Categories
Agents are organized by domain expertise:- Development Team
- Security
- Database
- AI & Data
Core development specialists:
- frontend-developer - React, Vue, Angular expert
- backend-developer - API and server-side development
- fullstack-developer - End-to-end application development
- mobile-developer - iOS and Android applications
- devops-engineer - Infrastructure and deployment
Using Agents
Installation
Install agents using the CLI:Invocation
Once installed, agents are available in Claude Code:Agents appear in Claude Code’s agent picker automatically after installation.
Real-World Examples
Example 1: Frontend Developer Agent
File:.claude/agents/frontend-developer.md
Execution Flow
- Context Discovery - Map existing frontend landscape
- Development Execution - Build components with TypeScript
- Handoff and Documentation - Deliver with tests and docs
Agent-to-Agent Handoffs
Agents can delegate specialized tasks:Tool Permissions
Agents specify which tools they need:Model Selection
Choose the right model for each agent:- Sonnet (Default)
- Opus
- Haiku
Best for: Most development tasks
- Balanced performance and cost
- 200K context window
- Strong coding capabilities
- Good for agents that need to read/write code
Creating Custom Agents
You can create your own agents:1
Create Agent File
Create
.claude/agents/my-agent.md2
Add Frontmatter
Define name, description, tools, and model
3
Write Instructions
Provide clear, specific instructions for the agent’s behavior
4
Test
Invoke the agent in Claude Code:
@my-agent Task descriptionFor detailed guidance on creating agents, see Creating Components.
Agent Best Practices
1. Clear Scope Definition
Define exactly when to use the agent:2. Context Gathering
Always gather context before starting work:- Query context-manager for project information
- Check existing patterns and conventions
- Validate assumptions with targeted questions
3. Structured Communication
Provide clear status updates:4. Documentation
Document all deliverables:- File locations and purposes
- Integration points
- Configuration changes
- Next steps
Global Agents
Create agents that work across all projects:~/.claude/agents/ and available everywhere.
Next Steps
Browse Agent Library
Explore 400+ available agents
Create Custom Agents
Build your own specialized agents
Commands
Learn about custom slash commands
Global Agents
Create globally accessible agents