Inspiration

When teams use multiple Claude Code sessions to parallelize development, each agent's context drifts as it discovers constraints, changes approaches, or uncovers dependencies. Humans spend 30-50% of development time manually syncing context through Slack, PRs, and meetings — not because the work is hard, but because LLMs have no way to coordinate with each other. We asked: what if AI agents could sync context, negotiate conflicts, and coordinate their work autonomously?

What it does

PeerCode is a coordination server that enables multiple Claude Code sessions to build software in parallel through three protocols:

  1. Context Delta Propagation — Agents push discoveries (contract changes, new dependencies, scope shifts) to a shared plan, and peers receive them in real-time via WebSocket.
  2. Structured Debates — When two agents disagree on an interface or approach, they enter a multi-round negotiation protocol. Only if they can't reach consensus after 5 rounds does it escalate to a human.
  3. File-Level Locking + Sync Coordination — Agents acquire granular locks (file, section, or line-level) before editing, and coordinate serialized pushes to a shared peer-progress branch.

The server also uses the Anthropic API for AI-powered project decomposition — breaking a project description into phases, tasks, and interface contracts optimized for parallelization.

How we built it

  • Node.js + TypeScript server with Express 5 for REST, ws for WebSocket, and the official MCP SDK for the Streamable HTTP transport
  • ClickHouse Cloud for append-only event streams (deltas, debate messages, audit trail)
  • In-memory store with ClickHouse fallback for mutable live state (projects, locks, sessions)
  • Anthropic API for project decomposition and planning, with Nimble web search for grounding debates in current facts
  • Datadog LLM Observability for end-to-end tracing of every MCP tool call and agent action
  • Zod for input validation on all MCP tool schemas
  • Vitest for unit and integration testing

Challenges we ran into

  • Drift detection accuracy — Deciding what constitutes a "significant" context change worth broadcasting vs. local-only noise. Too many deltas creates noise; too few creates real drift.
  • Debate convergence — Ensuring agents actually negotiate and propose alternatives rather than just restating their positions across rounds.
  • Temporal coupling — Handling the case where Agent A pushes a contract change while Agent B is mid-implementation against the old contract.
  • MCP Streamable HTTP transport — Managing per-session transport state and lifecycle correctly with the new Streamable HTTP protocol.

Accomplishments that we're proud of

  • A working bidirectional context consensus protocol where LLMs are first-class coordination participants — no existing system does this.
  • The debate system that actually produces structured multi-round negotiation between agents with escalation to humans as a fallback.
  • End-to-end Datadog LLM Observability tracing every agent action for full visibility.
  • A clean composition-root architecture where storage, services, and transports are fully decoupled and testable.

What we learned

  • LLM-to-LLM coordination is fundamentally different from human-to-human coordination — agents need structured protocols (not free-form chat) to converge reliably.
  • The MCP protocol is powerful but requires careful session management, especially with the Streamable HTTP transport.
  • ClickHouse is an excellent fit for append-only event streams but requires async-aware code for live mutable state.
  • Lock granularity matters — file-level locks are too coarse for parallel work; section and line-level locks are essential for real parallelization.

What's next for PeerCode

  • Auto-drift detection — Have agents automatically determine what's worth broadcasting vs. keeping local.
  • Federated agent support — Allow developers using different AI tools (Cursor, Windsurf, etc.) to sync through the same PeerCode server.
  • Metrics and learning — Measure successful context propagation vs. noise, and auto-tune drift detection thresholds based on team patterns.
  • Web UI — Build the full dual-pane dashboard (vertical tree roadmap + Kanban board) for human visibility into agent coordination.

Built With

Share this project:

Updates