Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
jeffallan avatar

Websocket Engineer

  • 5.3k installs
  • 10.8k repo stars
  • Updated May 20, 2026
  • jeffallan/claude-skills

websocket-engineer is an agent skill for real-time WebSocket and Socket.IO systems with auth, rooms, Redis scaling, and presence tracking.

About

This skill implements real-time communication with WebSockets or Socket.IO, covering bidirectional messaging, presence tracking, room management, and horizontal scaling. The workflow analyzes connection scale and latency, designs clustering with Redis pub/sub and failover, builds servers with JWT handshake authentication and room events, validates locally with wscat for auth rejection and message delivery, then scales using Redis adapters, sticky sessions, and load balancing. Reference guides load for protocol handshake, scaling, rooms and acknowledgments, security with rate limiting and CORS, and SSE alternatives. Code examples show Socket.IO with Redis adapter, presence via hSet, join-room handlers, and client reconnection with exponential backoff plus offline message queuing. Must-do rules require sticky sessions, heartbeat ping-pong, room scoping, disconnect cleanup, and load testing. Must-not rules forbid unclustered in-memory state, mixed HTTP and WebSocket ports without upgrade handling, and skipping connection cleanup before production.

  • Six-step workflow from requirement analysis through local validation, scaling, and monitoring
  • Socket.IO server with JWT auth middleware, Redis adapter, presence hSet, and room events
  • Client reconnection with exponential backoff, jitter, and offline message queue flushing
  • Reference guides for protocol, scaling, patterns, security, and SSE or long-polling alternatives
  • Must-do scaling rules: sticky sessions, heartbeat ping-pong, room scoping, and load testing

Websocket Engineer by the numbers

  • 5,250 all-time installs (skills.sh)
  • +130 installs in the week ending Jul 28, 2026 (Skillselion tracking)
  • Ranked #133 of 4,386 Backend & APIs skills by installs in the Skillselion catalog
  • Security screen: LOW risk (skills.sh audit)
  • Data as of Jul 28, 2026 (Skillselion catalog sync)
At a glance

websocket-engineer capabilities & compatibility

Capabilities
websocket server implementation · socket io redis clustering · jwt handshake authentication · room and presence management · client reconnection and queuing
Works with
redis · docker · kubernetes
Use cases
api development · debugging · orchestration
From the docs

What websocket-engineer says it does

Use when building real-time communication systems with WebSockets or Socket.IO.
SKILL.md
Use sticky sessions for load balancing (WebSocket connections are stateful — requests must route to the same server instance)
SKILL.md
Queue messages during disconnection windows to avoid silent data loss
SKILL.md
npx skills add https://github.com/jeffallan/claude-skills --skill websocket-engineer

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs5.3k
repo stars10.8k
Security audit3 / 3 scanners passed
Last updatedMay 20, 2026
Repositoryjeffallan/claude-skills

How do you design, implement, and scale bidirectional real-time messaging with authentication, rooms, and clustered Socket.IO servers?

Build real-time WebSocket or Socket.IO systems with auth, rooms, Redis scaling, presence, and production monitoring.

Who is it for?

Teams adding chat, live updates, or presence features with Socket.IO or native WebSockets and Redis horizontal scaling.

Skip if: Static REST-only APIs, batch ETL pipelines, or projects with no need for persistent bidirectional connections.

When should I use this skill?

Building real-time communication, bidirectional messaging, horizontal scaling with Redis, presence tracking, or room management.

What you get

You get server and client patterns with JWT auth, Redis pub/sub adapters, sticky sessions, reconnection queues, and monitoring guidance ready to validate and scale.

  • WebSocket server setup
  • event handlers
  • client library with reconnection

By the numbers

  • Compares five real-time protocols: WebSocket, SSE, long polling, HTTP/2 push, and WebRTC
  • Documents bidirectionality, browser support, proxy issues, and overhead per protocol in a feature matrix

Files

SKILL.mdMarkdownGitHub ↗

