本文へ移動
cccskills
無料GitHub で公開

sse-websocket-streaming-expert

Expert guide for Server-Sent Events (SSE), WebSockets, and Streaming Architectures. Covers real-time data push, Socket.IO, Hono WebSocket, and AI response streaming / Panduan ahli streaming real-time.

インストール方法を見る

含まれるファイル(1)

  • SKILL.md5.2 KB

SKILL.md(原文)

インストールする前に、エージェントに与えられる指示の中身を確認できます。

SSE, WebSocket & Streaming Expert

English | Bahasa Indonesia


<a name="english"></a>

English

Description

A focused guide for building real-time data push architectures. While realtime-collaboration-expert focuses on CRDTs (Yjs) for multi-player editing, this skill focuses on the transport layer: when to use Server-Sent Events (SSE) vs WebSockets vs HTTP Streaming, scaling pub/sub architectures, and streaming AI responses.

Trigger Conditions

  • When building live notification systems, live sports scores, or stock tickers.
  • When streaming LLM text generation responses chunk-by-chunk to the UI.
  • When the user asks about "WebSockets", "Socket.IO", or "SSE".
  • When implementing a chat application.

Core Architectural Guidelines

1. SSE vs WebSockets

Choose the right transport mechanism to save server resources.

  • Server-Sent Events (SSE): Unidirectional (Server to Client). Uses standard HTTP. Best for live feeds, AI streaming, notifications. Handles reconnections automatically.
  • WebSockets: Bidirectional. Best for chat apps, multiplayer games. Requires a persistent TCP connection and custom ping/pong keepalives.

2. Streaming AI Responses (HTTP Streaming)

For LLMs, use standard HTTP Streaming (often via the ai SDK in React/Next.js) instead of complex WebSockets.

// Next.js Route Handler Example
export async function POST(req: Request) {
  const { prompt } = await req.json();
  const stream = await myLLM.stream(prompt);
  
  return new Response(stream, {
    headers: { 'Content-Type': 'text/event-stream' },
  });
}

3. Scaling WebSockets (Pub/Sub)

A single Node.js process can handle thousands of WebSockets, but when you scale horizontally (multiple servers), clients on Server A cannot see messages from Server B.

  • Redis Adapter: Use a Pub/Sub mechanism (like Redis) so when a message is published, all server instances broadcast it to their respective connected clients.
  • Serverless WebSockets: In serverless environments (AWS API Gateway, Cloudflare Durable Objects), you do not hold the connection in your code. The infrastructure holds it, and calls your webhook when messages arrive.

4. Reconnection & Idempotency

  • Always assume connections will drop.
  • Clients must maintain a lastEventId or cursor. Upon reconnection, the client sends this cursor so the server can push any missed messages, preventing data loss.

Orchestration & Integration

  • Supplements js-backend-expert or go-programming-expert with real-time push capabilities.
  • Essential for gemini-agent-booster when building AI streaming chat interfaces.
  • Integrates with api-gateway-proxy-expert to ensure proxies do not buffer streaming responses.

<a name="bahasa-indonesia"></a>

Bahasa Indonesia

Deskripsi

Panduan terfokus untuk membangun arsitektur push data real-time. Skill ini berfokus pada lapisan transport: kapan harus menggunakan Server-Sent Events (SSE) vs WebSockets vs HTTP Streaming, penskalaan arsitektur pub/sub (Redis), dan streaming respons AI.

Kondisi Pemicu

  • Saat membangun sistem notifikasi live, pembaruan skor, atau ticker saham.
  • Saat melakukan streaming teks hasil generasi LLM bagian-demi-bagian (chunk-by-chunk) ke UI.
  • Saat mengimplementasikan aplikasi obrolan (chat).

Panduan Arsitektur Inti

1. SSE vs WebSockets

Pilih mekanisme transport yang tepat:

  • Server-Sent Events (SSE): Satu arah (Server ke Klien). Berjalan di atas HTTP biasa. Sangat ideal untuk feed berita, notifikasi, dan streaming AI. Mendukung rekoneksi otomatis secara native.
  • WebSockets: Dua arah. Ideal untuk aplikasi chat dan game. Membutuhkan penanganan koneksi persisten dan mekanisme ping/pong manual.

2. Streaming Respons AI

