Sub-Agents in Claude Code – Context, Delegation, and Focus

Lesson 2: Spawning and Configuring Sub-Agents

Lesson Objectives

By the end of this lesson, students should be able to:

  • Initiate a sub-agent spawn in Claude Code Cowork mode
  • Transfer the right context to a sub-agent
  • Configure a sub-agent's task scope and file access
  • Understand what the sub-agent inherits from the parent vs. what must be explicitly provided

Lesson Content

How sub-agents are spawned.

Sub-agents in Claude Code are spawned within Cowork/Agent mode. The parent agent spawns a sub-agent by providing it with a task description and relevant context. The sub-agent runs as a separate agent instance and returns results when complete. Verify current sub-agent spawn syntax and configuration at docs.anthropic.com/en/docs/claude-code.

Context transfer – what to give the sub-agent.

A sub-agent starts with a fresh context window. It does not inherit the parent's conversation history – it starts with only what you explicitly give it. Transfer:

  • Task description: Specific, measurable goal for the sub-agent
  • Scope: Which files or directories the sub-agent should work in
  • Relevant background: What the sub-agent needs to know about the project to do its task
  • Expected output format: How the sub-agent should report its findings

Do NOT transfer the entire parent conversation history – that defeats the purpose of a focused context window. Transfer only what this sub-agent needs for its specific task.

Task description quality for sub-agents.

Sub-agent task descriptions follow the same quality rules as Cowork mode tasks:

  • Specific and measurable ("identify all SQL queries that are not using parameterized inputs in src/db/")
  • Scoped file access ("only read files in src/db/ – do not modify any files")
  • Defined output format ("return a list of file paths and line numbers for each finding, with a brief description of the issue")
  • Defined stop conditions ("stop if you find more than 20 issues – return what you have found so far")

What sub-agents inherit.

Sub-agents in Claude Code inherit: the CLAUDE.md context for the project directory, available Skills, and the MCP servers configured for the project. They do NOT inherit: the parent's conversation history, intermediate findings, or decisions made during the parent session.

Enroll to continue this lesson.

The preview above shows the lesson objectives and opening lesson content. Enroll to view the full lesson, complete the practice work, and take the lesson quiz.

Log In / Create Account
Back to Course