Anthropic / Claude Code9 minLesson 7 of 60

Subagents: Delegating to Specialists

A subagent is a focused worker the main agent can hand a job to. It runs in its own context window with its own instructions, does the task, and reports back a summary. The big win is that all the noisy intermediate work stays out of your main session.

Why isolate the work

Say you need a wide search across the codebase. Doing it inline floods your main window with file dumps you will never look at again. A search subagent reads all of that in its own context and hands back only the conclusion. Your main thread stays clean and sharp.

Good candidates for a subagent

  • Broad searches where you only need the answer, not the files.
  • Repetitive, well-defined jobs like writing tests for a module.
  • Reviews, where a fresh perspective helps.
  • Anything you would run in parallel with other work.
One job each
Give a subagent a single, clear responsibility and a clear definition of done. A subagent with a fuzzy mandate wanders just like a person would.
Claude Code Tutorial - Subagents
Claude Code Tutorial - Subagents· Net Ninja
Subagents (Claude Code docs)How to define and use subagents with their own context and tools.code.claude.com
Finished this lesson? Mark it read to track your progress.