adding-swarm-patterns

Use when adding new multi-agent coordination patterns to agent-relay - provides checklist for types, schema, templates, and docs updates

601 stars

Best use case

adding-swarm-patterns is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Use when adding new multi-agent coordination patterns to agent-relay - provides checklist for types, schema, templates, and docs updates

Teams using adding-swarm-patterns should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/adding-swarm-patterns/SKILL.md --create-dirs "https://raw.githubusercontent.com/AgentWorkforce/relay/main/skills/adding-swarm-patterns/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/adding-swarm-patterns/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How adding-swarm-patterns Compares

Feature / Agentadding-swarm-patternsStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Use when adding new multi-agent coordination patterns to agent-relay - provides checklist for types, schema, templates, and docs updates

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# 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

Related Skills

choosing-swarm-patterns

601
from AgentWorkforce/relay

Use 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

agent-relay-orchestrator

601
from AgentWorkforce/relay

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.

agent-relay

601
from AgentWorkforce/relay

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.

openclaw-relay

601
from AgentWorkforce/relay

Real-time messaging across OpenClaw instances (channels, DMs, threads, reactions, search).

prpm-json-best-practices

601
from AgentWorkforce/relay

Best practices for structuring prpm.json package manifests with required fields, tags, organization, multi-package management, enhanced file format, eager/lazy activation, and conversion hints

implementing-command-palettes

601
from AgentWorkforce/relay

Use when building Cmd+K command palettes in React - covers keyboard navigation with arrow keys, keeping selected items in view with scrollIntoView, filtering with shortcut matching, and preventing infinite re-renders from reference instability

github-oauth-nango-integration

601
from AgentWorkforce/relay

Use when implementing GitHub OAuth + GitHub App authentication with Nango - provides two-connection pattern for user login and repo access with webhook handling

frontend-design

601
from AgentWorkforce/relay

Create distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.

deploying-to-staging-environment

601
from AgentWorkforce/relay

Use when deploying changes to staging across relay, relay-dashboard, and relay-cloud repos - coordinates multi-repo branch syncing using git worktrees, automatically triggers staging deployments via GitHub Actions

debugging-websocket-issues

601
from AgentWorkforce/relay

Use 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

creating-skills

601
from AgentWorkforce/relay

Use 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

creating-claude-rules

601
from AgentWorkforce/relay

Use when creating or fixing .claude/rules/ files - provides correct paths frontmatter (not globs), glob patterns, and avoids Cursor-specific fields like alwaysApply