Add these rules to your Claude Code, Cursor, Cline, or Roo Cody configuration to enable inter-agent messaging.
On EVERY user interaction, IMMEDIATELY run:
# This MUST be the FIRST command in every session/interaction
bash .aea/scripts/aea-check.sh || cat .aea/prompts/check-messages.mdIf messages need processing:
# Use the iterative processor for handling multiple messages
bash .aea/scripts/process-messages-iterative.shIf automatic checking isn't available:
-
Check for the
.aea/directoryls -la .aea/ 2>/dev/null -
Look for unprocessed message files
ls -1t .aea/message-*.json 2>/dev/null | while read msg; do if [ ! -f ".aea/.processed/$(basename $msg)" ]; then echo "π¬ New message: $(basename $msg)" cat "$msg" | jq '.' fi done
-
Process based on message type and priority
- β
question(any priority) β Search codebase β Answer β Send response - β
update(normal priority) β Read β Acknowledge ifrequires_response: true - β
update(high/urgent) β Summarize key points to user - β
issue(low/medium) β Analyze β Suggest fix β Send response
- β
issue(high/urgent) β Notify user β Wait for approval before acting - β
handoff(any priority) β Review with user β Get approval - β
request(any priority) β Evaluate β Present plan β Get approval - β Any message requiring code changes β Always get approval first
When to send messages:
- β Completing integration work across repositories
- β Handing off responsibility to another codebase
- β Asking questions about dependencies
- β Reporting bugs that affect other repos
- β Sharing important updates or changes
How to send a message:
-
Create
.aea/directory in target repositorymkdir -p /path/to/other/repo/.aea/
-
Generate timestamp
date -u +"%Y%m%dT%H%M%SZ" # Example: 20251013T163529Z
-
Create message file
# Naming: message-{TIMESTAMP}-from-{YOUR_ID}.json cat > /path/to/other/repo/.aea/message-20251013T163529Z-from-claude-yourrepo.json
-
Use standard JSON structure (see below)
{
"protocol_version": "1.0",
"message_type": "handoff|question|issue|update|request|response",
"timestamp": "2025-10-13T16:35:29Z",
"from": {
"agent_id": "claude-your-repo-name",
"agent_type": "claude-sonnet-4.5",
"role": "Your role description",
"context": "/absolute/path/to/your/repo",
"expertise": ["skill1", "skill2"]
},
"to": {
"agent_id": "claude-target-repo|any-claude-instance",
"role": "Expected recipient role",
"context": "/absolute/path/to/target/repo"
},
"priority": "low|normal|high|urgent",
"requires_response": true|false,
"in_reply_to": "message-TIMESTAMP-from-SENDER.json",
"message": {
"subject": "Brief subject line",
"summary": "One paragraph summary",
"body": {
"what_was_built": "Detailed description",
"how_to_use": "Step-by-step instructions",
"next_steps": "What needs to happen next",
"files_created": ["file1.cpp", "file2.hpp"],
"documentation": ["/path/to/doc1.md"]
}
},
"metadata": {
"code_written": "500 lines",
"session_time": "5 hours",
"status": "complete|in-progress|blocked"
}
}| Type | When to Use | Required Fields | Auto-Process |
|---|---|---|---|
| handoff | Transferring responsibility | what_was_built, how_to_use, next_steps |
β Requires approval |
| question | Need information/clarification | question, context, requires_response: true |
β Auto-respond |
| issue | Report bug or problem | issue_description, severity, reproduction_steps |
|
| update | Share progress/status | update_summary, changes_made |
β Auto-acknowledge |
| request | Ask for work to be done | request_details, why_needed |
β Requires approval |
| response | Reply to previous message | in_reply_to, response_to_what |
β Auto-process |
| Message Type | Priority | Auto-Action | Description |
|---|---|---|---|
question |
Any | β Yes | Search code β Answer β Send response |
update |
Normal | β Yes | Read β Acknowledge if needed |
update |
High/Urgent | β Yes | Summarize key points to user |
issue |
Low/Medium | β Yes | Analyze β Suggest fix β Respond |
issue |
High/Urgent | β No | Notify user β Wait for approval |
handoff |
Any | β No | Review β Request user approval |
request |
Any | β No | Evaluate β Present plan to user |
response |
Any | β Yes | Process β Update context |
# THIS IS MANDATORY - Run at the beginning of EVERY user interaction:
bash .aea/scripts/aea-check.sh || cat .aea/prompts/check-messages.md-
Automatic Check (runs via script above)
- Scans for unprocessed messages
- Applies policy from agent-config.yaml
- Auto-responds to safe messages
- Flags risky messages for approval
-
If Messages Found
# For multiple messages or interactive processing: bash .aea/scripts/process-messages-iterative.sh -
Mark as Processed
touch .aea/.processed/$(basename $message_file) echo "[$(date '+%Y-%m-%d %H:%M:%S')] Processed: $type from $sender" >> .aea/agent.log
1. Consider if other repos need to know
2. Create handoff message if appropriate
3. Include all necessary context
4. Reference created files with absolute paths
# Generate timestamp
TIMESTAMP=$(date -u +%Y%m%dT%H%M%SZ)
# Create message in target repo
cat > /path/to/target/repo/.aea/message-${TIMESTAMP}-from-{YOUR_AGENT_ID}.json << 'EOF'
{
"protocol_version": "1.0",
"message_type": "response",
"from": {"agent_id": "{YOUR_AGENT_ID}"},
...
}
EOFAdd to your startup routine:
# Pseudo-code for agent startup
def on_session_start():
if directory_exists(".aea"):
messages = list_files(".aea/message-*.json")
if messages:
print("π¬ Inter-agent messages found:")
for msg in messages:
content = read_json(msg)
print(f" - From: {content['from']['agent_id']}")
print(f" Subject: {content['message']['subject']}")
print(f" Type: {content['message_type']}")
print("\nπ Processing messages...")
for msg in messages:
process_message(msg)When you start and find .aea/message-20251013T163529Z-from-claude-module-dev.json:
**Response to user:**
"π¬ Found inter-agent message from claude-module-dev (2025-10-13)
**Subject**: API Module Integration Complete - Production Ready
**Summary**: Complete integration of API module into this repository.
All code compiled (ApiHandler.cpp, 508 lines), tested, and ready for use.
**Key Points**:
- Files created: src/handlers/api_handler.{hpp,cpp}
- Endpoint: api-server-prod:8080
- Status: 100% complete, production-ready
**Next Steps**:
1. Review integration code (5-10 min)
2. Read HOW_IT_WORKS.md
3. Initialize ApiHandler in main.cpp
4. Wire up request handlers
5. Test with live traffic
Would you like me to proceed with the integration?"When you need to ask another agent something:
# Create message file
cat > /path/to/other-repo/.aea/message-$(date -u +%Y%m%dT%H%M%SZ)-from-claude-my-app.json << 'EOF'
{
"protocol_version": "1.0",
"message_type": "question",
"requires_response": true,
"timestamp": "2025-10-13T18:00:00Z",
"from": {
"agent_id": "claude-my-app",
"context": "/path/to/my/app"
},
"to": {
"agent_id": "claude-other-repo",
"context": "/path/to/other-repo"
},
"message": {
"subject": "Question about optimal batch_size",
"question": "What's the recommended batch_size for 50,000 updates/sec throughput?",
"context": "Currently using batch_size=100, interval=100ms. Seeing 200ms latency.",
"current_config": {
"batch_size": 100,
"batch_interval": "100ms",
"pool_size": 10
}
}
}
EOFWhen you find a bug that affects another repository:
{
"protocol_version": "1.0",
"message_type": "issue",
"priority": "high",
"timestamp": "2025-10-13T19:00:00Z",
"from": {
"agent_id": "claude-my-app"
},
"to": {
"agent_id": "claude-other-repo"
},
"message": {
"subject": "Memory leak in executeBatch()",
"issue_description": "Memory grows by 1MB/min during high load",
"severity": "high",
"reproduction_steps": [
"1. Run application with 10,000 updates/sec",
"2. Monitor with: watch -n 1 'ps aux | grep myapp'",
"3. Observe memory growth over 1 hour"
],
"suspected_cause": "Response objects not freed in loop",
"proposed_fix": "Add cleanup after each request()"
}
}β
Check .aea/ directory on EVERY session start
β
Read and acknowledge ALL messages found
β
Use absolute paths (never relative)
β
Include comprehensive context in messages
β
Inform user when sending/receiving messages
β
Copy PROTOCOL.md to new .aea/ directories
β Ignore the .aea/ directory
β Skip reading messages to save time
β Assume messages don't apply to you
β Send messages without user awareness
β Include sensitive data (passwords, keys, PII)
β Use relative paths or vague references
For complete details, see: .aea/PROTOCOL.md in this repository
Topics covered:
- Complete JSON schema
- All message types with examples
- Discovery protocol
- Threading and multi-cast
- Status tracking
- Advanced features
Add this to your agent configuration:
- Check for
.aea/on every session start - Read all
message-*.jsonfiles if present - Inform user about messages found
- Act on message content appropriately
- Create messages when doing cross-repo work
- Use standard JSON structure
- Include absolute paths
- Reference this protocol
First time seeing .aea/ directory?
- Read
.aea/PROTOCOL.mdfor full details - Check for message files:
ls .aea/message-*.json - Read any messages found
- Acknowledge to user
- Follow instructions in message content
- Create response if
requires_response: true
Need to send a message?
- Use template from "MESSAGE JSON STRUCTURE" above
- Generate timestamp:
date -u +%Y%m%dT%H%M%SZ - Create file:
message-{TIMESTAMP}-from-{YOUR_ID}.json - Include all necessary context
- Copy
.aea/PROTOCOL.mdif creating new.aea/directory
User: "Help me with X"
Agent:
1. Check .aea/
2. Found messages
3. Read and summarize for user
4. Ask if user wants to follow message instructions
Agent completes major work across repos:
1. Ask user: "Should I notify the other repository's agent?"
2. If yes, create handoff message
3. Include what was built, how to use, next steps
4. Inform user message was sent
Agent blocked by missing information:
1. Identify which repo has the info
2. Create question message
3. Set requires_response: true
4. Inform user question was sent
5. Continue with other work if possible
Add this section:
## Inter-Agent Communication (AEA Protocol)
**CRITICAL: On EVERY user interaction, IMMEDIATELY run:**
```bash
bash .aea/scripts/aea-check.sh || cat .aea/prompts/check-messages.mdThis repository uses the AEA protocol for async agent-to-agent communication.
Message Processing Rules:
- Auto-process: questions, normal updates, low/medium issues
- Require approval: high/urgent issues, handoffs, requests, code changes
For multiple messages: Use bash .aea/scripts/process-messages-iterative.sh
See: .aea/aea-rules.md for complete protocol documentation.
### **For Cursor (.cursorrules)**
Add:
- ALWAYS run first: bash .aea/scripts/aea-check.sh
- Auto-process safe messages (questions, updates)
- Get approval for risky messages (handoffs, urgent issues)
- Use .aea/scripts/process-messages-iterative.sh for multiple messages
- See .aea/aea-rules.md for complete protocol
### **For Cline/Roo Cody**
Add to project rules:
MANDATORY: Run "bash .aea/scripts/aea-check.sh" at start of every interaction. Auto-process questions and updates, get approval for handoffs and urgent issues. Use .aea/scripts/process-messages-iterative.sh for batch processing. Follow .aea/aea-rules.md protocol for all AEA communications.
---
## π― **TL;DR - MINIMAL RULES**
**Absolute minimum to add to your agent rules:**
- MANDATORY: Run "bash .aea/scripts/aea-check.sh" at start of EVERY interaction
- Auto-process: questions, normal updates, low/medium issues
- Get approval: high/urgent issues, handoffs, requests, code changes
- For multiple messages: Use .aea/scripts/process-messages-iterative.sh
- Mark processed: touch .aea/.processed/$(basename $message_file)
- Log actions: echo "[timestamp] action" >> .aea/agent.log
- When doing cross-repo work: Consider sending handoff message
- Always use absolute paths in messages
### **The ONE Command You Must Remember:**
```bash
# Run this FIRST in EVERY interaction:
bash .aea/scripts/aea-check.sh || cat .aea/prompts/check-messages.md
That's it! Copy these rules to your agent configuration to enable inter-agent communication.
For questions or updates to this protocol: Create a message in the appropriate .aea/ directory.