Back to Everything Claude Code

Agent Orchestration

rules/common/agents.md

2.1.02.5 KB
Original Source

Agent Orchestration

Available Agents

Located in ~/.claude/agents/:

AgentPurposeWhen to Use
plannerImplementation planningComplex features, refactoring
architectSystem designArchitectural decisions
tdd-guideTest-driven developmentNew features, bug fixes
code-reviewerCode reviewAfter writing code
security-reviewerSecurity analysisBefore commits
build-error-resolverFix build errorsWhen build fails
e2e-runnerE2E testingCritical user flows
refactor-cleanerDead code cleanupCode maintenance
doc-updaterDocumentationUpdating docs
rust-reviewerRust code reviewRust projects
harmonyos-app-resolverHarmonyOS app developmentHarmonyOS/ArkTS projects

Immediate Agent Usage

No user prompt needed:

  1. Complex feature requests - Use planner agent
  2. Code just written/modified - Use code-reviewer agent
  3. Bug fix or new feature - Use tdd-guide agent
  4. Architectural decision - Use architect agent

Parallel Task Execution

ALWAYS use parallel Task execution for independent operations:

markdown
# GOOD: Parallel execution
Launch 3 agents in parallel:
1. Agent 1: Security analysis of auth module
2. Agent 2: Performance review of cache system
3. Agent 3: Type checking of utilities

# BAD: Sequential when unnecessary
First agent 1, then agent 2, then agent 3

Delegation Completion Contract

Applies to every agent at every depth (parent, child, grandchild):

  1. Your final message IS the deliverable. Never end your turn with "waiting for background agents" — a spawned task is not a completed task. Ending your turn while children are running orphans their results (completed children cannot notify a parent whose turn has ended).
  2. If you delegate, you own collection. Wait for results, integrate them, then return. Fire-and-forget delegation is forbidden.
  3. Decompose only when the work cannot fit in one context. Do not re-delegate a task already sized for a single agent — depth is an outcome, not a plan.

Rationale: observed failure mode — research agents followed "Parallel Task Execution" above, spawned children, and returned "waiting" as their final answer. All children completed successfully but their results were orphaned. The parallel rule without a completion contract produces zombie tasks.

Multi-Perspective Analysis

For complex problems, use split role sub-agents:

  • Factual reviewer
  • Senior engineer
  • Security expert
  • Consistency reviewer
  • Redundancy checker