Volver a PodcastsClaude
Claude Code subagents
Crear un subagente
In the previous video, we covered what sub aents are and how they work.
En el video anterior, vimos qué son los subagentes y cómo funcionan.
Cloud code includes built-in sub aents, but you can also create your own sub aents that specialize in certain tasks.
Claude Code incluye subagentes integrados, pero también puedes crear tus propios subagentes especializados en ciertas tareas.
Custom sub aents are markdown files with YAML front matter.
Los subagentes personalizados son archivos markdown con frontmatter YAML.
These markdown files contain configuration that helps claude understand when to use the sub aent and provides directions to the sub aent itself.
Estos archivos markdown contienen configuración que ayuda a Claude a saber cuándo usar el subagente y le proporciona instrucciones.
Now, the easiest way to create a sub agent is with the / agents command.
La forma más fácil de crear un subagente es usar el comando /agents.
This panel is the main interface for managing your sub aents.
Este panel es la interfaz principal para gestionar tus subagentes.
Once here, select create new agent.
Aquí, selecciona Crear nuevo agente.
You'll then be asked if you want to create a sub aent for the current project or a sub aent that will be shared between all the projects on your machine.
Se te preguntará si quieres crear un subagente para el proyecto actual o uno que se comparta entre todos los proyectos de tu máquina.
Next, you can create a sub aent manually, but we recommend using claw code to automatically generate it for you.
Puedes crear un subagente manualmente, pero recomendamos usar Claude Code para generarlo automáticamente.
Our first sub aent will be a code reviewer.
Nuestro primer subagente será un revisor de código.
I'll ask Claude to make a sub agent that reviews code quality and security issues.
Le pediré a Claude que cree un subagente que revise la calidad del código y los problemas de seguridad.
Claude will use your input to generate a name, description, and system prompt for the sub agent.
Claude usará tu entrada para generar un nombre, descripción e indicación de sistema para el subagente.
We'll see those in a moment, but before we do, we get the opportunity to customize the tools that this sub agent has access to.
Los veremos en un momento, pero antes tenemos la oportunidad de personalizar las herramientas a las que tendrá acceso este subagente.
Now, given that our sub agent is only responsible for reviewing code, you might decide to disallow tools for editing, but I'll leave an execution to allow the sub agent to more easily identify pending changes.
Como nuestro subagente solo se encarga de revisar código, podrías desactivar las herramientas de edición, pero dejo la ejecución habilitada para que pueda identificar más fácilmente los cambios pendientes.
Next, you'll be prompted to select the model that powers this sub agent.
A continuación, se te pedirá que selecciones el modelo que potencia este subagente.
And finally, a color.
Y por último, un color.
This color is used in the UI to help you better identify the sub agent.
Este color se usa en la interfaz para identificar mejor el subagente.
And it also just adds a little bit of personal flare.
También añade un toque personal.
Now at the summary window, we see that the sub aent config file will be saved into my current project at this path.
En la ventana de resumen, vemos que el archivo de configuración del subagente se guardará en mi proyecto actual en esta ruta.
Now let's open up that file to get a better idea of what's going on.
Abrimos ese archivo para entender mejor qué contiene.
The name field is a unique identifier.
El campo name es un identificador único.
This is how you reference the sub agent either by asking claw directly or using at agent code quality reviewer in your message.
Así es como referencias el subagente, ya sea pidiéndoselo directamente a Claude o usando @agent code-quality-reviewer en tu mensaje.
The description controls when cla decides to use the sub aent.
El campo description controla cuándo Claude decide usar el subagente.
The description must be on a single line.
La descripción debe estar en una sola línea.
Notice that there are escaped new line characters in there.
Nota que hay caracteres de nueva línea escapados.
If you want Claude to use the sub agent automatically more often, add in the word proactively to the description.
Si quieres que Claude use el subagente automáticamente con más frecuencia, añade la palabra proactively en la descripción.
You can also add example conversations to help Claude understand when it should be using the sub agent.
También puedes agregar conversaciones de ejemplo para ayudar a Claude a entender cuándo usar el subagente.
The tools field lists which tools the sub agent can access.
El campo tools lista las herramientas a las que puede acceder el subagente.
The list of tools will match the tools we granted access to during the agent generation, but you can further edit the list of tools in this file if you want.
La lista de herramientas coincidirá con las que concedimos durante la generación del agente, pero puedes editar esta lista directamente en el archivo.
The model field specifies which claw model to use.
El campo model especifica qué modelo de Claude usar.
Sonnet, opus, haiku or inherit.
Sonnet, Opus, Haiku o inherit.
Use haiku for fast tasks.
Usa Haiku para tareas rápidas.
Opus for complex analysis and sonnet if you need something between the two.
Opus para análisis complejos y Sonnet si necesitas algo intermedio.
Inherit will use the same model as your main conversation.
inherit usará el mismo modelo que tu conversación principal.
The body of the file contains the system prompt that is given to the sub aent.
El cuerpo del archivo contiene la indicación de sistema que se le da al subagente.
The system prompt will provide guidance to the sub agent, helping it understand how to complete its task and how it should return information back to the main agent.
La indicación de sistema proporciona orientación al subagente, ayudándolo a entender cómo completar su tarea y cómo devolver la información al agente principal.
Now for the fun part.
Ahora viene la parte divertida.
After creating your sub agent, test it by making some code changes and asking claw to review them.
Después de crear tu subagente, pruébalo haciendo algunos cambios en el código y pidiéndole a Claude que los revise.
If the sub agent isn't being used when you expect, check your description.
Si el subagente no se usa cuando lo esperas, revisa tu descripción.
Adding more specific examples helps Claude understand when to delegate.
Agregar ejemplos más específicos ayuda a Claude a entender cuándo delegar.