agent-patterns: Multi-Agent Design Patterns and Orchestration Practices

Preface

When working on complex tasks in environments like Claude Code or Cursor, a single session can easily become flooded with test logs, search results, and lengthy exploration output, slowing down the main conversation context and making it difficult to enforce role-based permission boundaries. Sub-agents use independent context windows to handle such work, but without aligning on constraints like “when to split tasks, how to delegate, what the parallel upper limit is, and whether sub-agents can be nested” in advance, coordination overhead can overwhelm the parallelization benefits. Below is an introduction to the agent-patterns Skill maintained by oakoss: it organizes multi-agent design patterns, built-in sub-agent capabilities, configuration fields, and common misuse into a referenceable guide, aimed at developers who are designing or debugging multi-agent systems.

What Is This

agent-patterns is a Skill in the agent-skills repository (current metadata version is 1.1, MIT license, author oakoss). The official description covers: custom sub-agents, built-in sub-agents (Explore / Plan / General-purpose, etc.), trade-offs between fungible and specialized agents, delegation and orchestration, batch processing workflows, context hygiene, and failure recovery.

The Skill content aligns with the Claude Code Sub-agents documentation; within oakoss’s collection of 112 hand-curated Skills, it is categorized as one directly related to Multi-Agent architecture. The frontmatter specifies user-invocable: false, indicating that it is not directly invoked by users via slash commands, but rather automatically selected by the Agent in scenarios such as “designing multi-agent systems, creating custom sub-agents, delegating batch operations, or orchestrating parallel work.”

Core Features

Design Pattern Quick Reference

The Skill summarizes eight common patterns and their applicable timing in a table, for example:

Pattern Key Points Typical Scenarios
Fungible swarm Identical agents pull tasks from a shared task board Large-scale software development, systems requiring resilience
Sequential pipeline Each step depends on the previous step’s output Multi-step processes with clear dependencies
Hierarchical Manager decomposes, workers execute in parallel Large tasks with independent subtasks
Peer collaboration Multiple agents iterate until consensus Code review, quality-sensitive output
Orchestrator delegation Main conversation orchestrates sub-agents sequentially Multi-stage, multi-expert parallel work
Two-stage review Spec compliance first, then code quality High-risk code, complex requirements
Question-first delegation Clarify first, then execute Ambiguous tasks with high rework costs
Review loop enforcement Fix-review cycle with maximum iterations Review processes requiring convergence

The content recommends: large-scale software development should default to fungible agents; specialized agents should only be considered for peer review or discussion-based workflows to reduce single-point-of-failure risks.

Built-in Sub-Agents and Tool Strategy

The material lists common built-in sub-agents on the Claude Code side and their purposes, such as Explore (Haiku, read-only, for codebase exploration), Plan (inherits model, read-only), General-purpose (inherits model, all tools), Bash (terminal isolation), Claude Code Guide (Haiku, read-only, answers product questions).

For custom agents, the Skill provides role-based tool recommendations: read-only reviews use Read, Grep, Glob; avoid Bash when only creating files (to reduce heredoc approval noise); scripts and build tasks can include Bash; research-type agents can include WebFetch, WebSearch. Sub-agents inherit all tools by default (including MCP); they can be restricted using tools whitelists or disallowedTools blacklists. MCP is unavailable in background sub-agents.

Key Constraints and Scaling Recommendations

  • Nesting: Sub-agents cannot spawn sub-agents; multi-step orchestration must be sequentially driven by the main conversation.
  • Batch processing: Standard tasks are approximately 5–8 items per agent.
  • Parallelism: Approximately 2–4 agents simultaneously; small tasks should not be stacked beyond 5.
  • Foreground/Background: Foreground sub-agents block the main conversation; background ones can run concurrently.

When to Use Sub-Agents vs Main Conversation

