websockets-best-practices
Installation
SKILL.md
WebSockets best practices
Use when designing, building, or reviewing WebSocket-based real-time systems.
Mental model
- A WebSocket is a long-lived bidirectional connection, not just “HTTP but realtime”.
- Design the system around connection lifecycle, message contracts, delivery expectations, and failure recovery.
- Keep protocol design explicit. Real-time systems become fragile when message shapes and state transitions are only implied in client code.
Connection lifecycle
- Make connect, authenticate, subscribe, unsubscribe, disconnect, reconnect, and session-expiry states explicit.
- Expect connections to drop, stall, race, or reconnect at inconvenient times.
- Keep connection ownership clear so the app knows who is responsible for opening, closing, and resetting socket state.