Course navigation
Claude SkillsLesson 14 of 15

Skills with Subagents

A skill does not have to do everything itself. With the Task tool enabled in allowed-tools, your skill becomes an orchestrator — it spawns parallel child Claude instances, each handling one subtask, then collects and synthesises their output.

What is a subagent?

In Claude Code, a subagent is a separate Claude instance that your orchestrating skill spawns to handle one specific piece of work.

PropertyBehaviour
Runs independentlyDoes not share memory with the orchestrator or other subagents
Runs in parallelMultiple subagents work at the same time, saving wall-clock time
Returns a resultSends its output back to the orchestrator when done
Has a narrow focusGiven a single well-defined task, not the whole problem
Subagents require Claude Code (the CLI tool). They do not work in claude.ai chat skills. The Task tool is only available in Claude Code.

How it works

StepWhat happens
1You invoke the skill (e.g. /research "React Server Components")
2Orchestrator Claude reads SKILL.md and sees allowed-tools: [Task]
3Orchestrator spawns subagents in parallel — e.g. docs, community, comparisons
4All subagents complete; orchestrator receives their text output
5Orchestrator synthesises findings into one structured report

The key ingredient: allowed-tools

By default, skills do not have access to any tools. To enable subagents, add Task to the allowed-tools list in the frontmatter. Add any other tools your subagents will need too.

No subagent access

SKILL.md
---
name: research
description: Research a topic.
---

## Steps
1. Research the topic.

Subagents enabled

SKILL.md
---
name: research
description: Research a topic.
allowed-tools:
  - Task
  - WebSearch
---

## Steps
1. Spawn subagents via the Task tool.

Example 1 — /research

A single command spawns three subagents in parallel — one per angle — then returns one synthesised report. Without subagents this would require three separate conversations.

SKILL.md
---
name: research
description: >
  Research a topic using three parallel subagents.
  Usage: /research <topic>
  Example: /research "React Server Components"
  Outputs a structured summary covering docs, community, and comparisons.
allowed-tools:
  - Task
  - WebSearch
---

## Role
You are a research coordinator. Delegate subtasks to subagents, then
synthesise their results into one clear report.

## Steps
1. Read the topic the user provides after the command.
2. Spawn three subagents in parallel using the Task tool:
   - Subagent A: Search official documentation and specs.
   - Subagent B: Search community discussions, blog posts, and tutorials.
   - Subagent C: Find comparisons with alternative approaches.
3. Wait for all three subagents to return.
4. Synthesise the results into one report.

## Output format
### Overview
One paragraph summary.

### Key findings
- Bullet per important finding (source: A/B/C)

### Comparisons
Short table if relevant.

### Recommended next step
One sentence.

## Constraints
- Do not add findings that subagents did not return.
- Keep the total output under 600 words.
Claude Code
$ /research "React Server Components"
◆ Spawning subagents...
├─ [A] Searching official docs & specs
├─ [B] Searching community posts & tutorials
└─ [C] Finding comparisons with alternatives
◆ Waiting for results...
[A] Returned 4 findings
[B] Returned 6 findings
[C] Returned 3 findings
◆ Synthesising...
### Overview
React Server Components (RSC) run on the server and stream HTML
to the client without shipping their JS bundle to the browser.
### Key findings
- RSC reduces client bundle size by up to 60% in typical apps [A]
- Async/await is supported directly inside server components [A]
- Community reports improved LCP on data-heavy pages [B]
- Compared to Remix: RSC is granular; Remix loaders are simpler [C]
### Recommended next step
Start with the Next.js App Router quickstart to try RSC locally.
Done (3 subagents, ~8 s total)

Example 2 — /audit

Review every TypeScript file in a directory by spawning one dedicated subagent per file. Each subagent reads only its file and reports findings independently. The output format ends with a Summary: line — that is part of the skill output, not this lesson.

SKILL.md
---
name: audit
description: >
  Audit every TypeScript file in a directory for issues.
  Usage: /audit <directory>
  Example: /audit src/api
  Spawns one subagent per file; collects and ranks all findings.
allowed-tools:
  - Task
  - Read
  - Bash
---

## Context
- Date: $CURRENT_DATE
- Files: $(find ${directory} -name "*.ts" | head -20)

## Steps
1. Read the file list from context.
2. For each file, spawn a subagent with the Task tool:
   - Give the subagent the file path.
   - Ask it to list Critical, Warning, and Suggestion findings.
3. Collect all subagent results.
4. De-duplicate overlapping findings.
5. Rank by severity: Critical first.

## Output format
## Audit — ${directory}
For each file with findings:
  ### filename.ts
  - [Critical]: description
  - [Warning]: description
  - [Suggestion]: description

## Summary
X critical, Y warnings, Z suggestions across N files.
claude-code · /audit src/api
Spawned 4 subagents for: auth.ts · tokens.ts · middleware.ts · helpers.ts

Audit — src/api

auth.ts

[Critical] jwt.verify does not check expiry

[Warning] process.env.SECRET is not guarded at startup

middleware.ts

[Warning] rate-limiter applied after auth check

[Suggestion] extract token extraction into a shared helper

helpers.ts · tokens.ts

No critical or warning findings.

Summary: 1 critical, 2 warnings, 1 suggestion across 4 files
The Summary line is skill output format — defined in SKILL.md ## Output format

Best practices

  • Give each subagent one job — narrow tasks return more accurate results than broad instructions.
  • Do not nest subagents — keep the hierarchy to one level: orchestrator spawns subagents only.
  • Only request tools subagents need — unnecessary tool access increases risk and slows the run.
  • Collect, then synthesise — the final Step must combine subagent results into one report.
  • Keep subagent count reasonable — 2–5 subagents is a sweet spot; more than 10 can hit rate limits.

When to use subagents vs a single skill

SituationUse subagents?Why
Multiple independent search queriesYesQueries have no dependency; parallel is faster
Review N files independentlyYesEach file is self-contained; one subagent per file is clean
Sequential steps (A depends on B)NoSubagents cannot share state; orchestrate sequentially instead
One focused transformation taskNoA single Claude invocation is faster and simpler
Tasks needing shared memoryNoSubagents are isolated — use a single skill with context instead
Gathering data from multiple sourcesYesEach source is independent; parallelism cuts total time
The simplest subagent skill to start with is a /research skill with 2–3 subagents. Verify output quality there, then apply the same pattern to your own use case.

Before you continue

  • Add Task to allowed-tools to enable subagent spawning in Claude Code.
  • Orchestrator skills delegate parallel work, then synthesise results into one report.
  • Use subagents for independent parallel tasks — not sequential or shared-memory work.
  • Keep subagent count to 2–5 and give each one a narrow, specific job.
  • Next lesson: Share and Distribute Skills.

What's Next

Sub-agents extend what a single skill can do. Next: packaging and sharing skills with your team.