agentleFS
wittyreferencewittyreference/twilio-claude-plugin/skills/multi-agent-patterns/SKILL.md

multi-agent-patterns

Skill2 starsChanged 8 months agoMITView on GitHub

Twilio development skill: multi-agent-patterns

17 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use context-fundamentals, context-degradation and 10 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • rohunvoraSkill

    context-fundamentals

    Understand the components, mechanics, and constraints of context in agent systems. Use when designing agent architectures, debugging context-related failures, or optimizing context usage.

    Also in 8 projects that use this

  • rohunvoraSkill

    context-degradation

    Recognize, diagnose, and mitigate patterns of context degradation in agent systems. Use when context grows large, agent performance degrades unexpectedly, or debugging agent failures.

    Also in 7 projects that use this

  • AbdullahMalik17Skill

    configuring-dapr-pubsub

    Configures Dapr pub/sub components for event-driven microservices with Kafka or Redis. Use when wiring agent-to-agent communication, setting up event subscriptions, or integrating Dapr sidecars. Covers component configuration, subscription patterns, publishing events, and Kubernetes deployment. NOT when using direct Kafka clients or non-Dapr messaging patterns.

    Also in 3 projects that use this

  • AbdullahMalik17Skill

    containerizing-applications

    Containerizes applications with Docker, docker-compose, and Helm charts. Use when creating Dockerfiles, docker-compose configurations, or Helm charts for Kubernetes. Includes Docker Hardened Images (95% fewer CVEs), multi-stage builds, and 15+ battle-tested gotchas.

    Also in 3 projects that use this

  • muratcankoylanSkill

    long-horizon-prompting

    This skill should be used when writing, enhancing, or evaluating the launch prompt for a long-running autonomous agent or a parallel multi-agent orchestration attacking a hard problem: pseudo-formal task briefs that define terms and an exact success predicate linguistically, enumerate non-counting outcomes, set persistence rules with explicit stop and return conditions and effort floors, manage a diverse portfolio of parallel approaches with an approach registry and blocked-route bookkeeping, and gate the return on adversarial audit. Route agent topology and coordination protocols to multi-agent-patterns, runtime control surfaces and loop governance to harness-engineering, evaluator and quality-gate construction to evaluation, judge design to advanced-evaluation, and compaction or memory mechanics to context-compression and memory-systems.

    Also in 3 projects that use this

  • +6 more from AbdullahMalik17
  • +1 more from rohunvora

The file

We split this skill into the rules it gives an agent

4 rules. 0 are common, 4 are distinctive, and 0 are very specific to this project.

  • 0

    Common

    Most of the 16 edited versions we read keep these.

  • 4

    Distinctive

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    All development workflows enforce Test-Driven Development via pre-phase hooks:

    line 43
  2. Distinctive:

    test-gen: must create tests that fail initially (Red phase)

    line 45
  3. Distinctive:

    test-gen tasks: Tests must exist AND fail

    line 378
  4. Distinctive:

    All tasks: No hardcoded credentials

    line 381

“Common” is measured: kept by at least 6 in 10 of the 16 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

name: multi-agent-patterns description: Agent orchestration and coordination patterns. Use when designing multi-agent workflows, choosing between parallel/sequential/hierarchical patterns, or coordinating subagents.

Multi-Agent Patterns for Twilio

This skill describes orchestration and coordination patterns for Twilio development workflows.

Pattern Overview

PatternBest ForTwilio Use Case
OrchestratorSequential flowsFeature development pipeline
Agent TeamsParallel + adversarialBug debugging, code review, parallel QA
Peer-to-PeerParallel workDebugging + fixing simultaneously
HierarchicalComplex featuresMulti-channel solutions
EvaluatorQuality gatesCode review with standards
TDD PipelineCode qualityRed → Green → Refactor

Cross-Cutting Concerns

Human Approval Gates

The project operates in "Highly Supervised" autonomy mode. Human approval is required at key checkpoints:

architect → [APPROVAL] → spec → [APPROVAL] → test-gen → dev → qa → review → [APPROVAL] → docs

Approval gates pause execution until human confirms:

  • Architecture decisions are sound
  • Specifications are correct
  • Code is ready for merge

TDD Enforcement

All development workflows enforce Test-Driven Development via pre-phase hooks:

  1. test-gen must create tests that fail initially (Red phase)
  2. tdd-enforcement hook runs BEFORE dev phase and verifies:
    • Tests exist (testsCreated > 0)
    • Tests are FAILING
  3. dev is blocked with TDD VIOLATION if tests pass or don't exist
  4. dev implements minimal code to make tests pass (Green phase)
  5. review validates TDD was followed
// Pre-phase hooks in workflow definition
{
  agent: 'dev',
  name: 'TDD Green Phase',
  prePhaseHooks: ['tdd-enforcement'],  // Blocks if tests don't fail
}

See .claude/skills/tdd-workflow.md for detailed TDD patterns.

Orchestrator Pattern (Default)

A central coordinator manages the workflow, invoking specialists in sequence.

Structure

graph TD
    CC["Claude Code\n(sequencer)"]
    CC --> A["/architect"]
    CC --> S["/spec"]
    CC --> T["/test-gen"]
    CC --> D["/dev"]
    CC --> R["/review"]

When to Use

  • New feature development (sequential phases)
  • Bug fixes (diagnose → test → fix → verify)
  • Refactoring (test → change → test)

Twilio Example: New Voice Feature

/architect "Add voicemail recording"

Phase 1: /architect
  → Design: functions/voice/voicemail.protected.js
  → Pattern: Record verb with callback

Phase 2: /spec
  → Input: CallSid, RecordingUrl
  → Output: TwiML with Record, callback handling

Phase 3: /test-gen
  → Unit tests for TwiML generation
  → Integration test for recording callback

Phase 4: /dev
  → Implement voicemail.protected.js
  → Make tests pass

Phase 5: /review
  → Security: Protected endpoint ✓
  → Patterns: Matches voice/CLAUDE.md ✓

Phase 6: /test
  → All tests passing ✓

Handoff Protocol

Each agent passes structured context to the next:

## Handoff: /architect → /spec

Files identified:
- functions/voice/voicemail.protected.js (create)
- __tests__/unit/voice/voicemail.test.js (create)

Architecture decisions:
- Use Record verb with transcribe=true
- Store recordings via callback to /voice/recording-complete
- Protected endpoint (requires Twilio signature)

Ready for: Detailed specification

Peer-to-Peer Pattern

Agents work in parallel on related but independent tasks. For true parallel coordination with inter-agent messaging, see Agent Teams Pattern above.

Structure

graph TD
    U["User"]
    U --> A["Agent A"]
    U --> B["Agent B"]
    A <--> B

When to Use

  • Debugging (analyze logs while reviewing code)
  • Multi-file changes (update function + tests simultaneously)
  • Documentation (code + docs in parallel)

Twilio Example: Debugging SMS Failure

Parallel agents:

Agent A: /twilio-logs
  → Analyzing debugger for error 30003
  → Found: Unreachable destination +1555...

Agent B: /dev (investigating)
  → Reading send-sms.protected.js
  → Found: No validation on 'to' parameter

Sync point:
  → Root cause: Invalid phone number passed through
  → Fix: Add E.164 validation before API call

Coordination Mechanism

Agents share findings through explicit sync points:

## Sync: Debug Analysis Complete

Agent A findings:
- Error 30003: Unreachable destination
- 5 failures in last hour
- All to same number pattern

Agent B findings:
- No input validation in send-sms
- Phone number from user input without sanitization

Combined insight:
- Need E.164 validation before Twilio API call
- Add test for invalid phone number handling

Hierarchical Pattern

A lead agent delegates to sub-agents, which may further delegate.

Structure

graph TD
    LA["Lead Agent\n/architect"]
    VT["Voice Team"]
    ST["SMS Team"]
    VFT["Verify Team"]

    LA --> VT
    LA --> ST
    LA --> VFT

    VT --> VS["/spec"] & VD["/dev"]
    ST --> SS["/spec "] & SD["/dev "]
    VFT --> VFS["/spec  "] & VFD["/dev  "]

When to Use

  • Multi-channel features (voice + SMS + web)
  • Large refactoring (multiple subsystems)
  • Complex IVR with nested menus

Twilio Example: Multi-Channel Notification System

Lead: /architect "Build notification system with voice, SMS, and email fallback"

Delegation:
├── Voice Team
│   ├── /spec voice notification (call + TTS)
│   └── /dev functions/voice/notify.protected.js
│
├── SMS Team
│   ├── /spec SMS notification
│   └── /dev functions/messaging/notify.protected.js
│
└── Orchestration Team
    ├── /spec fallback logic (voice → SMS → email)
    └── /dev functions/helpers/notify-orchestrator.private.js

Rollup:
- Each team reports completion + test status
- Lead verifies integration
- Final /review of complete system

Supervision Protocol

Lead agent maintains oversight:

## Status: Multi-Channel Notification

Voice Team: COMPLETE
- notify-voice.protected.js ✓
- Tests passing ✓

SMS Team: IN_PROGRESS
- notify-sms.protected.js ✓
- Tests: 1 failing (rate limit handling)

Verify Team: BLOCKED
- Waiting on SMS team completion

Lead action: Assist SMS team with rate limit test

Evaluator Pattern

An evaluator agent assesses work quality against standards.

Structure

graph LR
    P["Producer\n/dev"] --> E["Evaluator\n/review"] --> D["Decision\nPASS/FAIL"]
    E --> F["Feedback Loop"]
    F -.-> P

When to Use

  • Code review gates
  • Security audits
  • TDD verification (tests must fail first)

Twilio Example: Code Review Gate

/review functions/voice/transfer-call.protected.js

Evaluation criteria (from CLAUDE.md):

□ ABOUTME comments present
  ✓ Line 1-2: Descriptive ABOUTME

□ No hardcoded credentials
  ✓ Uses context.TWILIO_ACCOUNT_SID

□ Error handling present
  ✓ Validates 'to' parameter
  ✗ Missing try/catch around client call

□ Protected endpoint for sensitive operations
  ✓ .protected.js suffix

□ Tests exist and pass
  ✓ 4 unit tests passing

Verdict: NEEDS_CHANGES
Reason: Add try/catch for Twilio API call

Agent Teams Pattern

Real parallel coordination with inter-agent messaging. Unlike subagents (which share the parent's context and can only report back), teammates have their own context windows and communicate directly with each other.

Structure

graph TD
    LA["Lead Agent\n(delegate mode)"]
    LA -- "shared task list" --> A["Teammate A"]
    LA -- "shared task list" --> B["Teammate B"]
    LA -- "shared task list" --> C["Teammate C"]
    A <-- "direct messaging" --> B
    B <-- "direct messaging" --> C
    A <-- "direct messaging" --> C

When to Use

  • Bug debugging with competing hypotheses (3 investigators challenge each other)
  • Multi-lens code review (security + performance + tests in parallel)
  • Parallel QA + review after implementation
  • Cross-layer changes (functions + agents + config)

Comparison: Subagents vs Agent Teams vs Feature Factory

AspectSubagentsAgent TeamsFeature Factory
ContextShared with parentOwn window per teammateOwn SDK session
CommunicationReturn results to callerMessage each other + shared tasksPhase handoffs
ParallelismSequentialParallelSequential
Token costLowest~2-3xMedium
ResumableYesNoYes
Best forSequential workflowsAdversarial/parallel workCI/CD automation

Twilio Example: Bug Fix with Competing Hypotheses

/team bug-fix "SMS webhook returning 500 for empty body"

Parallel investigators:

Teammate "code-tracer":
  → Reading send-sms.protected.js
  → Found: No body validation, crashes on undefined
  → Confidence: HIGH

Teammate "log-analyst":
  → Checking debugger for error 11200
  → Found: 500 errors from /messaging/send-sms endpoint
  → Confirms code-tracer's finding

Teammate "config-checker":
  → Checking webhook config, env vars
  → All correct — rules out configuration issue
  → Supports code-level root cause

Lead synthesis:
  → Root cause: Missing body validation
  → Fix: Add null check before Twilio API call
  → Regression test: Empty body should return 400, not 500

Quality Gates

Teammates are subject to TeammateIdle and TaskCompleted hooks:

  • test-gen tasks: Tests must exist AND fail
  • dev tasks: Tests must pass + lint clean
  • qa tasks: Coverage >= 80%
  • All tasks: No hardcoded credentials

Pattern Selection Guide

Is work sequential with clear phases?
├── Yes → Sequential Pipeline
│         Start with /architect, follow phase sequence
│
└── No → Do agents need to discuss findings?
         ├── Yes → Agent Teams Pattern
         │         Use /team command
         │
         └── No → Can tasks run independently?
                  ├── Yes → Peer-to-Peer Pattern
                  │         Run multiple commands in parallel
                  │
                  └── No → Is there natural hierarchy?
                           ├── Yes → Hierarchical Pattern
                           │         Lead agent delegates to teams
                           │
                           └── No → Evaluator Pattern
                                     Quality gate with feedback loop

Twilio-Specific Considerations

Webhook Chains = Orchestrator

Twilio webhooks naturally follow orchestrator pattern:

graph LR
    IC["Incoming Call"] --> IVR["IVR Menu"] --> GI["Gather Input"] --> RC["Route Call"] --> REC["Record"] --> HU["Hangup"]
    IC -.-> H1["Handler 1"]
    IVR -.-> H2["Handler 2"]
    GI -.-> H3["Handler 3"]
    RC -.-> H4["Handler 4"]
    REC -.-> H5["Handler 5"]

Each handler is a function that passes control to the next via TwiML action URLs.

Real-Time Features = Peer Pattern

ConversationRelay and real-time features benefit from peer coordination:

graph TD
    VH["Voice Handler\n(TwiML setup)"] <--> WS["WebSocket AI\n(LLM backend)"]
    VH --> SS["Shared State\n(context)"]
    WS --> SS

Multi-Channel = Hierarchical

Voice + SMS + Verify solutions need hierarchical coordination:

User Verification Flow
├── Channel Selection (Lead)
│   ├── Voice: Call with OTP
│   ├── SMS: Text with code
│   └── Email: Link with token
└── Verification Check (Shared)

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.