agentleFS
TheBeardedBearSASTheBeardedBearSAS/claude-craft/.claude/skills/sub-agents-patterns/SKILL.md

sub-agents-patterns

Skill108 starsChanged 17 days agoMITView on GitHub

Sub-agent patterns for parallel and complex tasks. Use when splitting work across Explore/Plan/general-purpose sub-agents or running independent investigations in parallel.

The file

We split this skill into the rules it gives an agent

12 rules. About 0 are common, 11 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈11

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use for fast codebase exploration and information gathering.

    line 18
  2. Distinctive:

    Use for multi-step tasks requiring autonomy.

    line 33
  3. Distinctive:

    Use for designing implementation strategies.

    line 48
  4. Distinctive:

    Before implementing complex features

    line 58
  5. Distinctive:

    When multiple approaches are possible

    line 59
  6. Distinctive:

    Run different quality checks simultaneously:

    line 86
  7. Very specific:

    Use run_in_background: true for long-running tasks:

    line 98
  8. Distinctive:

    No mid-execution permission blocks

    line 140
  9. Distinctive:

    Use Explore agent for quick searches

    line 163
  10. Distinctive:

    Use background mode for long tasks

    line 164
  11. Distinctive:

    Use agents for simple single-file reads

    line 169
  12. Distinctive:

    Use vague prompts that require clarification

    line 171

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Sub-Agents Patterns

Guide for using sub-agents effectively in Claude Code for parallel and complex tasks.

Agent Types

1. Explore Agent (Quick Research)

Use for fast codebase exploration and information gathering.

Task tool with subagent_type: "Explore"
- Quick file pattern searches
- Keyword searches in code
- Understanding codebase structure

When to use:

  • Finding files by pattern
  • Searching for specific code patterns
  • Answering questions about codebase organization

2. General-Purpose Agent (Complex Tasks)

Use for multi-step tasks requiring autonomy.

Task tool with subagent_type: "general-purpose"
- Complex refactoring
- Multi-file updates
- Research and implementation

When to use:

  • Tasks spanning multiple files
  • Independent sub-tasks that can run in parallel
  • Tasks requiring judgment and iteration

3. Plan Agent (Architecture)

Use for designing implementation strategies.

Task tool with subagent_type: "Plan"
- Implementation planning
- Architecture decisions
- Trade-off analysis

When to use:

  • Before implementing complex features
  • When multiple approaches are possible
  • For architectural decisions

Parallel Task Patterns

Pattern 1: Parallel Research

Launch multiple explore agents for different aspects:

# Launch in parallel (single message with multiple tool calls):
- Agent 1: Search for authentication patterns
- Agent 2: Search for API endpoints
- Agent 3: Search for database models

Pattern 2: Parallel Updates

For independent file updates across languages/modules:

# Launch in parallel:
- Agent 1: Update French templates
- Agent 2: Update Spanish templates
- Agent 3: Update German templates
- Agent 4: Update Portuguese templates

Pattern 3: Parallel Quality Checks

Run different quality checks simultaneously:

# Launch in parallel:
- Agent 1: Run linter
- Agent 2: Run tests
- Agent 3: Check types
- Agent 4: Security audit

Background Agents

Use run_in_background: true for long-running tasks:

Task tool with:
  run_in_background: true

Benefits:
- Continue working while agent runs
- Check progress via output file
- Notification when complete

Best for:

  • Test suites
  • Build processes
  • Large migrations
  • Quality pipelines

Permission Prompting (v2.1.20+)

Background agents request permissions before launching, preventing mid-execution blocks:

Launching background task: "Analyze and fix code"

This task will need permissions for:
- Read (all files)
- Edit (src/**)
- Bash (npm run lint:fix)

Approve all? [y/N/select]

Response options:

OptionAction
yApprove all requested permissions
NRefuse and cancel launch
selectChoose permissions individually

Benefits:

  • No mid-execution permission blocks
  • Full visibility of agent actions before start
  • Granular control over allowed operations

Task Tool Metrics (v2.1.30+)

Task tool results now include execution metrics:

MetricDescription
Token countTotal tokens consumed by the sub-agent
Tool usesNumber of tool invocations during execution
DurationTotal elapsed time for task completion

Benefits:

  • Monitor sub-agent cost per task
  • Identify expensive operations
  • Optimize parallel task distribution

Best Practices

Do

  • Launch independent tasks in parallel (single message, multiple tools)
  • Use Explore agent for quick searches
  • Use background mode for long tasks
  • Provide clear, detailed prompts

Don't

  • Launch dependent tasks in parallel
  • Use agents for simple single-file reads
  • Forget to check background agent results
  • Use vague prompts that require clarification

Example: Multi-Language Update

# Task: Update all i18n templates to new format

## Parallel Execution:
1. Launch 4 agents (FR, ES, DE, PT) with run_in_background: true
2. Continue working on other phases
3. Check results when notified

## Each agent receives:
- List of files to update
- Template format to follow
- Instructions to read before write

Coordination Patterns

Sequential with Checkpoints

For tasks that have dependencies:

1. Agent A completes task A
2. Check result
3. Agent B uses result for task B
4. Check result
5. Continue...

Fan-Out/Fan-In

For parallel work with combined results:

1. Fan-out: Launch N parallel agents
2. Wait: All agents complete
3. Fan-in: Combine/verify results
4. Continue with merged state

References

  • Claude Code Task tool documentation
  • .claude/rules/01-workflow-analysis.md for analysis patterns
  • .claude/settings.json for permission configuration

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.