# Websocket Engineer

Use when building real-time communication systems with WebSockets or Socket.IO.

- Repository: https://github.com/Jeffallan/claude-skills (12164 stars)
- Category: Engineering
- License: MIT
- Last updated: 2026-10-30
- Runs scripts: no, instructions only

## Install

Claude Code: `npx skills add Jeffallan/claude-skills --skill websocket-engineer -g -a claude-code -y`
Codex: `npx skills add Jeffallan/claude-skills --skill websocket-engineer -g -a codex -y`
Cursor: `npx skills add Jeffallan/claude-skills --skill websocket-engineer -g -a cursor -y`
Gemini CLI: `npx skills add Jeffallan/claude-skills --skill websocket-engineer -g -a gemini-cli -y`
Claude Code plugin marketplace: `/plugin marketplace add Jeffallan/claude-skills`

## Description

Use when building real-time communication systems with WebSockets or Socket.IO. Invoke for bidirectional messaging, horizontal scaling with Redis, presence tracking, room management.

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# 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:

| Topic | Reference | Load When |
|-------|-----------|-----------|
| Protocol | `references/protocol.md` | WebSocket handshake, frames, ping/pong, close codes |
| Scaling | `references/scaling.md` | Horizontal scaling, Redis pub/sub, sticky sessions |
| Patterns | `references/patterns.md` | Rooms, namespaces, broadcasting, acknowledgments |
| Security | `references/security.md` | Authentication, authorization, rate limiting, CORS |
| Alternatives | `references/alternatives.md` | SSE, long polling, when to choose WebSockets |

## Code Examples

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

```js
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,
});

The rest: https://github.com/Jeffallan/claude-skills/blob/HEAD/skills/websocket-engineer/SKILL.md
