Назад к подкастамClaude
Claude Code subagents
Создание субагента
In the previous video, we covered what sub aents are and how they work.
В предыдущем видео мы рассмотрели, что такое субагенты и как они работают.
Cloud code includes built-in sub aents, but you can also create your own sub aents that specialize in certain tasks.
Claude Code включает встроенные субагенты, но вы также можете создавать собственные, специализированные на определённых задачах.
Custom sub aents are markdown files with YAML front matter.
Пользовательские субагенты это Markdown-файлы с YAML front matter.
These markdown files contain configuration that helps claude understand when to use the sub aent and provides directions to the sub aent itself.
Эти Markdown-файлы содержат конфигурацию, помогающую Claude понять, когда использовать субагент, и инструкции для самого субагента.
Now, the easiest way to create a sub agent is with the / agents command.
Проще всего создать субагент с помощью команды /agents.
This panel is the main interface for managing your sub aents.
Эта панель является основным интерфейсом для управления субагентами.
Once here, select create new agent.
Здесь выберите 'Create New 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.
Вас спросят, создать ли субагент для текущего проекта или субагент, общий для всех проектов на вашей машине.
Next, you can create a sub aent manually, but we recommend using claw code to automatically generate it for you.
Субагент можно создать вручную, но мы рекомендуем использовать Claude Code для автоматической генерации.
Our first sub aent will be a code reviewer.
Наш первый субагент будет ревьюером кода.
I'll ask Claude to make a sub agent that reviews code quality and security issues.
Попрошу Claude создать субагент, который проверяет качество кода и проблемы безопасности.
Claude will use your input to generate a name, description, and system prompt for the sub agent.
Claude использует ваши данные для генерации имени, описания и системного промпта субагента.
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.
Это мы увидим чуть позже, но сначала у нас есть возможность настроить инструменты, доступные этому субагенту.
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.
Поскольку субагент отвечает только за проверку кода, вы можете запретить инструменты редактирования, но я оставлю выполнение, чтобы субагент мог легче выявлять ожидающие изменения.
Next, you'll be prompted to select the model that powers this sub agent.
Затем вас попросят выбрать модель для этого субагента.
And finally, a color.
И наконец, цвет.
This color is used in the UI to help you better identify the sub agent.
Этот цвет используется в интерфейсе для удобной идентификации субагента.
And it also just adds a little bit of personal flare.
А ещё добавляет немного личного стиля.
Now at the summary window, we see that the sub aent config file will be saved into my current project at this path.
В окне сводки видно, что файл конфигурации субагента будет сохранён в текущем проекте по этому пути.
Now let's open up that file to get a better idea of what's going on.
Откроем этот файл, чтобы лучше понять, что происходит.
The name field is a unique identifier.
Поле name является уникальным идентификатором.
This is how you reference the sub agent either by asking claw directly or using at agent code quality reviewer in your message.
Так вы ссылаетесь на субагент: напрямую спрашивая Claude или используя @agent code quality reviewer в сообщении.
The description controls when cla decides to use the sub aent.
Description управляет тем, когда Claude решает использовать субагент.
The description must be on a single line.
Description должен быть на одной строке.
Notice that there are escaped new line characters in there.
Обратите внимание на экранированные символы новой строки.
If you want Claude to use the sub agent automatically more often, add in the word proactively to the description.
Чтобы Claude использовал субагент автоматически чаще, добавьте слово 'proactively' в описание.
You can also add example conversations to help Claude understand when it should be using the sub agent.
Можно также добавить примеры диалогов, чтобы Claude лучше понимал, когда применять субагент.
The tools field lists which tools the sub agent can access.
Поле tools перечисляет инструменты, доступные субагенту.
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.
Список инструментов соответствует правам доступа, выданным при генерации агента, но вы можете дополнительно отредактировать его в этом файле.
The model field specifies which claw model to use.
Поле model указывает, какую модель Claude использовать.
Sonnet, opus, haiku or inherit.
Sonnet, Opus, Haiku или inherit.
Use haiku for fast tasks.
Haiku подходит для быстрых задач.
Opus for complex analysis and sonnet if you need something between the two.
Opus для сложного анализа, Sonnet если нужно что-то среднее.
Inherit will use the same model as your main conversation.
Inherit использует ту же модель, что и основной разговор.
The body of the file contains the system prompt that is given to the sub aent.
Тело файла содержит системный промпт, передаваемый субагенту.
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.
Системный промпт инструктирует субагент, помогая ему понять, как выполнить задачу и как вернуть информацию основному агенту.
Now for the fun part.
Теперь самое интересное.
After creating your sub agent, test it by making some code changes and asking claw to review them.
После создания субагента протестируйте его: внесите изменения в код и попросите Claude проверить их.
If the sub agent isn't being used when you expect, check your description.
Если субагент не используется, когда вы этого ожидаете, проверьте описание.
Adding more specific examples helps Claude understand when to delegate.
Более конкретные примеры помогают Claude понять, когда делегировать задачи.