agent-patterns

Multi-agent design patterns for Claude Code and AI development systems. Covers custom subagents, built-in subagents (Explore/Plan/General-purpose), fungible vs specialized agents, delegation, orchestration, batch workflows, context hygiene, and failure recovery. Use when: designing multi-agent systems, creating custom subagents, delegating bulk operations, orchestrating parallel work, choosing between fungible and specialized agents, configuring agent frontmatter, or debugging agent coordination issues.

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "agent-patterns" with this command: npx skills add oakoss/agent-skills/oakoss-agent-skills-agent-patterns

Agent Patterns

Multi-agent design, delegation, and orchestration in Claude Code and AI-assisted development. Default to fungible agents for large-scale software dev; use specialized agents only for peer review or discourse-based workflows.

Subagents in Claude Code are specialized AI assistants that run in isolated context windows with custom system prompts, specific tool access, and independent permissions. They preserve main conversation context by keeping exploration, test runs, and verbose operations out of the primary thread.

Key constraint: subagents cannot spawn other subagents. Multi-step orchestration requires chaining subagents from the main conversation.

Quick Reference

PatternDescriptionWhen to Use
Fungible swarmIdentical agents pick tasks from a shared boardLarge-scale software dev, resilient systems
Sequential pipelineEach agent builds on previous outputMulti-step workflows with clear dependencies
HierarchicalManager decomposes, workers execute in parallelComplex tasks with independent subtasks
Peer collaborationAgents iterate until consensusCode review, quality-critical outputs
Orchestrator delegationMain conversation chains subagentsMulti-phase workflows, parallel specialists
Two-stage reviewSpec compliance check, then code quality checkHigh-stakes code, complex requirements
Question-first delegationAgent asks clarifying questions before proceedingAmbiguous tasks, expensive-to-redo work
Review loop enforcementFix-review cycle with max iteration escalationAny review workflow needing convergence
Built-in SubagentModelToolsPurpose
ExploreHaikuRead-onlyFile discovery, code search, codebase exploration
PlanInheritsRead-onlyCodebase research during plan mode
General-purposeInheritsAll toolsComplex research, multi-step operations
BashInheritsTerminalRunning terminal commands in separate context
Claude Code GuideHaikuRead-onlyAnswering questions about Claude Code features
ConfigurationValue
Custom agent location.claude/agents/*.md (project), ~/.claude/agents/*.md (user)
CLI agents--agents '{...}' (session only, JSON format)
Plugin agentsPlugin agents/ directory (lowest priority)
Required fieldsname, description
Optional fieldstools, disallowedTools, model, permissionMode, skills, hooks, color
Model valuessonnet, opus, haiku, inherit (default)
Permission modesdefault, acceptEdits, dontAsk, bypassPermissions, plan
Nesting limitSubagents cannot spawn other subagents (one level only)
Foreground vs backgroundForeground blocks main conversation; background runs concurrently
Batch size5-8 items per agent (standard tasks)
Parallel agents2-4 simultaneously

When to Use Subagents vs Main Conversation

Use Subagents WhenUse Main Conversation When
Task produces verbose output (test suites, logs, API responses)Task needs frequent back-and-forth or iterative refinement
Enforcing specific tool restrictions or permissionsMultiple phases share significant context
Work is self-contained and can return a summaryMaking a quick, targeted change
Parallel independent research pathsLatency matters (subagents start fresh and gather context)

Tool Access Patterns

Agent RoleRecommended ToolsRationale
Read-only reviewerRead, Grep, GlobCannot modify code; safe for audits
File creatorRead, Write, Edit, Glob, GrepNO Bash; avoids heredoc approval spam
Script runnerRead, Write, Edit, Glob, Grep, BashFull access for build/deploy tasks
Research agentRead, Grep, Glob, WebFetch, WebSearchExternal data access for documentation lookup

Subagents inherit all tools by default (including MCP tools). Use tools as an allowlist or disallowedTools as a denylist to restrict access. MCP tools are not available in background subagents.

Common Mistakes

MistakeCorrect Pattern
Expecting subagents to spawn sub-subagentsSubagents cannot nest; chain subagents from the main conversation instead
Giving Bash tool to agents that only create filesUse Write and Edit tools only; Bash causes approval spam from heredoc usage
Omitting disallowedTools for sensitive operationsUse disallowedTools to explicitly deny dangerous tools even when inheriting
Spawning too many agents (5+) for a small taskStart with 2-3 agents; coordination overhead outweighs benefit at higher counts
Burying critical instructions past line 300 of agent promptPut critical rules immediately after frontmatter; models deprioritize late instructions
Using specialized agents for large-scale software devUse fungible agents with a shared task board; specialized agents create single points of failure
Not including "FIX issues found" in delegation promptsWithout explicit action directive, agents only report problems without making changes
Setting model to Haiku for content generationDefault to Sonnet; Haiku only for script execution, fast lookups, or pass/fail checks
Not writing clear descriptions for custom agentsClaude uses the description field to decide when to auto-delegate; vague descriptions prevent delegation
Using MCP tools in background subagentsMCP tools are not available in background subagents; run in foreground instead
Not preloading skills into subagentsSubagents do not inherit skills from the parent; list them explicitly in the skills field

Delegation

  • Explore codebase before designing agent prompts: Claude auto-delegates to the built-in Explore subagent (Haiku, read-only) for file discovery and code search; supports quick, medium, and very thorough modes
  • Plan multi-agent architecture for complex projects: Use plan mode; Claude delegates research to the Plan subagent before presenting a plan
  • Execute batch operations across many files: Chain General-purpose subagents from the main conversation with identical prompts and non-overlapping item lists
  • Isolate high-volume operations: Delegate test runs, log processing, or doc fetching to subagents to keep verbose output out of your main context
  • Run parallel research: Spawn multiple subagents simultaneously for independent investigations; Claude synthesizes findings when all complete
  • Resume interrupted work: Ask Claude to continue a previous subagent; resumed agents retain full conversation history including tool calls and reasoning

For project-level workflow sequencing, phase-gate validation, goal decomposition, and capability scoring, use the orchestration skill.

References

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

Coding

github-cli

No summary provided by upstream source.

Repository SourceNeeds Review
Coding

tanstack-cli

No summary provided by upstream source.

Repository SourceNeeds Review
Coding

typescript-patterns

No summary provided by upstream source.

Repository SourceNeeds Review
Coding

tanstack-devtools

No summary provided by upstream source.

Repository SourceNeeds Review