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

Lesson 3: Delegating Tasks Effectively to Sub-Agents

Lesson Objectives

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

  • Write a complete sub-agent task delegation with all required components
  • Specify output format to enable parent aggregation
  • Set appropriate stop conditions to manage sub-agent scope
  • Evaluate whether a delegation is ready to send to a sub-agent

Lesson Content

The complete delegation structure.

An effective sub-agent task delegation has five components:

  1. Goal: What the sub-agent must accomplish – specific, measurable
  2. Scope: Which files, directories, or operations are in bounds
  3. Background: What the sub-agent needs to know about the project for this task
  4. Output format: Exactly how the sub-agent should report its findings
  5. Stop conditions: When to stop and return even if not complete

Goal specification.

Vague: "Review the authentication code." Specific: "Identify all places in src/auth/ where session tokens are stored or transmitted without encryption – return file, line number, and a description of the vulnerability."

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:
– File: `[file path]` | Line: [line number] | Severity: [High/Medium/Low] | Issue: [one sentence]

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:

  • The specific component architecture relevant to this task
  • Conventions the sub-agent should respect (do not flag X, Y is intentional)
  • Reference points (the database schema, the API spec)

Stop conditions.

  • Max findings: "Stop and return findings when you have identified 10 issues – do not continue after 10"
  • Max file count: "Analyze up to 20 files – stop and return after 20 even if the directory has more"
  • Decision point: "Stop and ask the parent if you find a pattern that is unclear – do not make assumptions about intent"

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