Orchestration Patterns

July 18, 2026 · View on GitHub

How to wire Commands, Agents, and Skills together for complex workflows.

The Three Layers

Command (entry point, user-facing)
  └── Agent (execution, constrained tools)
        └── Skill (domain knowledge, preloaded)

Each layer has a single responsibility:

  • Commands handle user interaction and parameter collection
  • Agents execute workflows with constrained tool access
  • Skills provide domain-specific knowledge and procedures

Pattern 1: Command > Agent > Skill

The most powerful pattern. A slash command delegates to an agent that has skills preloaded.

Example: Feature Builder

Command (commands/build-feature.md):

---
description: Build a feature end-to-end with planning, implementation, and tests
argument-hint: <feature description>
---

Build this feature using a structured approach:

1. Delegate to the planner agent to create a plan
2. Wait for plan approval
3. Implement the plan
4. Run quality gates
5. Create a commit

Feature: $ARGUMENTS

Agent (agents/planner.md):

---
name: planner
description: Break down tasks into plans
tools: ["Read", "Glob", "Grep"]
skills: ["api-conventions", "project-patterns"]
model: opus
---

Skill (skills/api-conventions/SKILL.md):

---
name: api-conventions
description: API design patterns for this project
user-invocable: false
---

REST endpoints use camelCase. Auth via Bearer tokens.
Error responses follow RFC 7807.

How It Flows

  1. User runs /build-feature add user preferences
  2. Command expands $ARGUMENTS and delegates to planner agent
  3. Planner loads with api-conventions skill already in context
  4. Planner explores code, produces plan using skill knowledge
  5. Control returns to command for approval
  6. Implementation proceeds with full context

Pattern 2: Multi-Phase Development (RPI)

Research > Plan > Implement with validation gates between phases.

Structure

.claude/
├── commands/
│   └── develop.md          # Entry point
├── agents/
│   ├── researcher.md       # Phase 1: explore and validate
│   ├── architect.md        # Phase 2: design
│   └── implementer.md      # Phase 3: build
└── skills/
    └── project-patterns/
        └── SKILL.md         # Shared knowledge

The Flow

/develop "add webhook support"


[Research Phase] → researcher agent
    │  - Explore existing code
    │  - Find similar patterns
    │  - Check dependencies
    │  - Score confidence (0-100)

    ├── Score < 70 → HOLD (ask user for more context)


[Plan Phase] → architect agent
    │  - Design the solution
    │  - List all files to change
    │  - Identify risks
    │  - Present plan for approval

    ├── User rejects → Back to research


[Implement Phase] → implementer agent
    │  - Execute the plan step by step
    │  - Run tests after each step
    │  - Quality gates at checkpoints


[Verify] → reviewer agent
    │  - Code review the changes
    │  - Security check
    │  - Performance check


[Commit] → /commit command

Researcher Agent

---
name: researcher
description: Explore codebase to assess feasibility before implementation
tools: ["Read", "Glob", "Grep", "Bash"]
background: true
isolation: worktree
memory: project
---

Key: runs in background with worktree isolation so it doesn't block the main session.

Architect Agent

---
name: architect
description: Design implementation plans with risk assessment
tools: ["Read", "Glob", "Grep"]
skills: ["project-patterns"]
model: opus
---

Key: read-only tools, Opus model for deep reasoning, preloaded project patterns.

Pattern 3: Agent Skills vs On-Demand Skills

Two ways to use skills — understand when to use each.

Agent Skills (Preloaded)

# In agent frontmatter
skills: ["api-conventions", "error-handling"]
  • Full skill content injected into agent context at startup
  • Always available, no invocation needed
  • Use for: domain knowledge the agent always needs
  • Cost: uses context tokens

On-Demand Skills (Invoked)

# In skill frontmatter
user-invocable: true
  • User runs /skill-name or Claude invokes via Skill() tool
  • Content loaded only when called
  • Use for: procedures run occasionally
  • context: fork runs in isolated subagent context

Decision Matrix

ScenarioUse
Agent always needs this knowledgeAgent skill (preloaded)
User triggers occasionallyOn-demand skill
Heavy procedure, don't pollute contextOn-demand with context: fork
Background-only, never user-facinguser-invocable: false

Pattern 4: Agent Teams Orchestration

For large tasks, coordinate multiple agents working in parallel.

# Enable agent teams
export CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1

Team Composition

RoleAgentResponsibility
LeadMain sessionCoordinate, assign tasks, synthesize
FrontendTeammate 1UI components, styling, client logic
BackendTeammate 2API endpoints, database, server logic
TestsTeammate 3Test coverage, integration tests

Communication Flow

  • Lead assigns tasks via shared task list
  • Teammates work independently in their own context windows
  • Teammates message each other directly (not just report back)
  • Lead synthesizes results and handles conflicts

When to Use Agent Teams vs Subagents

FactorSubagentsAgent Teams
ContextShares parent sessionIndependent windows
CommunicationReturns result onlyDirect messaging
DurationShort tasksLong sessions
IsolationOptional worktreeAlways isolated
CoordinationParent managesShared task list

Pattern 5: Dynamic Command Substitution

Commands support string substitution for dynamic context.

# In a command file

Current branch: !`git branch --show-current`
Last commit: !`git log --oneline -1`
Modified files: !`git diff --name-only`

Session: ${CLAUDE_SESSION_ID}
User argument: $ARGUMENTS
First word: $ARGUMENTS[0]

The !`command` syntax injects live output. Use for context-aware commands.

Frontmatter Quick Reference

Command Frontmatter

FieldTypePurpose
descriptionstringShown in / menu
argument-hintstringPlaceholder text
allowed-toolsstring[]Tool whitelist
modelstringOverride model

Agent Frontmatter

FieldTypePurpose
namestringAgent identifier
descriptionstringWhen to use (include PROACTIVELY for auto-invoke)
toolsstring[]Allowed tools
disallowedToolsstring[]Blocked tools
modelstringModel override
permissionModestringPermission level
maxTurnsnumberTurn limit
skillsstring[]Preloaded skills
mcpServersobjectAgent-specific MCP servers
hooksobjectAgent-specific hooks
memorystringuser / project / local
backgroundbooleanDefault to background execution
isolationstringworktree for git isolation
colorstringDisplay color in agent teams

Skill Frontmatter

FieldTypePurpose
namestringSkill identifier
descriptionstringWhen to invoke
argument-hintstringParameter hint
disable-model-invocationbooleanPrevent auto-invocation
user-invocablebooleanShow in / menu
allowed-toolsstring[]Tool whitelist
modelstringModel override
contextstringfork for isolated execution
agentstringDelegate to specific agent
hooksobjectSkill-specific hooks