Agent Messaging Expert
Enterprise-grade skill for send, receive, cryptographically, signed. Includes structured workflows, validation checks, and reusable patterns for ai maestro.
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
| Type | Purpose | Example |
|---|---|---|
task_assignment | Assign work to an agent | "Review auth middleware" |
task_complete | Report completed work | "Security review done, 2 issues found" |
plan_approval | Request sign-off | "Approve this migration plan?" |
status_update | Progress report | "3/5 files reviewed" |
constraint | Set rules for all agents | "Don't modify shared config" |
shutdown_request | Ask agent to exit | "Work complete, please clean up" |
error | Report failure | "Build failed, blocking deployment" |
handoff | Transfer 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
- Prefer direct over broadcast β Targeted messages reduce noise and cost
- Include context in messages β Don't assume the receiver knows the background
- Use structured data β JSON payloads over free text for machine-processable messages
- Set timeouts β Don't wait indefinitely for replies
- Acknowledge important messages β Confirm receipt of critical assignments
- Keep messages small β Send references (file paths, IDs) not full content
- Log all communication β Enables debugging and audit trails
- Handle message ordering β Messages may arrive out of order; use timestamps
- Clean up channels β Remove completed conversations to reduce clutter
- Graceful shutdown β Send shutdown acknowledgment before exiting
Reviews
No reviews yet. Be the first to review this template!
Similar Templates
Full-Stack Code Reviewer
Comprehensive code review skill that checks for security vulnerabilities, performance issues, accessibility, and best practices across frontend and backend code.
Test Suite Generator
Generates comprehensive test suites with unit tests, integration tests, and edge cases. Supports Jest, Vitest, Pytest, and Go testing.
Pro Architecture Workspace
Battle-tested skill for architectural, decision, making, framework. Includes structured workflows, validation checks, and reusable patterns for development.