adding-swarm-patterns
$
npx mdskill add AgentWorkforce/relay/adding-swarm-patternsUpdate types, schemas, templates, and docs for new swarm patterns.
- Enables multi-agent coordination for competitive or auction workflows.
- Modifies TypeScript unions, JSON enums, YAML templates, and markdown files.
- Follows a strict checklist to ensure consistency across all pattern definitions.
- Delivers a complete, deployable pattern ready for immediate agent use.
SKILL.md
.github/skills/adding-swarm-patternsView on GitHub ↗
---
name: adding-swarm-patterns
description: Use when adding new multi-agent coordination patterns to agent-relay - provides checklist for types, schema, templates, and docs updates
tags: agent-relay, swarm, patterns, workflows
---
# Adding Swarm Patterns
## Overview
Add new multi-agent coordination patterns to agent-relay by updating four locations: TypeScript types, JSON schema, YAML template, and markdown docs.
## When to Use
- Adding a new swarm pattern (e.g., "competitive", "auction")
- Extending coordination capabilities for multi-agent workflows
- Responding to user requests for new orchestration strategies
## Quick Reference
| File | Location | What to Add |
|------|----------|-------------|
| types.ts | `packages/broker-sdk/src/workflows/types.ts` | Add to `SwarmPattern` union type |
| schema.json | `packages/broker-sdk/src/workflows/schema.json` | Add to `SwarmPattern.enum` array |
| template.yaml | `packages/broker-sdk/src/workflows/builtin-templates/` | Create `{pattern}.yaml` |
| pattern.md | `docs/workflows/patterns/` | Create `{pattern}.md` |
| template.md | `docs/workflows/templates/` | Create `{pattern}.md` |
| README.md | `docs/workflows/README.md` | Add to patterns and templates tables |
## Implementation Checklist
### 1. Update TypeScript Types
```typescript
// packages/broker-sdk/src/workflows/types.ts
export type SwarmPattern =
| "fan-out"
| "pipeline"
// ... existing patterns ...
| "your-new-pattern"; // Add here
```
### 2. Update JSON Schema
```json
// packages/broker-sdk/src/workflows/schema.json
"SwarmPattern": {
"type": "string",
"enum": [
"fan-out",
"pipeline",
// ... existing patterns ...
"your-new-pattern"
]
}
```
### 3. Create YAML Template
```yaml
# packages/broker-sdk/src/workflows/builtin-templates/{pattern}.yaml
version: "1.0"
name: pattern-name
description: "One-line description"
swarm:
pattern: pattern-name
maxConcurrency: N
timeoutMs: N
channel: swarm-pattern-name
agents:
- name: lead
cli: claude
role: "Role description"
# ... more agents
workflows:
- name: workflow-name
steps:
- name: step-name
agent: agent-name
task: |
Task description with {{task}} placeholder
verification:
type: output_contains
value: STEP_COMPLETE
coordination:
barriers:
- name: barrier-name
waitFor: [step1, step2]
state:
backend: memory
namespace: pattern-name
errorHandling:
strategy: fail-fast
```
### 4. Create Pattern Documentation
```markdown
# docs/workflows/patterns/{pattern}.md
# Pattern Name
One-sentence description.
## When to Use
- Use case 1
- Use case 2
## Structure
[ASCII diagram showing agent/step flow]
## Configuration
[YAML snippet]
## Best Practices
- Practice 1
- Practice 2
```
### 5. Create Template Documentation
```markdown
# docs/workflows/templates/{pattern}.md
# Pattern Template
**Pattern:** name | **Timeout:** N minutes | **Channel:** swarm-name
## Overview
What this template does.
## Agents
| Agent | CLI | Role |
|-------|-----|------|
## Workflow Steps
1. **step** (agent) — Description
## Usage
[CLI and TypeScript examples]
## Verification Markers
- `MARKER` — Description
```
### 6. Update README
Add to both tables in `docs/workflows/README.md`:
- Patterns table: `| [pattern](patterns/pattern.md) | Description | Best For |`
- Templates table: `| [pattern](templates/pattern.md) | pattern | Description |`
## Common Mistakes
| Mistake | Fix |
|---------|-----|
| Forgetting schema.json | Validation will fail if schema doesn't include the pattern |
| Inconsistent naming | Use same name in types, schema, template filename, and docs |
| Missing verification markers | Each step should have `output_contains` verification |
| Wrong doc links | Use relative paths: `patterns/name.md` not `/docs/workflows/patterns/name.md` |
## Pattern Design Guidelines
**Good patterns have:**
- Clear coordination model (who talks to whom)
- Defined failure handling (what happens if one agent fails)
- Appropriate concurrency (parallel vs sequential)
- Barrier synchronization for convergence points
**Pattern categories:**
- **Parallel**: fan-out, competitive, scatter-gather
- **Sequential**: pipeline, handoff, cascade
- **Hierarchical**: hub-spoke, hierarchical, supervisor
- **Consensus**: consensus, debate, auction
- **Graph**: dag, mesh
More from AgentWorkforce/relay
- agent-relayUse when you need Codex to coordinate multiple agents through Relaycast for peer-to-peer messaging, lead/worker handoffs, or shared status tracking across sub-agents and terminals.
- agent-relay-orchestratorRun headless multi-agent orchestration sessions via Agent Relay. Use when spawning teams of agents, creating channels for coordination, managing agent lifecycle, and running parallel workloads across Claude/Codex/Gemini/Pi/Droid agents.
- browser-testing-with-screenshotsUse when testing web applications with visual verification - automates Chrome browser interactions, element selection, and screenshot capture for confirming UI functionality
- choosing-swarm-patternsUse when coordinating multiple AI agents and need to pick the right orchestration pattern - covers 10 patterns (fan-out, pipeline, hub-spoke, consensus, mesh, handoff, cascade, dag, debate, hierarchical) with decision framework and reflection protocol
- creating-agent-skills-skillUse when creating Agent Skills packages (SKILL.md format) for Codex CLI, GitHub Copilot, or Amp - provides the agentskills.io specification with frontmatter constraints, directory structure, and validation rules
- creating-claude-agentsUse when creating or improving Claude Code agents. Expert guidance on agent file structure, frontmatter, persona definition, tool access, model selection, and validation against schema.
- creating-claude-hooksUse when creating or publishing Claude Code hooks - covers executable format, event types, JSON I/O, exit codes, security requirements, and PRPM package structure
- creating-claude-rulesUse when creating or fixing .claude/rules/ files - provides correct paths frontmatter (not globs), glob patterns, and avoids Cursor-specific fields like alwaysApply
- creating-skillsUse when creating new Claude Code skills or improving existing ones - ensures skills are discoverable, scannable, and effective through proper structure, CSO optimization, and real examples
- debugging-websocket-issuesUse when seeing WebSocket errors like "Invalid frame header", "RSV1 must be clear", or "WS_ERR_UNEXPECTED_RSV_1" - covers multiple WebSocketServer conflicts, compression issues, and raw frame debugging techniques