Sub-agents are better suited for: producing lengthy outputs (tests, logs, API responses), requiring enforced tool/permission boundaries, self-contained work that can return only summaries, multiple independent research paths running in parallel. The main conversation is better suited for: tasks requiring frequent back-and-forth refinement, multiple stages sharing large amounts of context, quick small changes, or being latency-sensitive (sub-agent cold starts require re-collecting context).

Installation and Activation

agent-patterns is installed with oakoss/agent-skills. The official installation examples (consistent with the repository README):

# Interactive browsing and selection
pnpm dlx skills add oakoss/agent-skills

# Only install agent-patterns
pnpm dlx skills add oakoss/agent-skills -s agent-patterns

# Specify target Agent (example: Claude Code)
pnpm dlx skills add oakoss/agent-skills -a claude-code

# User-level global installation
pnpm dlx skills add oakoss/agent-skills -g

# Preview list
pnpm dlx skills add oakoss/agent-skills --list

The collection supports 27+ types of Agent ecosystems including Claude Code, Cursor, Gemini CLI, OpenAI Codex, VS Code, GitHub Copilot, etc. (see agentskills.io); specific installation paths depend on the Skill mechanism of the tool you are using.

Custom sub-agent file locations (configuration table within the Skill):

Configuration Item Value
Project level .claude/agents/*.md
User level ~/.claude/agents/*.md
Session-level CLI --agents '{...}' (JSON, only for current session)
Plugin Plugin’s agents/ directory (lowest priority)

Required frontmatter fields: name, description. Optional: tools, disallowedTools, model, permissionMode, skills, hooks, color. model can be sonnet, opus, haiku, inherit (default). permissionMode includes default, acceptEdits, dontAsk, bypassPermissions, plan, etc.

Typical Usage (Corresponding to Skill Content)

  1. Orchestrate multi-stage work: Start sub-agents sequentially in the main conversation by stage (e.g., first use Explore to map out the code structure, then use General-purpose to execute multi-step modifications); do not treat “sub-agents spawning sub-agents” as a viable path.

  2. Parallel fungible swarm: Place independently executable items into a shared task board, use 2–4 identically configured agents to process them in parallel, each agent handling approximately 5–8 tasks, and finally merge summaries in the main conversation.

  3. Two-stage review: First dispatch a read-only agent to check requirements/spec compliance, then dispatch another read-only or restricted agent to check code quality; the review Skill recommends that review-type prompts include closed-loop expressions like “FIX issues found” and be combined with Review loop enforcement to set maximum iterations.

  4. Write custom agent files: Write frontmatter and system prompts in .claude/agents/my-reviewer.md; place critical rules in a prominent position immediately after the frontmatter to avoid them being weakened by the model when buried deep in a 300-line document.

  5. Tighten permissions and tools: Audit-type agents should only have Read, Grep, Glob opened; for sensitive operations, even when inheriting all tools, explicit prohibition should be set in frontmatter using disallowedTools.

Use Cases and Notes

Suitable for: Designing new multi-agent topologies, adding .claude/agents for projects, debugging inconsistent results after delegation or context bloat, making architectural trade-offs between fungible and specialized agents, configuring permissionMode and model tiers.

Notes (Common Mistakes summary from the Skill):

Misuse Recommendation
Expecting sub-agents to nest sub-agents Only the main conversation can orchestrate
Only creating files but giving Bash Use Write/Edit to reduce approval interference
Inheriting all tools but not blocking dangerous items Use disallowedTools to explicitly reject
Too many agents for small tasks Start with 2–3 first
Over-specialization in large-scale development Prefer fungible + task board
Critical instructions written at the end of prompts Place immediately after frontmatter

The Skill declares user-invocable: false, meaning it is typically loaded by the Agent when relevant tasks arise, rather than being manually invoked by users through a command.

Conclusion

agent-patterns consolidates multi-agent patterns, built-in sub-agents, configuration tables, and anti-patterns in the Claude Code context into a reference document, suitable as a checklist before orchestration and delegation. For installation and item descriptions, refer to the official repository:

https://github.com/oakoss/agent-skills/tree/main/skills/agent-patterns

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye