Sub-Agents in Claude Code – Context, Delegation, and Focus By the end of this lesson, students should be able to: The complete delegation structure. An effective sub-agent task delegation has five components: Goal specification. Vague: "Review the authentication code." Specific: "Identify all places in The specific goal gives the sub-agent a precise success criterion. The vague goal produces a general "review" with no defined scope of findings. Output format specification. Standardized output format enables the parent to aggregate findings from multiple sub-agents without reformatting: “` Return your findings as a list in this format: If no issues are found, return: "No issues found in scope." “` When multiple sub-agents return findings in the same format, the parent can concatenate and sort without parsing. Background – what the sub-agent needs to know. Provide only project-specific context the sub-agent cannot get from CLAUDE.md alone: Stop conditions. A complete delegation for a documentation coverage sub-agent: "Goal: Identify functions and classes in src/api/ that have no JSDoc documentation. Scope: Read-only access to src/api/ only. Do not modify files. Background: This is a TypeScript API codebase. Functions decorated with @internal are exempt from documentation requirements. Output format: Return a list: - [file path]:[line number] - [function/class name] for each undocumented item. If all items are documented, return: 'All public API items in src/api/ are documented.' Stop condition: If you find more than 50 undocumented items, stop and return the first 50 with a note that the full list was truncated." This delegation is ready to send: specific goal, clear scope, relevant background, structured output, and a defined stop condition. Sub-agent task delegations that include "fix" or "update" instructions (not just "identify") grant the sub-agent write access intent. Before delegating a writing task to a sub-agent, ensure: (1) the sub-agent is scoped to the right files, (2) the change type is specific (not "improve the code"), and (3) the sub-agent's output is reviewed before the changes are committed – just as with any AI-generated code change. Log in and enroll to access lesson quizzes.
Lesson 3: Delegating Tasks Effectively to Sub-Agents
Lesson Objectives
Lesson Content
src/auth/ where session tokens are stored or transmitted without encryption – return file, line number, and a description of the vulnerability."[file path] | Line: [line number] | Severity: [High/Medium/Low] | Issue: [one sentence]Practical Example
Safety Notes