Skip to content
secondsky avatar

Websocket Implementation

Real-time WebSocket server and client patterns built on Socket.IO, with Redis scaling for multi-server deployments.

CCM score
50 of 100
skills.sh installs
452
GitHub stars
257
last updated
Aug 21, 2026
View on GitHub

Own this skill? Claim it

What it does

  • Covers Socket.IO server setup, client connection handling, a React hook, and a typed message protocol with delivery acknowledgments
  • Includes a Redis adapter for horizontal scaling, room-based and per-user message routing, and /api/ws/stats and /api/ws/health monitoring endpoints
  • Requires token authentication on handshake and authorization on room joins, with client-side message queuing while disconnected
  • Designed for chat systems, live notifications, collaborative tools, and real-time dashboards, with a connection-count scaling guide

Install

$ npx -y skills add secondsky/claude-skills --skill websocket-implementation -y

Installs into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.

Files

WebSocket Implementation

Build scalable real-time communication systems with proper connection management.

Server Implementation (Socket.IO)

const { Server } = require('socket.io');
const { createAdapter } = require('@socket.io/redis-adapter');
const { createClient } = require('redis');

const io = new Server(server, {
  cors: { origin: process.env.CLIENT_URL, credentials: true }
});

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

// Connection management
const users = new Map();

io.use((socket, next) => {
  const token = socket.handshake.auth.token;
  try {
    socket.user = verifyToken(token);
    next();
  } catch (err) {
    next(new Error('Authentication failed'));
  }
});

io.on('connection', (socket) => {
  users.set(socket.user.id, socket.id);
  console.log(`User ${socket.user.id} connected`);

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

Details

Repository
github.com/secondsky/claude-skills
Categories
Backend & APIs, Frontend & UI Code
First seen
Jun 3, 2026

Questions

What does the websocket-implementation skill do?

The websocket-implementation skill builds real-time WebSocket communication with connection management, room-based messaging, and horizontal scaling. It gives Claude Code working Socket.IO server and client code, a React hook, and a message protocol with delivery acknowledgments.

Who should use the websocket-implementation skill?

The websocket-implementation skill suits developers building chat systems, live notifications, collaborative tools, or real-time dashboards. Its scaling table moves from a single server under 10K connections to Redis pub/sub and then sharded Redis behind a load balancer.

What does websocket-implementation need to run?

The websocket-implementation skill's examples use Socket.IO, the Redis adapter, and a Redis server reached through a REDIS_URL environment variable, plus a CLIENT_URL setting for CORS. Its server code expects a verifyToken helper that you supply for authentication.

How do I install the websocket-implementation skill?

Run npx -y skills add secondsky/claude-skills --skill websocket-implementation -y in your project to install the websocket-implementation skill. Once installed, Claude Code can write its Socket.IO server, client, and room-based messaging code for you.

More from secondsky/claude-skills

All 116

Similar to Websocket Implementation

More Backend & APIs