LESSON · 1 OF 3

What subagents are

What subagents are

When a job is big or self-contained, Claude can hand it to a subagent: a separate helper that runs the task in its own context and reports back just the result. Claude does this through the Task tool. The main conversation stays focused, and the subagent's noisy intermediate steps never clutter your thread.

Why delegate

Two reasons come up again and again:

  • Keep the main context clean. A subagent that reads twenty files to answer one question returns only the answer. The twenty files never enter your main conversation.
  • Run independent work in parallel. Several subagents can work at once on jobs that do not depend on each other, then report back.

Good candidates are a big search across a codebase, or a well-bounded task like "review this directory and summarize what each file does."

Custom agent types

Beyond the built-in general agent, you can define your own agent types. Each is a markdown file under .claude/agents/<name>.md with YAML frontmatter and a body that describes the agent's job:

markdown
---
name: reviewer
description: Reviews code changes for bugs and risky edits
tools: Read, Grep, Bash
---
You are a code reviewer. Read the changed files, look for bugs, missing
error handling, and anything risky to ship. Report findings as a short list.
Frontmatter keyWhat it does
nameThe agent type's identifier
descriptionWhen Claude should reach for this agent
toolsWhich tools the agent may use (optional)

The body is the agent's system prompt - its standing instructions.

Managing agents

Run /agents in the console to list, create, and edit agent types. Once an agent exists and its description fits the job, Claude can delegate to it on its own, or you can ask for it by name.

Next, define a reviewer agent of your own.


Your lab setup

This VM comes with Claude Code preinstalled and signed in - just run claude to start.

Spin up a fresh environment and practice live.
claude-code-ubuntu · fresh machine · ready in under a minute