websocket-realtime
Skill1 starsChanged 9 months agoApache-2.0View on GitHub
Build WebSocket servers, implement client reconnection with backoff, heartbeat keepalive, SSE, Socket.io rooms, Redis pub/sub scaling, and authentication.
- Reads credentials
3 other projects use a version of this.
Adopted by
Most recently taken up by
- valentinesamuel/claude-skillstheir own version, first seen Apr 19, 2026
- FutureJJ/claude-skillstheir own version, first seen Mar 7, 2026
- rohitg00/awesome-claude-code-toolkittheir own version, first seen Feb 4, 2026
Other versions3 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 3
- rohitg00/awesome-claude-code-toolkit★ 2.7ksame name
- FutureJJ/claude-skills★ 3same name
- valentinesamuel/claude-skills★ 1same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository73 other files it gives its agents.
- accessibility-wcagSkill
- api-designSkill
- api-testingSkill
- asset-optimizationSkill
- audio-systemsSkill
- aws-essentialsSkill
- ci-cd-pipelinesSkill
- codebase-analysisSkill
- code-reviewerSkill
- container-securitySkill
- cost-optimizationSkill
- database-designSkill
- data-visualizationSkill
- doc-generationSkill
- docker-kubernetesSkill
- docxSkill
- email-notificationsSkill
- env-configSkill
- flutter-mobileSkill
- framer-motionSkill
- frontend-code-reviewSkill
- frontend-designSkill
- fullstack-developerSkill
- game-enginesSkill
- gameplay-designSkill
- game-programming-languagesSkill
- game-serversSkill
- git-workflowSkill
- godot-4Skill
- golang-proSkill
- go-linter-configurationSkill
- graphics-renderingSkill
- i18n-localizationSkill
- incident-responseSkill
- level-designSkill
- llm-integrationSkill
- local-securitySkill
- memory-managementSkill
- monetization-systemsSkill
- monitoring-observabilitySkill
- multiplayer-netcodeSkill
- nextjs-16Skill
- notebooklm-researchSkill
- npm-packageSkill
- oauth-authSkill
- particle-systemsSkill
- performance-optimizationSkill
- playwright-testingSkill
- postgres-advancedSkill
- programming-architectureSkill
- project-migrationSkill
- publishing-platformsSkill
- python-best-practicesSkill
- react-nativeSkill
- redis-patternsSkill
- refactoring-patternsSkill
- remotion-best-practicesSkill
- rust-best-practicesSkill
- scraping-automationSkill
- security-reviewSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
3 rules. 0 are common, 3 are distinctive, and 0 are very specific to this project.
0
Common
Most of the 3 edited versions we read keep these.
3
Distinctive
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 14
BAD: No connection lifecycle management.
- Distinctive: line 114
BAD: No reconnection or infinite reconnect spam.
- Distinctive: line 208
BAD: No authentication, anyone can connect.
“Common” is measured: kept by at least 6 in 10 of the 3 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
WebSocket and Real-Time Communication
Build production-ready WebSocket servers with reconnection, heartbeat, authentication, and horizontal scaling.
WebSocket Server (Node.js ws)
BAD: No connection lifecycle management.
import WebSocket, { WebSocketServer } from 'ws';
const wss = new WebSocketServer({ port: 8080 });
wss.on('connection', (ws) => {
ws.on('message', (data) => {
// Broadcast to everyone
wss.clients.forEach((client) => {
client.send(data);
});
});
});GOOD: Connection tracking, error handling, graceful shutdown.
import WebSocket, { WebSocketServer } from 'ws';
import http from 'http';
interface Client {
ws: WebSocket;
userId: string;
rooms: Set<string>;
isAlive: boolean;
}
const server = http.createServer();
const wss = new WebSocketServer({ server });
const clients = new Map<WebSocket, Client>();
wss.on('connection', (ws, req) => {
const client: Client = {
ws,
userId: '', // Set after auth
rooms: new Set(),
isAlive: true,
};
clients.set(ws, client);
ws.on('pong', () => {
client.isAlive = true;
});
ws.on('message', (data) => {
try {
const msg = JSON.parse(data.toString());
handleMessage(client, msg);
} catch (err) {
ws.send(JSON.stringify({ error: 'Invalid message format' }));
}
});
ws.on('error', (err) => {
console.error('WebSocket error:', err);
});
ws.on('close', () => {
clients.delete(ws);
});
ws.send(JSON.stringify({ type: 'connected' }));
});
// Heartbeat interval
const heartbeat = setInterval(() => {
wss.clients.forEach((ws) => {
const client = clients.get(ws);
if (!client) return;
if (!client.isAlive) {
client.rooms.clear();
clients.delete(ws);
return ws.terminate();
}
client.isAlive = false;
ws.ping();
});
}, 30000);
// Graceful shutdown
process.on('SIGTERM', () => {
clearInterval(heartbeat);
wss.clients.forEach((ws) => {
ws.close(1000, 'Server shutting down');
});
server.close(() => {
process.exit(0);
});
});
server.listen(8080);Client Reconnection with Exponential Backoff
BAD: No reconnection or infinite reconnect spam.
const ws = new WebSocket('ws://localhost:8080');
ws.onclose = () => {
// Lost connection, nothing happens
};GOOD: Exponential backoff with jitter and max attempts.
class ReconnectingWebSocket {
private ws: WebSocket | null = null;
private url: string;
private reconnectAttempts = 0;
private maxReconnectAttempts = 10;
private baseDelay = 1000;
private maxDelay = 30000;
private reconnectTimer: NodeJS.Timeout | null = null;
constructor(url: string) {
this.url = url;
this.connect();
}
private connect() {
this.ws = new WebSocket(this.url);
this.ws.onopen = () => {
console.log('Connected');
this.reconnectAttempts = 0;
};
this.ws.onmessage = (event) => {
const msg = JSON.parse(event.data);
this.handleMessage(msg);
};
this.ws.onerror = (err) => {
console.error('WebSocket error:', err);
};
this.ws.onclose = () => {
console.log('Disconnected');
this.scheduleReconnect();
};
}
private scheduleReconnect() {
if (this.reconnectAttempts >= this.maxReconnectAttempts) {
console.error('Max reconnect attempts reached');
return;
}
const delay = Math.min(
this.baseDelay * Math.pow(2, this.reconnectAttempts),
this.maxDelay
);
const jitter = delay * 0.3 * Math.random();
const totalDelay = delay + jitter;
this.reconnectAttempts++;
console.log(`Reconnecting in ${Math.round(totalDelay)}ms (attempt ${this.reconnectAttempts})`);
this.reconnectTimer = setTimeout(() => {
this.connect();
}, totalDelay);
}
send(data: any) {
if (this.ws?.readyState === WebSocket.OPEN) {
this.ws.send(JSON.stringify(data));
} else {
console.warn('WebSocket not open, message queued');
}
}
close() {
if (this.reconnectTimer) {
clearTimeout(this.reconnectTimer);
}
this.ws?.close();
}
private handleMessage(msg: any) {
// Application logic
}
}Authentication on WebSocket Upgrade
BAD: No authentication, anyone can connect.
wss.on('connection', (ws) => {
// Unauthenticated connection
});GOOD: JWT verification during upgrade handshake.
import jwt from 'jsonwebtoken';
import { parse } from 'url';
const JWT_SECRET = process.env.JWT_SECRET || 'your-secret';
wss.on('connection', (ws, req) => {
const { query } = parse(req.url || '', true);
const token = query.token as string;
if (!token) {
ws.close(1008, 'Authentication required');
return;
}
try {
const payload = jwt.verify(token, JWT_SECRET) as { userId: string };
const client: Client = {
ws,
userId: payload.userId,
rooms: new Set(),
isAlive: true,
};
clients.set(ws, client);
ws.send(JSON.stringify({ type: 'authenticated', userId: payload.userId }));
} catch (err) {
ws.close(1008, 'Invalid token');
}
});Room-Based Broadcasting
BAD: Broadcasting to all clients regardless of relevance.
function broadcast(message: any) {
wss.clients.forEach((client) => {
client.send(JSON.stringify(message));
});
}GOOD: Room-based message routing.
function joinRoom(client: Client, room: string) {
client.rooms.add(room);
client.ws.send(JSON.stringify({ type: 'joined', room }));
}
function leaveRoom(client: Client, room: string) {
client.rooms.delete(room);
client.ws.send(JSON.stringify({ type: 'left', room }));
}
function broadcastToRoom(room: string, message: any, excludeClient?: Client) {
clients.forEach((client) => {
if (client.rooms.has(room) && client !== excludeClient) {
client.ws.send(JSON.stringify(message));
}
});
}
function handleMessage(client: Client, msg: any) {
switch (msg.type) {
case 'join':
joinRoom(client, msg.room);
break;
case 'leave':
leaveRoom(client, msg.room);
break;
case 'message':
broadcastToRoom(msg.room, {
type: 'message',
from: client.userId,
data: msg.data,
}, client);
break;
}
}<!-- See references/advanced.md for extended examples -->Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

