OpenParable
Skip to content
← Back to skills

Socketio

Development
socketio

Socketio is an Agent Skill for development published in the a5c-ai/babysitter repository on GitHub: a SKILL.md instruction file an AI agent can load to do this task.

Socket.io rooms, namespaces, adapters, middleware, and real-time patterns.

View on GitHub ↗
QUICK START

How to use this skill

Bring this guide into your coding agent with a prompt tailored to the tool you use.

  1. Open your project in Codex.
  2. Copy and paste the prompt below.
  3. Review files and risks before approving any action.
Prompt to paste
Inspect the Agent Skill at https://github.com/a5c-ai/babysitter/blob/HEAD/library/specializations/web-development/skills/socketio/SKILL.md and all supporting files. Report provenance, permissions, scripts, dependencies, and security risks. Propose an exact installation into .agents/skills/socketio, but wait for my approval before writing files or running scripts.

Copying this prompt does not install or run the skill. Review third-party files before use.

Socket.io Skill

Expert assistance for building real-time applications with Socket.io.

Capabilities

  • Configure Socket.io server
  • Implement rooms and namespaces
  • Use Redis adapter for scaling
  • Handle authentication middleware
  • Build event-driven patterns
  • Implement acknowledgements

Usage

Invoke this skill when you need to:

  • Build real-time applications
  • Implement chat rooms
  • Scale WebSocket servers
  • Handle complex event patterns

Server Setup

import { Server } from 'socket.io';
import { createAdapter } from '@socket.io/redis-adapter';
import { createClient } from 'redis';

const io = new Server(httpServer, {
  cors: { origin: '*' },
});

// Redis adapter for scaling
const pubClient = createClient({ url: process.env.REDIS_URL });
const subClient = pubClient.duplicate();
io.adapter(createAdapter(pubClient, subClient));

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

// Namespaces
const chatNamespace = io.of('/chat');

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

  socket.on('message', ({ roomId, content }) => {
    io.to(roomId).emit('message', {
      user: socket.user,
      content,
      timestamp: Date.now(),
    });
  });
});

Best Practices

  • Use namespaces for separation
  • Implement rooms for grouping
  • Scale with Redis adapter
  • Handle disconnection gracefully

Target Processes

  • real-time-application
  • chat-implementation
  • collaborative-features