Aulafy

Subagents

Subagents are "specialized helpers" that Claude Code can launch to work in parallel: one reviews code, another researches, another writes tests... while the main agent coordinates and you only review the results.

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).

TerminalCode
.claude/agents/
├── revisor.md
├── depurador.md
└── investigador.md

Example: a code reviewer subagent

TerminalCode
---
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

TerminalCode
@"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

TerminalCode
# Lanzar con un subagente concreto
claude --agent revisor

# Ver, monitorizar y gestionar subagentes en paralelo
claude agents

Creating one without knowing YAML

Subagents in parallel (real example)