WebSocket Engineer

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. Validate locally — Test connection handling, auth, and room behavior before scaling (e.g., npx wscat -c ws://localhost:3000); confirm auth rejection on missing/invalid tokens, room join/leave events, and message delivery 5. Scale — Verify Redis connection and pub/sub round-trip before enabling the adapter; configure sticky sessions and confirm with test connections across multiple instances; set up load balancing 6. Monitor — Track connections, latency, throughput, error rates; add alerts for connection-count spikes and error-rate thresholds

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

Code Examples

Server Setup (Socket.IO with Auth and Room Management)

import { createServer } from "http";
import { Server } from "socket.io";
import { createAdapter } from "@socket.io/redis-adapter";
import { createClient } from "redis";
import jwt from "jsonwebtoken";

const httpServer = createServer();
const io = new Server(httpServer, {
  cors: { origin: process.env.ALLOWED_ORIGIN, credentials: true },
  pingTimeout: 20000,
  pingInterval: 25000,
});

// Authentication middleware — runs before connection is established
io.use((socket, next) => {
  const token = socket.handshake.auth.token;
  if (!token) return next(new Error("Authentication required"));
  try {
    socket.data.user = jwt.verify(token, process.env.JWT_SECRET);
    next();
  } catch {
    next(new Error("Invalid token"));
  }
});

// Redis adapter for horizontal scaling
const pubClient = createClient({ url: process.env.REDIS_URL });
const subClient = pubClient.duplicate();
await Promise.all([pubClient.connect(), subClient.connect()]);
io.adapter(createAdapter(pubClient, subClient));

io.on("connection", (socket) => {
  const { userId } = socket.data.user;
  console.log(`connected: ${userId} (${socket.id})`);

  // Presence: mark user online
  pubClient.hSet("presence", userId, socket.id);

  socket.on("join-room", (roomId) => {
    socket.join(roomId);
    socket.to(roomId).emit("user-joined", { userId });
  });

  socket.on("message", ({ roomId, text }) => {
    io.to(roomId).emit("message", { userId, text, ts: Date.now() });
  });

  socket.on("disconnect", () => {
    pubClient.hDel("presence", userId);
    console.log(`disconnected: ${userId}`);
  });
});

httpServer.listen(3000);

Client-Side Reconnection with Exponential Backoff

import { io } from "socket.io-client";

const socket = io("wss://api.example.com", {
  auth: { token: getAuthToken() },
  reconnection: true,
  reconnectionAttempts: 10,
  reconnectionDelay: 1000,       // initial delay (ms)
  reconnectionDelayMax: 30000,   // cap at 30 s
  randomizationFactor: 0.5,      // jitter to avoid thundering herd
});

// Queue messages while disconnected
let messageQueue = [];

socket.on("connect", () => {
  console.log("connected:", socket.id);
  // Flush queued messages
  messageQueue.forEach((msg) => socket.emit("message", msg));
  messageQueue = [];
});

socket.on("disconnect", (reason) => {
  console.warn("disconnected:", reason);
  if (reason === "io server disconnect") socket.connect(); // manual reconnect
});

socket.on("connect_error", (err) => {
  console.error("connection error:", err.message);
});

function sendMessage(roomId, text) {
  const msg = { roomId, text };
  if (socket.connected) {
    socket.emit("message", msg);
  } else {
    messageQueue.push(msg); // buffer until reconnected
  }
}

Constraints

MUST DO

  • Use sticky sessions for load balancing (WebSocket connections are stateful — requests must route to the same server instance)
  • Implement heartbeat/ping-pong to detect dead connections (TCP keepalive alone is insufficient)
  • Use rooms/namespaces for message scoping rather than filtering in application logic
  • Queue messages during disconnection windows to avoid silent data loss
  • Plan connection limits per instance before scaling horizontally

MUST NOT DO

  • Store large state in memory without a clustering strategy (use Redis or an external store)
  • Mix WebSocket and HTTP on the same port without explicit upgrade handling
  • Forget to handle connection cleanup (presence records, room membership, in-flight timers)
  • Skip load testing before production — connection-count spikes behave differently from HTTP traffic spikes

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

Documentation

Related skills

How it compares

Choose websocket-engineer when protocol selection matters; use it before implementing WebSocket everywhere for feeds that SSE handles with less complexity.

FAQ

When should I choose WebSockets over SSE or long polling?

Load references/alternatives.md when latency, bidirectional messaging, or high-frequency server push needs exceed what SSE or long polling can support.

How do you scale Socket.IO across multiple server instances?

Connect a Redis pub/sub adapter, configure sticky sessions on the load balancer, and verify pub/sub round-trips before enabling clustered traffic.

What local checks should pass before scaling?

Use wscat to confirm auth rejects missing tokens, room join and leave events fire, and messages deliver before adding Redis adapters and load balancing.

Is Websocket Engineer safe to install?

skills.sh reports 3 of 3 security scanners passed. Review the Security Audits panel on this page before installing in production.

Backend & APIsbackendintegrations

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.