Real-time communication patterns for live updates, collaboration, and presence. Use when building chat applications, collaborative tools, live dashboards, or streaming interfaces (LLM responses, metrics). Covers SSE (server-sent events for one-way streams), WebSocket (bidirectional communication), WebRTC (peer-to-peer video/audio), CRDTs (Yjs, Automerge for conflict-free collaboration), presence patterns, offline sync, and scaling strategies. Supports Python, Rust, Go, and TypeScript.
View on GitHubancoleman/ai-design-components
backend-ai-skills
February 1, 2026
Select agents to install to:
npx add-skill https://github.com/ancoleman/ai-design-components/blob/main/skills/implementing-realtime-sync/SKILL.md -a claude-code --skill implementing-realtime-syncInstallation paths:
.claude/skills/implementing-realtime-sync/# Real-Time Sync Implement real-time communication for live updates, collaboration, and presence awareness across applications. ## When to Use Use this skill when building: - **LLM streaming interfaces** - Stream tokens progressively (ai-chat integration) - **Live dashboards** - Push metrics and updates to clients - **Collaborative editing** - Multi-user document/spreadsheet editing with CRDTs - **Chat applications** - Real-time messaging with presence - **Multiplayer features** - Cursor tracking, live updates, presence awareness - **Offline-first apps** - Mobile/PWA with sync-on-reconnect ## Protocol Selection Framework Choose the transport protocol based on communication pattern: ### Decision Tree ``` ONE-WAY (Server → Client only) ├─ LLM streaming, notifications, live feeds └─ Use SSE (Server-Sent Events) ├─ Automatic reconnection (browser-native) ├─ Event IDs for resumption └─ Simple HTTP implementation BIDIRECTIONAL (Client ↔ Server) ├─ Chat, games, collaborative editing └─ Use WebSocket ├─ Manual reconnection required ├─ Binary + text support └─ Lower latency for two-way COLLABORATIVE EDITING ├─ Multi-user documents/spreadsheets └─ Use WebSocket + CRDT (Yjs or Automerge) ├─ CRDT handles conflict resolution ├─ WebSocket for transport └─ Offline-first with sync PEER-TO-PEER MEDIA ├─ Video, screen sharing, voice calls └─ Use WebRTC ├─ WebSocket for signaling ├─ Direct P2P connection └─ STUN/TURN for NAT traversal ``` ### Protocol Comparison | Protocol | Direction | Reconnection | Complexity | Best For | |----------|-----------|--------------|------------|----------| | SSE | Server → Client | Automatic | Low | Live feeds, LLM streaming | | WebSocket | Bidirectional | Manual | Medium | Chat, games, collaboration | | WebRTC | P2P | Complex | High | Video, screen share, voice | ## Implementation Patterns ### Pattern 1: LLM Streaming with SSE Stream LLM tokens progressively to frontend (ai-chat integration). **Pytho