What are they for?
On large tasks, instead of doing everything linearly, Claude Code can distribute work among several subagents with specific roles (reviewer, planner, debugger, researcher). Benefits:
- Parallelism: several working at once = faster.
- Clean context: each subagent has its own "memory", without mixing.
- Specialization: each one with its own instructions and tools.
- Background: they can run in the background without blocking you.
Creating a subagent
A subagent is a Markdown file with YAML frontmatter (configuration) and a body that serves as its system prompt (its personality and role instructions).
.claude/agents/ ├── revisor.md ├── depurador.md └── investigador.md
Example: a code reviewer subagent
--- name: revisor description: Revisa código en busca de bugs y malas prácticas. Úsalo tras escribir o cambiar código. tools: Read, Grep, Glob model: sonnet color: blue --- Eres un revisor de código senior. Tu trabajo es leer los cambios y encontrar: - Bugs potenciales y casos límite no cubiertos. - Nombres poco claros y código difícil de mantener. - Problemas de seguridad. No edites archivos: solo informa de lo que encuentres, ordenado por gravedad. Sé directo pero constructivo.
Frontmatter fields
Where they are stored
- Project (recommended): .claude/agents/<nombre>.md
- Personal: ~/.claude/agents/<nombre>.md
- Via plugin: inside the plugin ( agents/... )
- Session only: with the --agents '{...}' flag (not saved to disk)
How to invoke them
Natural delegation
Simply ask the main agent:
Direct mention
@"revisor (agent)" revisa src/pagos.ts
Interactive assistant
Use the /agents command to open an assistant that guides you through creating and managing subagents without writing YAML by hand.
From the terminal
# Lanzar con un subagente concreto claude --agent revisor # Ver, monitorizar y gestionar subagentes en paralelo claude agents