.claude/skills/workflow/spawn-subagents/SKILL.md
Guidelines for spawning subagents to maintain clean context. Use for research tasks, parallel coding, verification, or any work benefiting from isolated context. Patterns by agent type.
npx skillsauth add brdohman/agile-maestro spawn-subagentsInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Use subagents liberally. They provide:
| Task Type | Why | |-----------|-----| | Research/Exploration | Keeps main context clean for decisions | | Code Generation (ViewModel, View, Service) | Each component gets focused context | | Test Writing | Separate concern from implementation | | Documentation | Don't pollute impl context with docs | | Verification/Validation | Clean run of tests, linting | | File Searches | Grep/Glob across codebase | | External Reviews | Claude review alongside Gemini/OpenCode |
| Task Type | Why | |-----------|-----| | Coordination | Need full picture to orchestrate | | Integration Decisions | Must see how pieces fit together | | User Communication | Context of conversation | | Final Assembly | Combining subagent outputs |
Append to any prompt for automatic delegation:
Refactor the authentication module. Use subagents.
Claude will spawn child agents for subtasks automatically.
Use the Task tool with specific agent types:
Task tool:
subagent_type: "macos-developer"
prompt: "Implement the LoginViewModel with these requirements..."
For independent work, run multiple subagents simultaneously:
# All three run in parallel
Task 1: subagent_type: "macos-developer", run_in_background: true
→ Implement ViewModel
Task 2: subagent_type: "macos-developer", run_in_background: true
→ Implement View
Task 3: subagent_type: "qa", run_in_background: true
→ Write test plan
When implementing a feature, spawn subagents for:
Main Agent (Coordinator)
├── Subagent 1: Research existing patterns in codebase
├── Subagent 2: Implement ViewModel
├── Subagent 3: Implement View (after ViewModel)
├── Subagent 4: Implement Service (if needed)
└── Subagent 5: Write unit tests
Coordination responsibilities:
When reviewing code, spawn subagents for:
Main Agent (Reviewer)
├── Subagent 1: Check architecture compliance
├── Subagent 2: Check Swift best practices
├── Subagent 3: Check test coverage
└── Subagent 4: Check security concerns
When testing, spawn subagents for:
Main Agent (Test Coordinator)
├── Subagent 1: Verify acceptance criteria 1-3
├── Subagent 2: Verify acceptance criteria 4-6
├── Subagent 3: Run edge case tests
└── Subagent 4: Run regression tests
When creating epics, spawn subagents for:
Main Agent (Planner)
├── Subagent 1: Analyze PRD.md
├── Subagent 2: Analyze TECHNICAL_SPEC.md
├── Subagent 3: Analyze IMPLEMENTATION_GUIDE.md
└── Main: Synthesize into epic
Long conversations accumulate context. By turn 50+, the context window is full of:
Spawn subagents for discrete tasks. Each subagent:
Without subagents (bad):
Turn 1: Read 10 files to understand codebase
Turn 2: Research patterns
Turn 3-10: Try implementation approach A (failed)
Turn 11-20: Try implementation approach B (failed)
Turn 21-30: Try implementation approach C (succeeded)
→ Context now full of failed attempts, stale file reads
With subagents (good):
Main Turn 1: Spawn research subagent
Subagent: Read files, return summary
→ Main receives: 500 token summary (not 10 files)
Main Turn 2: Spawn impl subagent with approach A
Subagent: Try approach A, fails
→ Main receives: "Approach A failed because X"
Main Turn 3: Spawn impl subagent with approach B
Subagent: Try approach B, succeeds
→ Main receives: Files created, test results
→ Main context stays clean, only has summaries
1. Read the output
2. Verify it meets requirements
3. Integrate into main work
4. Continue to next step
1. Read the error/failure reason
2. Decide: retry with different approach, or escalate
3. If retry: spawn new subagent with adjusted prompt
4. If escalate: report to user
1. Check if output file has partial results
2. Use what's available
3. Spawn replacement for remaining work
4. Note the issue in task comments
| Don't | Do Instead |
|-------|------------|
| Do everything in main context | Spawn subagents for discrete tasks |
| Spawn one giant subagent | Break into multiple focused subagents |
| Ignore subagent failures | Handle failures, retry or escalate |
| Duplicate work across subagents | Define clear boundaries |
| Wait sequentially for parallel tasks | Use run_in_background: true |
run_in_background: true for slow tasksmodel: "haiku" for simple tasksAll agents defined in .claude/agents/ can be used as subagent types:
| Agent | subagent_type |
|-------|---------------|
| macOS Developer | macos-developer |
| Staff Engineer | techlead |
| QA | qa |
| PM | pm |
| Build Engineer | build-engineer |
| Security | security |
| Designer | designer-agent |
| Data Architect | data-architect-agent |
| Planning | planning |
Example:
Task tool:
subagent_type: "macos-developer"
prompt: "Implement the ProfileView according to the design spec..."
testing
XCTest patterns for macOS Swift apps. Unit tests, async tests, Core Data tests, mock patterns, and assertion reference. Use when writing or reviewing tests.
tools
How to transition workflow state between review stages. Rules for setting review_stage and review_result fields on Stories and Epics.
documentation
Comment structure and rules for task workflow updates. Use when adding any comment to a task during implementation, review, or fix cycles.
testing
Validate task/story/epic/bug/techdebt metadata against schema v2.0. Run after TaskCreate or TaskUpdate to verify compliance. Returns pass/fail with actionable details.