realtime-patterns

Implement WebSocket, SSE, CRDT, and presence patterns for live collaborative applications.

Updated Apr 13, 2026
One-click install
npx skills add https://github.com/JenilRevaliya/ARGUS --skill realtime-patterns-jenilrevaliya
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: realtime-patterns
Source: https://github.com/JenilRevaliya/ARGUS/tree/main/.agent/skills/realtime-patterns
Command: npx skills add https://github.com/JenilRevaliya/ARGUS --skill realtime-patterns-jenilrevaliya

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Choosing and correctly implementing real-time communication protocols is error-prone: developers often default to WebSockets for one-way streams, forget reconnection logic, or mishandle optimistic UI rollbacks. This Skill provides proven patterns for building chat, live dashboards, and collaborative features without common pitfalls. ## Core Features & Use Cases - Protocol Selection Guidance: Decision rules for SSE vs WebSocket vs HTTP polling vs WebTransport based on data direction, latency, and proxy compatibility. - Production Code Patterns: Ready-to-adapt TypeScript implementations for SSE servers with heartbeats, WebSocket connection management with exponential-backoff reconnection, optimistic updates with React Query rollback, and presence tracking with timeouts. - Use Case: Building a live notification feed? Use the SSE pattern with auto-reconnect and Last-Event-ID resume. Building a chat room? Use the WebSocket broadcast-to-room pattern with ping/pong heartbeat to detect dead connections. ## Quick Start Ask the AI to implement a real-time notification system using Server-Sent Events with automatic reconnection for your Express and React app.

Frequently Asked Questions about realtime-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
When should I use SSE vs WebSocket?▼

Use SSE for one-way server-to-client streams like notifications, live feeds, and AI token streaming since it has built-in auto-reconnection and works through HTTP proxies. Use WebSocket for bidirectional communication like chat, gaming, and collaborative editing.

How do I implement WebSocket reconnection in JavaScript?▼

Wrap the WebSocket in a class that listens for onclose and retries with exponential backoff, capping delay at 30 seconds and limiting max retries. Reset the retry counter on successful connection to avoid permanent backoff after temporary failures.

How do I detect dead WebSocket connections on the server?▼

Run a periodic interval that calls ping() on every open connection, typically every 30 seconds. Clients respond with pong automatically; connections that stop responding can be terminated and removed from the client registry.

How do optimistic updates work with React Query?▼

Cancel in-flight queries, snapshot the current cache, apply the new state immediately via setQueryData, then roll back to the snapshot in onError. Invalidate the query in onSettled to refetch authoritative server state.

Does SSE work through proxies and CDNs?▼

Yes, SSE works through most HTTP proxies and CDNs since it uses standard HTTP. Set the X-Accel-Buffering: no header to disable nginx buffering, and send periodic heartbeat comments to prevent idle connection timeouts.

What are the limitations of HTTP polling for live data?▼

HTTP polling introduces latency equal to the poll interval and wastes requests when nothing has changed. It is the simplest option and works everywhere, but SSE or WebSocket is preferable for frequent updates.