From vfm-agent-company
Real-Time Systems - WebSocket & Live Data Mastery. Build chat apps, live dashboards, collaborative tools, multiplayer games, or real-time notifications. Use when implementing bidirectional communication, live updates, or instant messaging.
npx claudepluginhub duylinhdang1998/claude-template-agent --plugin vfm-agent-companyThis skill uses the workspace's default tool permissions.
**Purpose**: Build real-time, bidirectional communication systems for chat, notifications, collaboration, and live updates
Searches, retrieves, and installs Agent Skills from prompts.chat registry using MCP tools like search_skills and get_skill. Activates for finding skills, browsing catalogs, or extending Claude.
Searches prompts.chat for AI prompt templates by keyword or category, retrieves by ID with variable handling, and improves prompts via AI. Use for discovering or enhancing prompts.
Checks Next.js compilation errors using a running Turbopack dev server after code edits. Fixes actionable issues before reporting complete. Replaces `next build`.
Purpose: Build real-time, bidirectional communication systems for chat, notifications, collaboration, and live updates
Agent: Netflix Backend Architect / Meta React Architect Use When: Building chat apps, live dashboards, collaborative tools, multiplayer games, or real-time notifications
Real-time systems enable instant, bidirectional communication between clients and servers without polling.
Technologies:
Use Cases:
| Technology | Direction | Use Case | Complexity |
|---|---|---|---|
| WebSocket | Bidirectional | Chat, games, collaboration | Medium |
| SSE | Server → Client | Notifications, dashboards | Low |
| Socket.IO | Bidirectional | Production apps with fallbacks | Low |
| WebRTC | P2P | Video/audio calls, file sharing | High |
import { Server } from 'socket.io'
import { createServer } from 'http'
const httpServer = createServer()
const io = new Server(httpServer, {
cors: { origin: 'http://localhost:3000', credentials: true }
})
io.on('connection', (socket) => {
socket.on('join-room', (roomId) => socket.join(roomId))
socket.on('send-message', ({ roomId, message }) => {
io.to(roomId).emit('receive-message', {
senderId: socket.id,
message,
timestamp: Date.now()
})
})
})
httpServer.listen(8080)
import { useEffect, useState } from 'react'
import { io } from 'socket.io-client'
const socket = io('http://localhost:8080')
function Chat() {
const [messages, setMessages] = useState([])
useEffect(() => {
socket.emit('join-room', 'room-123')
socket.on('receive-message', (data) => {
setMessages(prev => [...prev, data])
})
return () => socket.off('receive-message')
}, [])
const sendMessage = (text) => {
socket.emit('send-message', { roomId: 'room-123', message: text })
}
return <div>{/* UI */}</div>
}
user:${userId})For detailed code examples: Read references/code-examples.md
io.use((socket, next) => {
const token = socket.handshake.auth.token
try {
socket.userId = jwt.verify(token, process.env.JWT_SECRET).userId
next()
} catch (error) {
next(new Error('Authentication failed'))
}
})
const socket = io('http://localhost:8080', {
reconnection: true,
reconnectionDelay: 1000,
reconnectionDelayMax: 5000,
reconnectionAttempts: 5
})
socket.on('connect', () => {
socket.emit('join-room', currentRoomId) // Rejoin rooms
})
import { createAdapter } from '@socket.io/redis-adapter'
io.adapter(createAdapter(pubClient, subClient))
// Now multiple Socket.IO servers sync via Redis
| Pattern | Bad | Good |
|---|---|---|
| Data format | JSON for everything | Binary (MessagePack) for high-frequency |
| Updates | Send every change | Batch updates |
| Targeting | Loop through sockets | Use rooms |
io.on('connection', (socket) => {
console.log(`Total: ${io.engine.clientsCount}`)
})
setInterval(() => {
console.log('Rooms:', io.sockets.adapter.rooms.size)
console.log('Memory:', process.memoryUsage())
}, 60000)
For detailed code examples including:
Read: references/code-examples.md
Remember: Real-time systems need careful design. Handle reconnections, authenticate users, rate limit, and scale horizontally with Redis.
Created: 2026-02-04 Maintained By: Netflix Backend Architect Version: Socket.IO 4+