skills/websocket-realtime-expert/SKILL.md
WebSockets, SSE, and real-time communication with Socket.io and native APIs. Activate on: WebSocket, real-time, SSE, Socket.io, live updates, push notifications, bidirectional, presence. NOT for: message queue infrastructure (use event-driven-architecture-expert), API gateway routing (use api-gateway-reverse-proxy-expert).
npx skillsauth add curiositech/windags-skills websocket-realtime-expertInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Build reliable real-time communication systems using WebSockets, Server-Sent Events, and managed real-time services.
Activate on: "WebSocket", "real-time", "SSE", "Socket.io", "live updates", "push notifications", "bidirectional", "presence", "live cursors", "collaborative editing"
NOT for: Message queue setup → event-driven-architecture-expert | Gateway WebSocket routing → api-gateway-reverse-proxy-expert | Streaming data pipelines → streaming-pipeline-architect
type discriminator and monotonic sequence IDs| Domain | Technologies | |--------|-------------| | WebSocket | ws (Node), Socket.io 4.8+, uWebSockets.js | | SSE | Native EventSource, @microsoft/fetch-event-source | | Managed | Supabase Realtime, Ably, Pusher, PartyKit | | Scaling | Redis Pub/Sub, NATS, @socket.io/redis-adapter | | Protocols | WebSocket (RFC 6455), SSE, WebTransport (HTTP/3) |
Client A ──ws──→ Server 1 ←──redis pub/sub──→ Server 2 ←──ws── Client B
│ │
└─────── Redis Cluster ───────┘
Each server subscribes to channels. When Server 1 receives a message
for a room, it publishes to Redis. Server 2 picks it up and forwards
to its connected clients.
// Server: SSE endpoint with resume support
app.get('/events', (req, res) => {
res.writeHead(200, {
'Content-Type': 'text/event-stream',
'Cache-Control': 'no-cache',
'Connection': 'keep-alive',
});
const lastId = parseInt(req.headers['last-event-id'] || '0');
// Replay missed events from store
const missed = eventStore.since(lastId);
missed.forEach(evt => {
res.write(`id: ${evt.id}\nevent: ${evt.type}\ndata: ${JSON.stringify(evt.data)}\n\n`);
});
// Subscribe to new events
const unsub = eventBus.subscribe(evt => {
res.write(`id: ${evt.id}\nevent: ${evt.type}\ndata: ${JSON.stringify(evt.data)}\n\n`);
});
req.on('close', unsub);
});
// Client sends heartbeat every 15s
const HEARTBEAT_INTERVAL = 15_000;
const PRESENCE_TIMEOUT = 45_000; // 3 missed heartbeats = offline
// Server tracks presence
const presence = new Map<string, { userId: string; lastSeen: number }>();
ws.on('message', (msg) => {
const { type, userId } = JSON.parse(msg);
if (type === 'heartbeat') {
presence.set(userId, { userId, lastSeen: Date.now() });
}
});
// Sweep stale presence every 10s
setInterval(() => {
const cutoff = Date.now() - PRESENCE_TIMEOUT;
for (const [id, p] of presence) {
if (p.lastSeen < cutoff) {
presence.delete(id);
broadcast({ type: 'presence:leave', userId: id });
}
}
}, 10_000);
type discriminatordata-ai
license: Apache-2.0 NOT for unrelated tasks outside this domain.
development
Use when designing caching strategies (cache-aside, write-through, write-behind), implementing distributed locks, building rate limiters, leaderboards, real-time streams (XADD/consumer groups), pub/sub, or tuning eviction policies. Triggers: thundering-herd on cache miss, dogpile on key expiry, Redlock vs SET-NX-PX choice, sliding-window rate limiter, hot-key on a single cluster slot, big-key blowup, MULTI/EXEC across slots, KEYS in production. NOT for Redis Cluster operations/admin (different domain), embedded KV (SQLite, leveldb), in-process LRU caches, or Memcached.
tools
Drawing the `'use client'` boundary correctly in React Server Components apps (Next.js App Router, RSC frameworks) — leaf-pushing, slot composition, serialization rules, and environment poisoning prevention. Grounded in react.dev and Next.js 16 docs.
development
Use when designing rate limiting for an API, choosing between token bucket / sliding window / leaky bucket / fixed window, implementing it in Redis, deciding edge (Cloudflare/Upstash) vs origin enforcement, sizing per-user vs per-IP vs per-endpoint quotas, returning the right 429 response with Retry-After, or fixing the boundary-burst bug in fixed-window limiters. Triggers: 429 too many requests, INCR + EXPIRE, ZADD + ZREMRANGEBYSCORE + ZCARD, X-RateLimit-Remaining header, Cloudflare WAF rate limiting rules, Upstash @upstash/ratelimit, leaky bucket shaping vs policing, distributed rate limiter consistency. NOT for DDoS mitigation specifically (different scale), CAPTCHA / bot management, full WAF design, or per-user quota billing.