socket-io — Claude Code skill: what it does, how to install
Guides your coding assistant through Socket.IO real-time features: namespaces, rooms, middleware auth, and Redis scaling.
MIT 106 installs ★ 50 updated 2026-10-23
npx skills add claude-dev-suite/claude-dev-suite --skill socket-io -a claude-codeWhat socket-io does
This skill equips the agent with patterns for bidirectional event streaming using Socket.IO. It covers typed event contracts via TypeScript interfaces, message acknowledgments, reconnect strategies, and a React useSocket hook.
For multi-server architectures, it outlines horizontal scaling via @socket.io/redis-adapter using paired Redis clients. Without an adapter, events scoped to rooms fail across multiple application nodes.
It sets distinct boundaries: avoid using this skill for WebRTC peer streams or unidirectional Server-Sent Events, as those need separate skills.
What it helps with
- set up typed Socket.IO event contracts in TypeScript
- protect socket connections using token authentication middleware
- isolate real-time message feeds into rooms
- scale Socket.IO across instances with a Redis adapter
- wire socket connections into React using a custom hook
Example prompts for the agent
- Configure a Socket.IO server with JWT authentication middleware and typed events
- Create a React hook for room subscriptions with delivery confirmations
- Set up the Redis adapter to scale Socket.IO horizontally across nodes
How to install socket-io
1Skills CLI (Vercel)
npx skills add claude-dev-suite/claude-dev-suite --skill socket-io -a claude-code2Manually: put the files in place
~/.claude/skills/socket-io/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/socket-io/
1Skills CLI (Vercel)
npx skills add claude-dev-suite/claude-dev-suite --skill socket-io -a codex2Manually: put the files in place
.agents/skills/socket-io/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add claude-dev-suite/claude-dev-suite --skill socket-io -a cursor2Manually: put the files in place
.cursor/skills/socket-io/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install claude-dev-suite/claude-dev-suite skills/real-time/socket-io2Manually: put the files in place
.github/skills/socket-io/SKILL.md1Skills CLI (Vercel)
npx skills add claude-dev-suite/claude-dev-suite --skill socket-io -a gemini-cli2Platform CLI
gemini skills install https://github.com/claude-dev-suite/claude-dev-suite --path skills/real-time/socket-ioManually: put the files in place
.devin/skills/socket-io/SKILL.mdThe legacy .windsurf/skills/ path still works
Skills CLI (Vercel)
npx skills add claude-dev-suite/claude-dev-suite --skill socket-io -a opencodeClaude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
Step by step, with commands for each platform: How to install skills in Claude Code: five ways
Questions about socket-io
How to install socket-io in Claude Code?
Run npx skills add claude-dev-suite/claude-dev-suite --skill socket-io -a claude-code. You can also place the file directly at ~/.claude/skills/socket-io/SKILL.md.
What does socket-io do?
It guides the agent on structuring Socket.IO code, preventing common anti-patterns like broadcasting to all users without room scoping.
Can I use this skill for WebRTC or SSE?
No. The skill instructions specifically exclude Server-Sent Events and WebRTC, directing users to dedicated sse and webrtc skills instead.
Source text
SKILL.md · MIT
---
name: socket-io
description: |
Socket.IO real-time bidirectional communication. Rooms, namespaces,
acknowledgments, middleware, scaling with Redis adapter, and TypeScript types.
USE WHEN: user mentions "Socket.IO", "socket.io", "real-time chat",
"live updates", "bidirectional WebSocket", "rooms", "namespaces"
DO NOT USE FOR: SSE (server-sent events) - use `sse`;
WebRTC - use `webrtc`; raw WebSocket without Socket.IO - use framework WS skills
allowed-tools: Read, Grep, Glob, Write, Edit
---
# Socket.IO
## Server Setup
```typescript
import { Server } from 'socket.io';
import { createServer } from 'http';
const httpServer = createServer(app);
interface ServerToClientEvents {
message: (data: { user: string; text: string; timestamp: number }) => void;
userJoined: (user: string) => void;
}
interface ClientToServerEvents {
sendMessage: (text: string, callback: (status: 'ok' | 'error') => void) => void;
joinRoom: (room: string) => void;
}
const io = new Server<ClientToServerEvents, ServerToClientEvents>(httpServer, {
cors: { origin: process.env.CLIENT_URL },
});
// Authentication middleware
io.use((socket, next) => {
const token = socket.handshake.auth.token;
try {
socket.data.user = verifyToken(token);
next();
} catch {
next(new Error('Authentication failed'));
}
});
io.on('connection', (socket) => {
console.log(`${socket.data.user.name} connected`);
socket.on('joinRoom', (room) => {
socket.join(room);
socket.to(room).emit('userJoined', socket.data.user.name);
});
socket.on('sendMessage', (text, callback) => {
const message = { user: socket.data.user.name, text, timestamp: Date.now() };
io.to('general').emit('message', message);
callback('ok');
});
socket.on('disconnect', () => {
console.log(`${socket.data.user.name} disconnected`);
});
});
```
## Client Setup
```typescript
import { io, Socket } from 'socket.io-client';
const socket: Socket<ServerToClientEvents, ClientToServerEvents> = io(API_URL, {
auth: { token: getAuthToken() },
reconnection: true,
reconnectionDelay: 1000,
});
socket.on('connect', () => console.log('Connected'));
socket.on('message', (data) => addMessage(data));
socket.on('connect_error', (err) => console.error(err.message));
// With acknowledgment
socket.emit('sendMessage', 'Hello!', (status) => {
if (status === 'error') showError('Failed to send');
});
```
## Scaling with Redis Adapter
```typescript
import { createAdapter } from '@socket.io/redis-adapter';
import { createClient } from 'redis';
const pubClient = createClient({ url: process.env.REDIS_URL });
const subClient = pubClient.duplicate();
await Promise.all([pubClient.connect(), subClient.connect()]);
io.adapter(createAdapter(pubClient, subClient));
```
## React Hook
```tsx
function useSocket(room: string) {
const [messages, setMessages] = useState<Message[]>([]);
useEffect(() => {
socket.emit('joinRoom', room);
socket.on('message', (msg) => setMessages((prev) => [...prev, msg]));
return () => { socket.off('message'); };
}, [room]);
const send = (text: string) => socket.emit('sendMessage', text, () => {});
return { messages, send };
}
```
## Anti-Patterns
| Anti-Pattern | Fix |
|--------------|-----|
| No authentication | Use `io.use()` middleware with JWT |
| Broadcasting to all instead of rooms | Use `socket.to(room).emit()` |
| No reconnection handling | Enable reconnection, show UI indicator |
| Single server without adapter | Use Redis adapter for horizontal scaling |
| No acknowledgments for critical events | Use callback parameter for delivery confirmation |
## Production Checklist
- [ ] Authentication middleware on connection
- [ ] Redis adapter for multi-server deployment
- [ ] Reconnection with exponential backoff
- [ ] Room-based message scoping
- [ ] Connection state UI indicator
- [ ] Rate limiting on message events
© claude-dev-suite · MIT · claude-dev-suite/claude-dev-suite