Real time features

From aj-geddes/useful-ai-prompts · View interactive version

Real time features is an AI agent skill from the GitHub repository aj-geddes/useful-ai-prompts. Implement real-time functionality using WebSockets, Server-Sent Events (SSE), or long polling. Use when building chat applications, live dashboards, collaborative editing, notifications, or any feature requiring instant updates.

How to use this skill

Skill file

Real-Time Features

Table of Contents

Overview

Implement real-time bidirectional communication between clients and servers for instant data synchronization and live updates.

When to Use

Quick Start

Minimal working example:

// server.ts
import WebSocket, { WebSocketServer } from "ws";
import { createServer } from "http";

interface Message {
  type: "join" | "message" | "leave" | "typing";
  userId: string;
  username: string;
  content?: string;
  timestamp: number;
}

interface Client {
  ws: WebSocket;
  userId: string;
  username: string;
  roomId: string;
}

class ChatServer {
  private wss: WebSocketServer;
  private clients: Map<string, Client> = new Map();
  private rooms: Map<string, Set<string>> = new Map();

  constructor(port: number) {
// ... (see reference guides for full implementation)

Reference Guides

Detailed implementations in the references/ directory:

| Guide | Contents |

|---|---|

| WebSocket Server (Node.js) | WebSocket Server (Node.js) |

| WebSocket Client (React) | WebSocket Client (React) |

| Server-Sent Events (SSE) | Server-Sent Events (SSE) |

| Socket.IO (Production-Ready) | Socket.IO (Production-Ready) |

Best Practices

✅ DO

❌ DON'T

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.