Gunakan HTTP Streaming biasa (biasanya menggunakan text/event-stream) untuk merender kata demi kata dari AI tanpa perlu memelihara koneksi WebSocket yang kompleks.

3. Penskalaan (Scaling) WebSockets

Saat aplikasi diskalakan ke beberapa server (horizontal scaling), pengguna yang terhubung ke Server A tidak akan menerima pesan dari pengguna di Server B. Anda WAJIB menggunakan Redis Pub/Sub (atau mekanisme message broker serupa) sebagai backplane agar semua server saling berkomunikasi.

4. Rekoneksi & Penanganan Kehilangan Data

  • Klien harus selalu mengirimkan kursor (misal: ID pesan terakhir yang diterima) saat melakukan rekoneksi.
  • Server menggunakan kursor tersebut untuk memutar ulang (replay) pesan yang terlewat selama klien terputus.

Integrasi Orkestrasi

  • Melengkapi js-backend-expert atau go-programming-expert dengan kemampuan push real-time.
  • Sangat penting bagi gemini-agent-booster saat membangun antarmuka chat AI.
  • Terintegrasi dengan api-gateway-proxy-expert (pastikan NGINX/proxy tidak melakukan buffering pada koneksi streaming).

レビュー

まだレビューはありません。使ってみた感想をお寄せください。

同じリポジトリのスキル

概要と使いどころ

Expert guide for automated and manual Web Accessibility (a11y) testing — axe-core, Pa11y, Playwright a11y, screen reader testing, and WCAG 2.2 Level AA/AAA compliance / Panduan ahli pengujian aksesibilitas web.

日本語の概要は準備中です。原文の説明を表示しています。

roedyrustam/vibes-plug752026年10月9日 更新

Expert guide for intelligent model cascading and routing — complexity-scored task routing from Flash/Haiku to Sonnet/Opus/Astra, dynamic escalation with quality gates, 40-60% token cost reduction while maintaining output quality / Panduan ahli untuk kaskade dan routing model cerdas — routing tugas berbasis skor kompleksitas dari Flash/Haiku ke Sonnet/Opus/Astra, eskalasi dinamis dengan gerbang kualitas, pengurangan biaya token 40-60% dengan kualitas output terjaga.

日本語の概要は準備中です。原文の説明を表示しています。

roedyrustam/vibes-plug752026年10月9日 更新

Expert guide for Affective Computing, emotional AI, and real-time sentiment analysis through native multimodal tokens (voice intonation and facial micro-expressions) / Panduan ahli komputasi afektif, AI emosional, dan analisis sentimen real-time melalui token multimodal native.

日本語の概要は準備中です。原文の説明を表示しています。

roedyrustam/vibes-plug752026年10月9日 更新

Expert guide for AI-assisted coding workflows — agentic code generation, multi-agent code swarms, self-healing CI/CD, automated PR review, spec-to-code pipelines, codebase knowledge graphs, and human-in-the-loop approval gates / Panduan ahli untuk workflow pengkodean berbasis AI — generasi kode agentic, code swarm multi-agen, CI/CD self-healing, review PR otomatis, pipeline spec-to-code, knowledge graph codebase, dan gate persetujuan human-in-the-loop.

日本語の概要は準備中です。原文の説明を表示しています。

roedyrustam/vibes-plug752026年10月9日 更新

Expert guide for long-term episodic memory integration (Mem0 v2, Letta/MemGPT, Zep v2), memory tier architecture, pgvector HNSW storage, and unified context management for autonomous AI agents / Panduan ahli untuk integrasi memori episodik jangka panjang (Mem0 v2, Letta/MemGPT, Zep v2), arsitektur tier memori, penyimpanan pgvector HNSW, dan manajemen konteks terpadu untuk agen AI otonom.

日本語の概要は準備中です。原文の説明を表示しています。

roedyrustam/vibes-plug752026年10月9日 更新

Expert guide for designing Machine-to-Machine (M2M) micro-economies, autonomous agent wallets, and swarm budget allocation / Panduan ahli merancang ekonomi mikro antar-agen (M2M), dompet agen otonom, dan alokasi anggaran swarm.

日本語の概要は準備中です。原文の説明を表示しています。

roedyrustam/vibes-plug752026年10月9日 更新

roedyrustam のスキルをすべて見る

このスキルの問題を報告する