Designs resilient peer-to-peer multi-agent systems without central orchestration. Useful for decentralized collaboration, swarm-like behavior, and dynamic agent networks.
Ships in agent-architect. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Design resilient peer-to-peer agent networks where agents collaborate without central orchestration.
┌─────────┐ ┌─────────┐
│ Agent A │◄───►│ Agent B │
└────┬────┘ └────┬────┘
│ │
│ ┌───────┐ │
└──►│ Agent │◄──┘
│ C │
┌──►│ │◄──┐
│ └───────┘ │
┌────┴────┐ ┌────┴────┐
│ Agent D │◄───►│ Agent E │
└─────────┘ └─────────┘
Each agent is an independent node with communication capabilities.
interface AgentNode {
id: string;
capabilities: string[];
state: AgentState;
// Communication
broadcast(message: Message): Promise<void>;
sendTo(agentId: string, message: Message): Promise<void>;
onMessage(handler: MessageHandler): void;
// Discovery
discoverPeers(): Promise<AgentNode[]>;
announceCapability(capability: string): void;
// Task handling
canHandle(task: Task): boolean;
handle(task: Task): Promise<Result>;
}
interface Message {
type: 'task_request' | 'task_result' | 'collaboration_invite' |
'capability_query' | 'heartbeat' | 'consensus_vote';
from: string;
to: string | 'broadcast';
payload: unknown;
timestamp: Date;
correlationId: string;
}
interface MessageBus {
publish(topic: string, message: Message): Promise<void>;
subscribe(topic: string, handler: MessageHandler): Subscription;
request(agentId: string, message: Message): Promise<Message>;
}
// In-memory implementation for local agents
class LocalMessageBus implements MessageBus {
private subscribers = new Map<string, MessageHandler[]>();
async publish(topic: string, message: Message) {
const handlers = this.subscribers.get(topic) || [];
await Promise.all(handlers.map(h => h(message)));
}
subscribe(topic: string, handler: MessageHandler) {
const handlers = this.subscribers.get(topic) || [];
handlers.push(handler);
this.subscribers.set(topic, handlers);
return {
unsubscribe: () => {
const idx = handlers.indexOf(handler);
if (idx >= 0) handlers.splice(idx, 1);
}
};
}
}
interface ServiceRegistry {
register(agent: AgentNode): Promise<void>;
deregister(agentId: string): Promise<void>;
findByCapability(capability: string): Promise<AgentNode[]>;
getAll(): Promise<AgentNode[]>;
onAgentJoin(handler: (agent: AgentNode) => void): void;
onAgentLeave(handler: (agentId: string) => void): void;
}
class AgentRegistry implements ServiceRegistry {
private agents = new Map<string, AgentNode>();
private capabilities = new Map<string, Set<string>>();
async findByCapability(capability: string): Promise<AgentNode[]> {
const agentIds = this.capabilities.get(capability) || new Set();
return Array.from(agentIds)
.map(id => this.agents.get(id))
.filter(Boolean) as AgentNode[];
}
}
// Agent A needs help from specialized agent
async function requestHelp(task: Task): Promise<Result> {
// Find capable agents
const candidates = await registry.findByCapability(task.requiredCapability);
if (candidates.length === 0) {
throw new Error(`No agent can handle: ${task.requiredCapability}`);
}
// Select best candidate (load balancing, proximity, etc.)
const selected = selectBestAgent(candidates, task);
// Send request and await response
const response = await messageBus.request(selected.id, {
type: 'task_request',
payload: task
});
return response.payload as Result;
}
// Multiple agents vote on a decision
async function reachConsensus(question: string, voters: AgentNode[]): Promise<Decision> {
const correlationId = generateId();
// Broadcast question to all voters
const votePromises = voters.map(voter =>
messageBus.request(voter.id, {
type: 'consensus_vote',
correlationId,
payload: { question }
})
);
const votes = await Promise.all(votePromises);
// Aggregate votes
const tally = new Map<string, number>();
for (const vote of votes) {
const choice = vote.payload.choice;
tally.set(choice, (tally.get(choice) || 0) + 1);
}
// Determine winner
const winner = [...tally.entries()]
.sort((a, b) => b[1] - a[1])[0];
return {
choice: winner[0],
confidence: winner[1] / voters.length,
votes: votes.map(v => ({ agent: v.from, choice: v.payload.choice }))
};
}
// Agents bid on tasks
async function auctionTask(task: Task): Promise<AgentNode> {
const correlationId = generateId();
// Broadcast task availability
await messageBus.publish('tasks', {
type: 'task_auction',
correlationId,
payload: { task, deadline: Date.now() + 5000 }
});
// Collect bids within deadline
const bids: Bid[] = [];
return new Promise((resolve) => {
const sub = messageBus.subscribe(`bids:${correlationId}`, (msg) => {
bids.push(msg.payload as Bid);
});
setTimeout(() => {
sub.unsubscribe();
// Select winning bid
const winner = bids.sort((a, b) => {
// Consider: capability match, current load, past performance
return scoreBid(b, task) - scoreBid(a, task);
})[0];
resolve(winner.agent);
}, 5000);
});
}
// Agents share state updates through gossip
class GossipProtocol {
private state = new Map<string, StateEntry>();
async gossip() {
// Select random peers
const peers = selectRandomPeers(this.registry, 3);
for (const peer of peers) {
// Exchange state digests
const theirDigest = await this.requestDigest(peer);
const myDigest = this.getDigest();
// Find differences
const theyNeed = this.findMissing(myDigest, theirDigest);
const iNeed = this.findMissing(theirDigest, myDigest);
// Exchange missing entries
if (theyNeed.length) await this.sendUpdates(peer, theyNeed);
if (iNeed.length) this.applyUpdates(await this.requestUpdates(peer, iNeed));
}
}
// Run gossip periodically
startGossipLoop(intervalMs: number) {
setInterval(() => this.gossip(), intervalMs);
}
}
const agentBehavior = {
onTaskReceived: async (task: Task) => {
// Can I handle this?
if (this.canHandle(task)) {
if (this.currentLoad < this.capacity) {
return this.handle(task);
} else {
// Overloaded, find help
return this.delegateToCapablePeer(task);
}
}
// Find someone who can
const capable = await this.findCapablePeer(task);
if (capable) {
return this.forwardTo(capable, task);
}
// No one can handle
return { error: 'No capable agent found' };
}
};
async function collaborativeSolve(problem: Problem): Promise<Solution> {
// Phase 1: Brainstorm
const ideas = await broadcastAndCollect<Idea>('brainstorm', {
problem,
timeout: 10000
});
// Phase 2: Critique and refine
const refinedIdeas = await broadcastAndCollect<Idea>('critique', {
ideas,
timeout: 15000
});
// Phase 3: Vote on best solution
const decision = await reachConsensus(
'Which solution should we implement?',
this.getAllAgents()
);
// Phase 4: Collaborate on implementation
return collaborativeImplement(decision.choice);
}
class HeartbeatMonitor {
private lastSeen = new Map<string, number>();
private TIMEOUT_MS = 30000;
recordHeartbeat(agentId: string) {
this.lastSeen.set(agentId, Date.now());
}
checkHealth(): string[] {
const now = Date.now();
const failed: string[] = [];
for (const [agentId, lastTime] of this.lastSeen) {
if (now - lastTime > this.TIMEOUT_MS) {
failed.push(agentId);
}
}
return failed;
}
async handleFailures(failed: string[]) {
for (const agentId of failed) {
// Remove from registry
await registry.deregister(agentId);
// Reassign pending tasks
const pendingTasks = await getPendingTasks(agentId);
for (const task of pendingTasks) {
await redistributeTask(task);
}
}
}
}
async function redistributeTask(task: Task) {
// Find available capable agents
const candidates = await registry.findByCapability(task.capability);
const available = candidates.filter(a => a.state.load < a.state.capacity);
if (available.length === 0) {
// Queue for later
await taskQueue.push(task);
return;
}
// Assign to least loaded
const target = available.sort((a, b) => a.state.load - b.state.load)[0];
await assignTask(target, task);
}
| Aspect | Mesh | Supervisor |
|---|---|---|
| Failure tolerance | High | Single point of failure |
| Visibility | Distributed | Centralized |
| Coordination overhead | Higher | Lower |
| Emergent behavior | Yes | Controlled |
| Scaling | Natural | Requires design |
| Debugging | Harder | Easier |
What SKILL.md sets; muted values are Claude Code's defaults
/agent-architect:agent-mesh-architecturefrom agent-architect
npx claudepluginhub latestaiagents/agent-skills --plugin agent-architect13 skills in this plugin
/a2a-protocolsImplement Agent-to-Agent (A2A) communication for cross-framework interoperability.
Use this skill when building multi-agent communication, implementing agent protocols,
connecting agents across frameworks, or standardizing agent interfaces.
Activate when: agent to agent, A2A, agent communication, agent protocol,
cross-framework agents, agent interoperability, MCP, agent discovery.
/agent-checkpointingImplement checkpointing for agent recovery, debugging, and replay.
Use this skill when building recoverable agents, implementing replay,
debugging agent failures, or creating resumable workflows.
Activate when: agent checkpoint, agent recovery, resume agent, agent restart,
workflow replay, agent debugging, failure recovery, state snapshot.
/agent-cost-budgetingUse this skill when managing AI agent costs. Activate when the user needs to control token usage,
implement cost limits for agents, optimize LLM spending, track agent costs, or prevent runaway
API bills in agent systems.
/agent-error-recoveryUse this skill when implementing error handling for AI agents. Activate when the user needs agents to
handle failures gracefully, implement retry strategies, design fault-tolerant agent systems, or build
agents that can recover from errors without human intervention.
/agent-handoff-protocolsUse this skill when designing task handoffs between agents. Activate when the user needs to pass work
between agents, transfer context between agents, implement agent-to-agent communication, or design
protocols for agents to collaborate on sequential tasks.
/agent-memory-systemsUse this skill when implementing memory for AI agents. Activate when the user needs agents to remember
past interactions, implement context persistence, build knowledge bases for agents, design agent state
management, or create shared memory between multiple agents.
4 plugins in one repository ship this exact skill · first indexed Aug 19, 2026
Other plugins' skills for the same job