Skip to main content
skill CX Codex

websocket-implementation · aj-geddes — Claude Code skill: WebSocket servers

A coding skill that walks you through building a WebSocket server: connection management, message routing, and Redis-based scaling.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add aj-geddes/useful-ai-prompts --skill websocket-implementation -a claude-code
Open on GitHub

What websocket-implementation does

The skill covers how to build real-time systems over WebSocket. It ships a quick start on Node.js with express, socket.io and redis, plus reference guides in the references/ directory: a Socket.IO server, a browser client, a Python server on aiohttp, message types and protocols, and scaling with Redis.

The quick start sets reconnection options and wires a Redis adapter for horizontal scaling. Connection management uses a Map; the full implementation lives in the reference guides. You need Node.js and the packages express, socket.io, redis and @socket.io/redis-adapter.

A separate section lists practices: authentication, graceful reconnection, rooms and channels, rate limiting, message acknowledgment. The don't list warns against unbounded message history in memory and arbitrary room creation. If scaling has been a later problem for you, this is a reason to check the architecture before the first release.

What it helps with

  • stand up a WebSocket server on Node.js with Socket.IO
  • handle client reconnection after a dropped network
  • route messages across rooms and channels
  • wire a Redis adapter for multiple instances
  • add authentication and message rate limiting

Example prompts for the agent

  • build a Socket.IO WebSocket server with rooms and a Redis adapter
  • add reconnection handling and message acknowledgments
  • show me how to scale WebSockets across instances with Redis

How to install websocket-implementation

1Skills CLI (Vercel)

npx skills add aj-geddes/useful-ai-prompts --skill websocket-implementation -a claude-code

2Manually: put the files in place

~/.claude/skills/websocket-implementation/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/websocket-implementation/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about websocket-implementation

How do I install websocket-implementation in Claude?

Run npx skills add aj-geddes/useful-ai-prompts --skill websocket-implementation -a claude-code. The skill lands in ~/.claude/skills/websocket-implementation/SKILL.md.

What does websocket-implementation do?

It helps you implement real-time bidirectional communication: connection management, message routing, error handling, and scaling with Redis.

What is this skill used for?

Chat, live notifications, collaborative editing, dashboards, and streaming events to clients.

Source text

SKILL.md · MIT
---
name: websocket-implementation
description: >
  Implement real-time bidirectional communication with WebSockets including
  connection management, message routing, and scaling. Use when building
  real-time features, chat systems, live notifications, or collaborative
  applications.
---

# WebSocket Implementation

## Table of Contents

- [Overview](#overview)
- [When to Use](#when-to-use)
- [Quick Start](#quick-start)
- [Reference Guides](#reference-guides)
- [Best Practices](#best-practices)

## Overview

Build scalable WebSocket systems for real-time communication with proper connection management, message routing, error handling, and horizontal scaling support.

## When to Use

- Building real-time chat and messaging
- Implementing live notifications
- Creating collaborative editing tools
- Broadcasting live data updates
- Building real-time dashboards
- Streaming events to clients
- Live multiplayer games

## Quick Start

Minimal working example:

```javascript
const express = require("express");
const http = require("http");
const socketIo = require("socket.io");
const redis = require("redis");

const app = express();
const server = http.createServer(app);
const io = socketIo(server, {
  cors: { origin: "*" },
  transports: ["websocket", "polling"],
  reconnection: true,
  reconnectionDelay: 1000,
  reconnectionDelayMax: 5000,
  reconnectionAttempts: 5,
});

// Redis adapter for horizontal scaling
const redisClient = redis.createClient();
const { createAdapter } = require("@socket.io/redis-adapter");

io.adapter(createAdapter(redisClient, redisClient.duplicate()));

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

// ... (see reference guides for full implementation)
```

## Reference Guides

Detailed implementations in the `references/` directory:

| Guide | Contents |
|---|---|
| [Node.js WebSocket Server (Socket.IO)](references/nodejs-websocket-server-socketio.md) | Node.js WebSocket Server (Socket.IO) |
| [Browser WebSocket Client](references/browser-websocket-client.md) | Browser WebSocket Client |
| [Python WebSocket Server (aiohttp)](references/python-websocket-server-aiohttp.md) | Python WebSocket Server (aiohttp) |
| [Message Types and Protocols](references/message-types-and-protocols.md) | Message Types and Protocols |
| [Scaling with Redis](references/scaling-with-redis.md) | Scaling with Redis |

## Best Practices

### ✅ DO

- Implement proper authentication
- Handle reconnection gracefully
- Manage rooms/channels effectively
- Persist messages appropriately
- Monitor active connections
- Implement presence features
- Use Redis for scaling
- Add message acknowledgment
- Implement rate limiting
- Handle errors properly

### ❌ DON'T

- Send unencrypted sensitive data
- Keep unlimited message history in memory
- Allow arbitrary room/channel creation
- Forget to clean up disconnected connections
- Send large messages frequently
- Ignore network failures
- Store passwords in messages
- Skip authentication/authorization
- Create unbounded growth of connections
- Ignore scalability from day one

© aj-geddes · MIT · aj-geddes/useful-ai-prompts

Similar skills

Everything for Backend and APIs →

websocket-implementation by other authors comes first.

From the same set118

agile-sprint-planning Helps teams organize sprints by setting clear sprint goals, estimating story points, managing backlogs against team velocity, and running standups. CX Codex +1 669installs business-case-development Walks your agent through a business case: quantify benefits and costs, assess risks, and make the ROI argument to leadership. CX Codex +1 668installs security-compliance-audit A skill that walks through security compliance checks for SOC 2, GDPR, HIPAA, PCI-DSS and ISO 27001. Useful before certification or an annual audit. CX Codex +1 665installs gitlab-cicd-pipeline A skill that steers your agent through writing .gitlab-ci.yml: stages, jobs, caching, artifacts, Kubernetes deploys. Useful when a pipeline needs building or reworking. CX Codex +1 664installs project-estimation A skill that helps the agent estimate project scope, timeline and resources. Useful when you need a budget or a plan you can defend. CX Codex +1 659installs log-analysis A skill that helps the agent read application and system logs: spot errors, recurring patterns and the root cause of a failure. Useful when a service breaks and you need answers. CX Codex +1 657installs image-optimization A skill that walks your agent through compressing images and picking modern formats. Useful before a deploy, when pages drag on mobile networks. CX Codex +1 656installs requirements-gathering Walks your agent through collecting and documenting stakeholder requirements before development starts. Useful at project kickoff and feature planning. CX Codex +1 655installs

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor