A

Agent Messaging Expert

Enterprise-grade skill for send, receive, cryptographically, signed. Includes structured workflows, validation checks, and reusable patterns for ai maestro.

SkillClipticsai maestrov1.0.0MIT
0 views0 copies

Agent Messaging Expert

Overview

A skill for implementing structured inter-agent communication in multi-agent systems. Enables Claude Code agents to send, receive, and process messages with proper protocols β€” supporting direct messaging, broadcast, request-reply patterns, and task coordination between agents working on shared codebases.

When to Use

  • Coordinating multiple Claude agents working on the same project
  • Building pipelines where one agent's output feeds another's input
  • Implementing review workflows with handoffs between specialists
  • Managing shared state across concurrent agent sessions
  • Debugging communication issues in multi-agent setups

Quick Start

# Send a message between agents claude "Send the security review findings to the implementation agent" # Set up a messaging channel claude "Create a message queue for the refactoring pipeline" # Check agent inbox claude "Check for pending messages from the review team"

Communication Patterns

1. Direct Messaging (Point-to-Point)

One agent sends a message to a specific agent:

Agent A ──message──→ Agent B

Use when: Assigning work, sending results, requesting review.

// Leader sends task to specific agent write("security-reviewer", { type: "task_assignment", subject: "Review auth middleware", body: "Check src/middleware/auth.ts for OWASP Top 10 vulnerabilities", priority: "high", deadline: "before_merge" });

2. Broadcast (One-to-Many)

Leader sends a message to all team members:

Leader ──broadcast──→ Agent A
                   ──→ Agent B
                   ──→ Agent C

Use when: Announcing changes, setting constraints, requesting status updates.

// Announce a constraint to all agents broadcast("review-team", { type: "constraint", body: "All changes must maintain backward compatibility with API v2" });

Warning: Broadcasts are expensive β€” each agent must process the message. Prefer direct messages when possible.

3. Request-Reply

Agent sends a request and waits for a response:

Agent A ──request──→ Agent B
Agent A ←──replyβ”€β”€β”€β”˜

Use when: Seeking approval, asking for information, confirming before proceeding.

// Agent requests approval before destructive operation const approval = await requestApproval("team-lead", { type: "plan_approval", subject: "Database schema migration", plan: "Drop deprecated columns: user.legacy_id, order.old_status", impact: "Irreversible after migration runs" }); if (approval.approved) { // Proceed with migration } else { // Revise plan based on feedback }

4. Publish-Subscribe (Event-Based)

Agents subscribe to topics and receive relevant messages:

Event Bus ──"test.complete"──→ Agent A (subscribed)
          ──"test.complete"──→ Agent C (subscribed)
           (Agent B not subscribed β€” no message)

Use when: Loosely coupled agents that react to events.

Message Format

Standard Message Structure

{ "id": "msg_abc123", "from": "security-reviewer", "to": "team-lead", "type": "task_complete", "subject": "Security review findings", "body": "Found 2 critical issues in auth.ts", "data": { "findings": [ { "severity": "critical", "file": "src/auth.ts", "line": 45, "issue": "SQL injection" }, { "severity": "high", "file": "src/auth.ts", "line": 89, "issue": "Missing rate limit" } ], "summary": { "critical": 2, "high": 1, "medium": 0 } }, "timestamp": "2024-01-15T10:30:00Z", "replyTo": null }

Message Types

TypePurposeExample
task_assignmentAssign work to an agent"Review auth middleware"
task_completeReport completed work"Security review done, 2 issues found"
plan_approvalRequest sign-off"Approve this migration plan?"
status_updateProgress report"3/5 files reviewed"
constraintSet rules for all agents"Don't modify shared config"
shutdown_requestAsk agent to exit"Work complete, please clean up"
errorReport failure"Build failed, blocking deployment"
handoffTransfer work to another agent"Passing DB review to specialist"

Message Routing

Priority Levels

urgent    β†’  Interrupt current work, process immediately
high      β†’  Process next, before normal queue
normal    β†’  Process in order received
low       β†’  Process when idle

Message Queue Management

# Check inbox (unread messages) amp-inbox # Check all messages including read amp-inbox --all # Filter by sender amp-inbox --from security-reviewer # Filter by type amp-inbox --type task_complete # Read specific message amp-read msg_abc123 # Reply to a message amp-reply msg_abc123 "Acknowledged, will fix the SQL injection first"

Error Handling

Delivery Failures

// Retry with exponential backoff async function sendWithRetry(to, message, maxRetries = 3) { for (let attempt = 0; attempt < maxRetries; attempt++) { try { return await send(to, message); } catch (err) { if (attempt === maxRetries - 1) throw err; await sleep(Math.pow(2, attempt) * 1000); } } }

Dead Letter Queue

Messages that can't be delivered after retries go to a dead letter queue for manual inspection:

# Check dead letter queue amp-dead-letters # Retry a dead letter amp-retry msg_failed_123 # Discard a dead letter amp-discard msg_failed_123

Security

Message Validation

  • Verify sender identity before processing
  • Validate message schema against expected types
  • Reject messages with unexpected fields or oversized payloads
  • Log all messages for audit trail

Access Control

{ "permissions": { "security-reviewer": { "can_send_to": ["team-lead"], "can_broadcast": false }, "team-lead": { "can_send_to": ["*"], "can_broadcast": true }, "worker": { "can_send_to": ["team-lead"], "can_broadcast": false } } }

Best Practices

  1. Prefer direct over broadcast β€” Targeted messages reduce noise and cost
  2. Include context in messages β€” Don't assume the receiver knows the background
  3. Use structured data β€” JSON payloads over free text for machine-processable messages
  4. Set timeouts β€” Don't wait indefinitely for replies
  5. Acknowledge important messages β€” Confirm receipt of critical assignments
  6. Keep messages small β€” Send references (file paths, IDs) not full content
  7. Log all communication β€” Enables debugging and audit trails
  8. Handle message ordering β€” Messages may arrive out of order; use timestamps
  9. Clean up channels β€” Remove completed conversations to reduce clutter
  10. Graceful shutdown β€” Send shutdown acknowledgment before exiting
Community

Reviews

Write a review

No reviews yet. Be the first to review this template!

Similar Templates