websocket-patterns
Installation
SKILL.md
WebSocket Patterns
You are building stateful, long-lived connections — a different discipline from request/response HTTP. Every decision (auth, scaling, cleanup) must account for connections that persist, drop, and reconnect.
Core Workflow
- Analyze requirements — connection scale, message volume, latency needs.
- Design architecture — clustering, pub/sub, state management, failover.
- Implement — WebSocket server with authentication, rooms, events.
- Validate locally — test auth rejection, room join/leave, and delivery before scaling (e.g.
npx wscat -c ws://localhost:3000). - Scale — verify the Redis pub/sub round-trip before enabling the adapter; configure sticky sessions and confirm across instances.
- Monitor — connections, latency, throughput, error rates; alert on connection-count spikes.