Retour aux podcastsClaude
Claude Code subagents
Créer un sous-agent
In the previous video, we covered what sub aents are and how they work.
Dans la vidéo précédente, nous avons vu ce que sont les sous-agents et comment ils fonctionnent.
Cloud code includes built-in sub aents, but you can also create your own sub aents that specialize in certain tasks.
Claude Code inclut des sous-agents intégrés, mais vous pouvez aussi créer vos propres sous-agents spécialisés dans certaines tâches.
Custom sub aents are markdown files with YAML front matter.
Les sous-agents personnalisés sont des fichiers markdown avec un 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.
Ces fichiers markdown contiennent une configuration qui aide Claude à savoir quand utiliser le sous-agent et lui fournit des instructions.
Now, the easiest way to create a sub agent is with the / agents command.
La façon la plus simple de créer un sous-agent est d'utiliser la commande /agents.
This panel is the main interface for managing your sub aents.
Ce panneau est l'interface principale pour gérer vos sous-agents.
Once here, select create new agent.
Ici, sélectionnez Créer un nouvel agent.
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.
Il vous sera demandé si vous souhaitez créer un sous-agent pour le projet actuel ou un sous-agent partagé entre tous les projets de votre machine.
Next, you can create a sub aent manually, but we recommend using claw code to automatically generate it for you.
Vous pouvez créer un sous-agent manuellement, mais nous recommandons d'utiliser Claude Code pour le générer automatiquement.
Our first sub aent will be a code reviewer.
Notre premier sous-agent sera un réviseur de code.
I'll ask Claude to make a sub agent that reviews code quality and security issues.
Je vais demander à Claude de créer un sous-agent qui vérifie la qualité du code et les problèmes de sécurité.
Claude will use your input to generate a name, description, and system prompt for the sub agent.
Claude utilisera votre saisie pour générer un nom, une description et un invite système pour le sous-agent.
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.
Nous les verrons dans un moment, mais avant, nous avons la possibilité de personnaliser les outils auxquels ce sous-agent aura accès.
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.
Notre sous-agent étant uniquement chargé de réviser le code, vous pourriez désactiver les outils d'édition, mais je laisse l'exécution activée pour lui permettre d'identifier plus facilement les modifications en attente.
Next, you'll be prompted to select the model that powers this sub agent.
Ensuite, vous serez invité à sélectionner le modèle qui alimente ce sous-agent.
And finally, a color.
Et enfin, une couleur.
This color is used in the UI to help you better identify the sub agent.
Cette couleur est utilisée dans l'interface pour vous aider à mieux identifier le sous-agent.
And it also just adds a little bit of personal flare.
Elle ajoute aussi une petite touche personnelle.
Now at the summary window, we see that the sub aent config file will be saved into my current project at this path.
Dans la fenêtre récapitulative, nous voyons que le fichier de configuration du sous-agent sera enregistré dans mon projet actuel à ce chemin.
Now let's open up that file to get a better idea of what's going on.
Ouvrons ce fichier pour mieux comprendre ce qu'il contient.
The name field is a unique identifier.
Le champ name est un identifiant unique.
This is how you reference the sub agent either by asking claw directly or using at agent code quality reviewer in your message.
C'est ainsi que vous référencez le sous-agent, soit en demandant directement à Claude, soit en utilisant @agent code-quality-reviewer dans votre message.
The description controls when cla decides to use the sub aent.
Le champ description contrôle quand Claude décide d'utiliser le sous-agent.
The description must be on a single line.
La description doit tenir sur une seule ligne.
Notice that there are escaped new line characters in there.
Notez qu'il y a des caractères de retour à la ligne échappés.
If you want Claude to use the sub agent automatically more often, add in the word proactively to the description.
Si vous souhaitez que Claude utilise automatiquement le sous-agent plus souvent, ajoutez le mot proactively dans la description.
You can also add example conversations to help Claude understand when it should be using the sub agent.
Vous pouvez aussi ajouter des exemples de conversations pour aider Claude à comprendre quand utiliser le sous-agent.
The tools field lists which tools the sub agent can access.
Le champ tools liste les outils auxquels le sous-agent peut accéder.
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 liste des outils correspondra à ceux que nous avons accordés lors de la génération de l'agent, mais vous pouvez modifier cette liste directement dans ce fichier.
The model field specifies which claw model to use.
Le champ model spécifie quel modèle Claude utiliser.
Sonnet, opus, haiku or inherit.
Sonnet, Opus, Haiku ou inherit.
Use haiku for fast tasks.
Utilisez Haiku pour les tâches rapides.
Opus for complex analysis and sonnet if you need something between the two.
Opus pour l'analyse complexe, et Sonnet si vous avez besoin de quelque chose entre les deux.
Inherit will use the same model as your main conversation.
inherit utilisera le même modèle que votre conversation principale.
The body of the file contains the system prompt that is given to the sub aent.
Le corps du fichier contient l'invite système fourni au sous-agent.
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.
L'invite système guide le sous-agent pour lui faire comprendre comment accomplir sa tâche et comment renvoyer les informations à l'agent principal.
Now for the fun part.
Passons maintenant à la partie amusante.
After creating your sub agent, test it by making some code changes and asking claw to review them.
Après avoir créé votre sous-agent, testez-le en apportant des modifications au code et en demandant à Claude de les réviser.
If the sub agent isn't being used when you expect, check your description.
Si le sous-agent n'est pas utilisé comme prévu, vérifiez votre description.
Adding more specific examples helps Claude understand when to delegate.
Ajouter des exemples plus précis aide Claude à comprendre quand déléguer.