Voltar aos PodcastsClaude
Claude Code subagents
Usando subagentes de forma eficaz
You know how to create sub agents and design them well.
Já sabes como criar sub-agentes e desenhá-los bem.
Now, let's cover when they actually help and when they get in the way.
Agora, vamos ver quando eles realmente ajudam e quando atrapalham.
Simply put, the difference comes down to whether the intermediate work matters to your main thread.
Em termos simples, a diferença está em saber se o trabalho intermédio importa para o teu thread principal.
When exploration is separate from execution, sub agents shine.
Quando a exploração está separada da execução, os sub-agentes brilham.
When each step depends on what the previous step discovered, well, information gets lost in the handoff process.
Quando cada passo depende do que o passo anterior descobriu, a informação perde-se no processo de transferência.
Sub agents excel at research tasks where you just need an answer, not the journey.
Os sub-agentes destacam-se em tarefas de investigação onde só precisas de uma resposta, não do percurso.
Consider investigating how authentication works in an unfamiliar code base.
Considera investigar como funciona a autenticação numa base de código desconhecida.
Well, the main thread might need to know where is the JWT validated, but doesn't need to see every file that was searched.
O thread principal pode precisar de saber onde é validado o JWT, mas não precisa de ver todos os ficheiros pesquisados.
A research sub agent can read dozens of files, trace through function calls, and explore different code paths.
Um sub-agente de investigação pode ler dezenas de ficheiros, rastrear chamadas de funções e explorar diferentes caminhos de código.
All that exploration stays in the sub agent's context.
Toda essa exploração fica no contexto do sub-agente.
Your main thread receives JWT validation happens in middleware/auth.js at line 42, called from the Express router and route/api.js, or something like that.
O teu thread principal recebe: a validação do JWT acontece em middleware/auth.js na linha 42, chamado a partir do Express router e route/api.js, ou algo parecido.
Claude reviews work more effectively when the code is presented as being authored by someone else.
O Claude revê o trabalho de forma mais eficaz quando o código é apresentado como sendo de outra pessoa.
If you build a feature over many turns with your main thread, asking the main thread to then review it often doesn't give the best feedback.
Se desenvolveres uma funcionalidade ao longo de muitas interações com o teu thread principal, pedir-lhe que a reveja depois nem sempre dá o melhor feedback.
Claude was involved in creating it, so it has trouble seeing it with fresh eyes.
O Claude esteve envolvido na criação, por isso tem dificuldade em vê-la com olhos frescos.
A reviewer sub agent sees the changes in a separate context.
Um sub-agente revisor vê as alterações num contexto separado.
It runs get diff, reads the modified files, and applies its specialized review criteria without the history of how the code was written.
Executa git diff, lê os ficheiros modificados e aplica os seus critérios de revisão especializados sem o histórico de como o código foi escrito.
And this separation also lets you encode project-specific review standards in the sub agent system prompt, ensuring consistent review criteria across the team.
E esta separação também te permite incorporar padrões de revisão específicos do projeto no system prompt do sub-agente, garantindo critérios de revisão consistentes em toda a equipa.
Claude Code's default system prompt emphasizes concise, code-focused response.
O system prompt padrão do Claude Code enfatiza respostas concisas e focadas em código.
And this works great for coding, but not for everything.
E isso funciona muito bem para programar, mas não para tudo.
So, one is a copywriting sub-agent with instructions about tone, audience, and style.
Então, um sub-agente de copywriting com instruções sobre tom, audiência e estilo.
This will produce better marketing text than the main thread would.
Isso vai produzir textos de marketing melhores do que o thread principal produziria.
Claude Code's default prompt tends towards concise, technical writing, which really isn't what you want for a landing page or email campaign, unless you want to put your customers to sleep.
O prompt padrão do Claude Code tende para uma escrita técnica e concisa, o que não é o que queres para uma landing page ou campanha de email, a não ser que queiras adormecer os teus clientes.
A copywriting sub-agent can have completely different instructions about voice and structure.
Um sub-agente de copywriting pode ter instruções completamente diferentes sobre voz e estrutura.
A styling sub-agent that at mentions your design system files will apply consistent CSS patterns.
Um sub-agente de estilo que mencione os teus ficheiros de design system vai aplicar padrões CSS consistentes.
When the sub-agent runs, those files load into the context automatically, so it knows your color variables, spacing conventions, and component patterns before it even starts writing any CSS.
Quando o sub-agente corre, esses ficheiros carregam automaticamente para o contexto, para que ele conheça as tuas variáveis de cor, convenções de espaçamento e padrões de componentes antes de começar a escrever qualquer CSS.
Sub-agents that claim expertise rarely help.
Sub-agentes que alegam ter experiência raramente ajudam.
Prompts like, "You are a Python expert." or "You are a Kubernetes specialist." add no value because Claude already has that knowledge.
Prompts como "És um especialista em Python" ou "És um especialista em Kubernetes" não acrescentam valor porque o Claude já tem esse conhecimento.
The overhead of launching a sub-agent, losing visibility into its work, and compressing its findings into a summary only makes sense when the sub-agent does something that the main thread can't.
O custo de lançar um sub-agente, perder visibilidade sobre o seu trabalho e comprimir as suas descobertas num resumo só faz sentido quando o sub-agente faz algo que o thread principal não consegue.
Like applying a custom system prompt or keeping exploratory work isolated.
Como aplicar um system prompt personalizado ou manter o trabalho exploratório isolado.
Sequential sub-agent pipelines create problems.
Pipelines sequenciais de sub-agentes criam problemas.
Consider a three-agent flow.
Considera um fluxo de três agentes.
One to reproduce a bug, one to debug it, and one to fix it.
Um para reproduzir um bug, outro para o depurar e outro para o corrigir.
Pipelines work when tasks are truly independent.
Os pipelines funcionam quando as tarefas são verdadeiramente independentes.
They fail when each step depends on discoveries from the previous step.
Falham quando cada passo depende das descobertas do passo anterior.
Test runner sub-agents tend to hide information you need.
Sub-agentes de execução de testes tendem a esconder informação de que precisas.
When tests fail, you want the full output to diagnose issues.
Quando os testes falham, queres o output completo para diagnosticar os problemas.
A sub-agent that returns a test failed forces you to create additional debug scripts to get details that would have been visible in direct output.
Um sub-agente que devolve apenas "teste falhado" obriga-te a criar scripts de depuração adicionais para obter detalhes que teriam sido visíveis no output direto.
Testing has showed that the test runner pattern performed worse among all configurations.
Os testes mostraram que o padrão de sub-agente para execução de testes teve o pior desempenho entre todas as configurações.
Across the series, we covered how sub-agents work as isolated threads that return summaries.
Ao longo da série, vimos como os sub-agentes funcionam como threads isoladas que devolvem resumos.
How to create them with the /agents command, and how to design them with structured outputs and specific descriptions.
Como criá-los com o /agents command, e como desenhá-los com outputs estruturados e descrições específicas.
Use them for research, reviews, and tasks needing custom system prompts.
Usa-os para investigação, revisões e tarefas que precisam de system prompts personalizados.
But, avoid them for expert claims, multi-step pipelines, and test runners.
Mas evita-os para alegações de especialização, pipelines de múltiplos passos e executores de testes.
The key question, does the intermediate work matter?
A questão-chave: o trabalho intermédio importa?
If not, then delegate it.
Se não, então delega.