home / skills / zpankz / mcp-skillset / multi-agent-coordination

multi-agent-coordination skill

/multi-agent-coordination

This skill coordinates multiple agents in a project, managing sessions, file reservations, and peer communication to prevent conflicts.

npx playbooks add skill zpankz/mcp-skillset --skill multi-agent-coordination

Review the files below or copy the command above to add this skill to your agents.

Files (1)
SKILL.md
2.8 KB
---
name: multi-agent-coordination
description: Automatically invoked when peer agents are detected in the same project. Establishes coordination protocols, file reservations, and message-based collaboration. Triggers on SessionStart when other agents exist in the project.
---

# Multi-Agent Coordination Protocol

You are operating in a **multi-agent environment**. Other agents are working on this project concurrently.

## Mandatory Coordination Behavior

### 1. Session Initialization (Do This First)

```yaml
sequence:
  1. register_agent:
      project_key: ${CWD}
      program: "claude-code"
      model: "claude-opus-4-5"
      # Name auto-generated (adjective+noun like "BlueLake")

  2. fetch_inbox:
      agent_name: ${YOUR_AGENT_NAME}
      include_bodies: true
      # Check for pending coordination messages

  3. Acknowledge any ack_required messages immediately
```

### 2. Before Editing Files

**Always reserve files before editing:**

```yaml
file_reservation_paths:
  project_key: ${CWD}
  agent_name: ${YOUR_AGENT_NAME}
  paths: ["path/to/file.py"]  # Or glob: "src/api/*.py"
  ttl_seconds: 3600
  exclusive: true
  reason: "Implementing feature X"
```

**If conflicts returned:**
- Check who holds the reservation
- Send a message requesting coordination
- Wait for response or reservation expiry

### 3. Communication Protocol

**Notify peers of significant changes:**

```yaml
send_message:
  to: ["PeerAgentName"]  # Or discovered via list_agents
  subject: "Working on: [component]"
  body_md: |
    ## What I'm doing
    - Modifying X
    - Adding Y

    ## Files affected
    - `src/foo.py`
    - `src/bar.py`

    ## Coordination needed?
    Let me know if this conflicts with your work.
  importance: "normal"
```

### 4. Periodic Inbox Polling

**Check inbox between major work units:**

```yaml
frequency: After each significant edit/commit
action: fetch_inbox → process messages → acknowledge
```

### 5. File Release on Completion

**Release reservations when done:**

```yaml
release_file_reservations:
  agent_name: ${YOUR_AGENT_NAME}
  # Omit paths to release all
```

## Quick Reference Commands

| Action | Tool |
|--------|------|
| Start session | `macro_start_session` |
| Check peers | `whois` + project agents resource |
| Reserve files | `file_reservation_paths` |
| Send update | `send_message` |
| Check inbox | `fetch_inbox` |
| Reply | `reply_message` |
| Release files | `release_file_reservations` |

## Conflict Resolution

1. **File conflict**: Message the holder, propose merge strategy
2. **Overlapping work**: Summarize thread, align on ownership
3. **Urgent coordination**: Use `importance: "urgent"` + `ack_required: true`

## Exit Protocol

Before ending session:
1. `release_file_reservations` (all)
2. `send_message` with session summary to active peers
3. Mark any pending inbox items as read

Overview

This skill establishes automated coordination when multiple agents are detected in the same project. It sets up session registration, file reservation, message-based notifications, and periodic inbox polling so agents can work concurrently with reduced conflicts. The skill triggers on session start whenever peer agents exist and enforces mandatory coordination steps.

How this skill works

On SessionStart the skill registers the agent in the project and fetches the inbox to surface pending coordination messages. It reserves files before edits, sends structured messages to peers about intent and affected files, polls the inbox after major edits, and releases reservations and posts a session summary when work finishes. Conflict-handling and acknowledgement rules are enforced automatically.

When to use it

  • Automatically invoked at session start when other agents are present
  • Before modifying any repository files or running bulk edits
  • After completing a significant commit or work unit
  • When you need to notify peers about overlapping areas or request merges
  • Any time you detect reservations conflicts or receive ack_required messages

Best practices

  • Register immediately at session start and fetch your inbox before taking action
  • Always reserve files (exclusive when needed) and include a TTL and reason
  • Send concise messages listing what you will change and which files are affected
  • Poll the inbox between major edits and acknowledge ack_required messages promptly
  • If a reservation conflict occurs, message the holder proposing a merge or handoff strategy
  • Release all reservations and send a final session summary before exiting

Example use cases

  • Implementing a new feature that touches shared modules—reserve files, announce intent, and release on completion
  • Hotfix coordination—set urgent importance with ack_required to get fast acknowledgement
  • Parallel refactor of APIs—reserve paths via glob patterns and exchange merge plans with peers
  • Coordinated testing runs—announce test changes and affected scripts to avoid overlapping test edits
  • Large migration where multiple agents change different subsystems—poll inbox frequently and align ownership

FAQ

What happens if a file reservation is already held by another agent?

Check who holds the reservation, message them requesting coordination or a handoff, and wait for their reply or the reservation TTL to expire.

When should I use urgent importance and ack_required?

Use urgent with ack_required for time-sensitive conflicts or changes that must not be delayed; acknowledge messages immediately and escalate if no response arrives within an agreed window.