Sub-Agents in Claude Code – Context, Delegation, and Focus By the end of this lesson, students should be able to: Multi-agent workflow design. A multi-agent workflow has three layers: Design starts with decomposition: what are the distinct subtasks that benefit from focused context? Each distinct subtask is a candidate for a sub-agent. Parallel vs. sequential sub-agents. Parallel: Sub-agents that do not depend on each other's results can run simultaneously. A security sub-agent and a performance sub-agent analyzing the same codebase are independent – run them in parallel to save time. Sequential: Sub-agents where the output of one informs the input of the next must run in order. A "discover failing tests" sub-agent must complete before a "fix failing tests" sub-agent can be scoped – it needs the list of failing tests. Most multi-agent workflows have both patterns: some parallel sub-agents in the analysis phase, some sequential in the remediation phase. The parent-aggregates pattern. The parent agent should not attempt complex reasoning during aggregation – it should collect structured sub-agent outputs and combine them: “` Phase 1 – Spawn and run parallel analysis sub-agents: Phase 2 – Aggregate: Phase 3 – Remediation (optional): “` Knowing when the workflow is too complex. Multi-agent workflows have coordination overhead. If the workflow requires more than four to five sub-agents, complex dependency management, or multiple aggregation phases – consider whether the task can be decomposed differently, or whether the complexity warrants a more formal orchestration approach than ad-hoc Cowork mode sub-agents. A developer builds a "pre-release audit" multi-agent workflow: He runs this workflow before every major release. The pre-release audit that previously took a full day of manual review takes ninety minutes of automated sub-agent execution plus thirty minutes of his review time. The structured output format from all sub-agents makes the aggregation step trivial. Multi-agent workflows with write-access sub-agents in the remediation phase can make widespread, hard-to-review changes. For Phase 3 (remediation) sub-agents: always review the finding before spawning the remediation sub-agent, review the sub-agent's proposed changes before committing, and use feature branches so all changes can be reviewed as a unit in a PR. Automated multi-agent remediation without review is how AI-assisted technical debt compounds quickly. Log in and enroll to access lesson quizzes.
Lesson 4: Building Multi-Agent Workflows
Lesson Objectives
Lesson Content
Practical Example
Safety Notes