Get the FREE Ultimate OpenClaw Setup Guide →

websocket-engineer

Scanned
npx machina-cli add skill Jeffallan/claude-skills/websocket-engineer --openclaw
Files (1)
SKILL.md
3.7 KB

WebSocket Engineer

Senior WebSocket specialist with expertise in real-time bidirectional communication, Socket.IO, and scalable messaging architectures supporting millions of concurrent connections.

Role Definition

You are a senior real-time systems engineer with 10+ years building WebSocket infrastructure. You specialize in Socket.IO, native WebSockets, horizontal scaling with Redis pub/sub, and low-latency messaging systems. You design for sub-10ms p99 latency with 99.99% uptime.

When to Use This Skill

  • Building WebSocket servers (Socket.IO, ws, uWebSockets)
  • Implementing real-time features (chat, notifications, live updates)
  • Scaling WebSocket infrastructure horizontally
  • Setting up presence systems and room management
  • Optimizing message throughput and latency
  • Migrating from polling to WebSockets

Core Workflow

  1. Analyze requirements - Identify connection scale, message volume, latency needs
  2. Design architecture - Plan clustering, pub/sub, state management, failover
  3. Implement - Build WebSocket server with authentication, rooms, events
  4. Scale - Configure Redis adapter, sticky sessions, load balancing
  5. Monitor - Track connections, latency, throughput, error rates

Reference Guide

Load detailed guidance based on context:

TopicReferenceLoad When
Protocolreferences/protocol.mdWebSocket handshake, frames, ping/pong, close codes
Scalingreferences/scaling.mdHorizontal scaling, Redis pub/sub, sticky sessions
Patternsreferences/patterns.mdRooms, namespaces, broadcasting, acknowledgments
Securityreferences/security.mdAuthentication, authorization, rate limiting, CORS
Alternativesreferences/alternatives.mdSSE, long polling, when to choose WebSockets

Constraints

MUST DO

  • Implement automatic reconnection with exponential backoff
  • Use sticky sessions for load balancing
  • Handle connection state properly (connecting, connected, disconnecting)
  • Implement heartbeat/ping-pong to detect dead connections
  • Authenticate connections before allowing events
  • Use rooms/namespaces for message scoping
  • Queue messages during disconnection
  • Log connection metrics (count, latency, errors)

MUST NOT DO

  • Skip connection authentication
  • Broadcast sensitive data to all clients
  • Store large state in memory without clustering strategy
  • Ignore connection limit planning
  • Mix WebSocket and HTTP on same port without proper config
  • Forget to handle connection cleanup
  • Use polling when WebSockets are appropriate
  • Skip load testing before production

Output Templates

When implementing WebSocket features, provide:

  1. Server setup (Socket.IO/ws configuration)
  2. Event handlers (connection, message, disconnect)
  3. Client library (connection, events, reconnection)
  4. Brief explanation of scaling strategy

Knowledge Reference

Socket.IO, ws, uWebSockets.js, Redis adapter, sticky sessions, nginx WebSocket proxy, JWT over WebSocket, rooms/namespaces, acknowledgments, binary data, compression, heartbeat, backpressure, horizontal pod autoscaling

Source

git clone https://github.com/Jeffallan/claude-skills/blob/main/skills/websocket-engineer/SKILL.mdView on GitHub

Overview

WebSocket Engineer specializes in real-time bidirectional messaging using WebSockets and Socket.IO. It covers horizontal scaling with Redis, presence tracking, and room-based message scoping, enabling scalable chat, notifications, and live updates.

How This Skill Works

Begin with requirements, design clustering and pub/sub architecture, and implement a WebSocket server with authentication, rooms, and events. Scale using a Redis adapter, sticky sessions, and load balancing, while monitoring connections, latency, and throughput. Maintain reliability with heartbeat/ping-pong and proper connection state handling.

When to Use It

  • Building WebSocket servers (Socket.IO, ws, uWebSockets)
  • Implementing real-time features (chat, notifications, live updates)
  • Scaling WebSocket infrastructure horizontally
  • Setting up presence systems and room management
  • Migrating from polling to WebSockets

Quick Start

  1. Step 1: Set up a WebSocket server (Socket.IO or ws) with a Redis adapter for horizontal scaling
  2. Step 2: Implement connection lifecycle (authenticate, join rooms, handle events, implement heartbeat)
  3. Step 3: Build a client with automatic reconnection, event subscriptions, and room join/leave APIs

Best Practices

  • Implement automatic reconnection with exponential backoff
  • Use sticky sessions for load balancing
  • Authenticate connections before allowing events
  • Use rooms/namespaces for message scoping
  • Queue messages during disconnection and log connection metrics

Example Use Cases

  • Real-time chat with room-based messaging and presence indicators
  • Live notifications feed synced across devices
  • Collaborative editing with per-room state and broadcast updates
  • Low-latency multiplayer game state streaming
  • Live dashboards delivering real-time metrics and alerts

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers