skills/adding-swarm-patterns/SKILL.md
Use when adding new multi-agent coordination patterns to agent-relay - provides checklist for types, schema, templates, and docs updates
npx skillsauth add agentworkforce/relay adding-swarm-patternsInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Add new multi-agent coordination patterns to agent-relay by updating four locations: TypeScript types, JSON schema, YAML template, and markdown docs.
| 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 |
// packages/broker-sdk/src/workflows/types.ts
export type SwarmPattern =
| "fan-out"
| "pipeline"
// ... existing patterns ...
| "your-new-pattern"; // Add here
// packages/broker-sdk/src/workflows/schema.json
"SwarmPattern": {
"type": "string",
"enum": [
"fan-out",
"pipeline",
// ... existing patterns ...
"your-new-pattern"
]
}
# 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
# 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
# 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
Add to both tables in docs/workflows/README.md:
| [pattern](patterns/pattern.md) | Description | Best For || [pattern](templates/pattern.md) | pattern | Description || 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 |
Good patterns have:
Pattern categories:
development
Run 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.
development
Use 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.
development
Real-time messaging across OpenClaw instances (channels, DMs, threads, reactions, search).
development
Use when building multi-agent workflows with the relay broker-sdk - covers the WorkflowBuilder API, DAG step dependencies, agent definitions, step output chaining via {{steps.X.output}}, verification gates, evidence-based completion, owner decisions, dedicated channels, dynamic channel management (subscribe/unsubscribe/mute/unmute), swarm patterns, error handling, event listeners, step sizing rules, authoring best practices, and the lead+workers team pattern for complex steps