streaming-api-patterns

streaming-api-patterns is a skill for Claude Code, Codex from ArieGoldkin/ai-agent-hub. It costs 51 tokens per session (1,593 once invoked), scanned A, original, MIT.

A guide to sending data to an application as it becomes available, using Server-Sent Events, WebSockets, or browser stream APIs. Server-Sent Events send updates one way, while WebSockets allow two-way communication.

In plain words
What is it for?
Building streaming chat responses, notifications, live data feeds, progress updates, chat apps, and collaborative editing features.
Why use it?
It helps handle live updates, dropped connections, and slow receivers without building these behaviors from scratch.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/ariegoldkin/ai-agent-hub/streaming-api-patterns
Any agent
npx skills add ArieGoldkin/ai-agent-hub --skill streaming-api-patterns
Clone the repo
git clone --depth 1 https://github.com/ArieGoldkin/ai-agent-hub

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for streaming-api-patterns

README.md
[![agentmods](https://agentmods.dev/badge/skills/ariegoldkin/ai-agent-hub/streaming-api-patterns.svg)](https://agentmods.dev/skills/ariegoldkin/ai-agent-hub/streaming-api-patterns)
Your own site
<a href="https://agentmods.dev/skills/ariegoldkin/ai-agent-hub/streaming-api-patterns"><img src="https://agentmods.dev/badge/skills/ariegoldkin/ai-agent-hub/streaming-api-patterns.svg" alt="Measured on agentmods" height="20"></a>
Per session 51 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,593 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00051 $0.01593
Opus 5 $0.00026 $0.00796
Sonnet 5 $0.00010 $0.00319
Haiku 4.5 $0.00005 $0.00159

Measured 5d ago against content hash 25f3d4f572c0, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-05, from the pricing page.

Security

Grade A, and why

streaming-api-patterns scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 5d ago.

The scan reads SKILL.md. This mod also ships 1 executable file (templates/sse-endpoint-template.ts), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

Origin

Copies of this mod

1 near-identical copy found in the catalogue:

skills/streaming-api-patterns/SKILL.md · 259 lines

How it starts

The opening of the file, as written. The whole thing — 259 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Streaming API Patterns

Overview

Modern applications require real-time data delivery. This skill covers Server-Sent Events (SSE) for server-to-client streaming, WebSockets for bidirectional communication, and the Streams API for handling backpressure and efficient data flow.

When to use this skill:

  • Streaming LLM responses (ChatGPT-style interfaces)
  • Real-time notifications and updates
  • Live data feeds (stock prices, analytics)
  • Chat applications
  • Progress updates for long-running tasks
  • Collaborative editing features

Core Technologies

1. Server-Sent Events (SSE)

Best for: Server-to-client streaming (LLM responses, notifications)

// Next.js Route Handler
export async function GET(req: Request) {
  const encoder = new TextEncoder()

  const stream = new ReadableStream({
    async start(controller) {
      // Send data
      controller.enqueue(encoder.encode('data: Hello\n\n'))

      // Keep connection alive
      const interval = setInterval(() => {
        controller.enqueue(encoder.encode(': keepalive\n\n'))
      }, 30000)

      // Cleanup
      req.signal.addEventListener('abort', () => {
        clearInterval(interval)
        controller.close()
      })
    }
  })

  return new Response(stream, {
    headers: {
      'Content-Type': 'text/event-stream',
      'Cache-Control': 'no-cache',
      'Connection': 'keep-alive',
    }
  })
}

// Client
const eventSource = new EventSource('/api/stream')
eventSource.onmessage = (event) => {
  console.log(event.data)
}

2. WebSockets

Best for: Bidirectional real-time communication (chat, collaboration)

// WebSocket Server (Next.js with ws)
import { WebSocketServer } from 'ws'

const wss = new WebSocketServer({ port: 8080 })

wss.on('connection', (ws) => {
  ws.on('message', (data) => {
    // Broadcast to all clients
    wss.clients.forEach((client) => {
      if (client.readyState === WebSocket.OPEN) {
        client.send(data)
      }
    })
  })
})

// Client
const ws = new WebSocket('ws://localhost:8080')
ws.onmessage = (event) => console.log(event.data)
ws.send(JSON.stringify({ type: 'message', text: 'Hello' }))

Read the full file on GitHub · 259 lines

Files

What ships with it

2 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 5d ago First seen · 259 lines · 51 tokens per session scan A 25f3d4f572c0

Subscribe to this mod's changes

streaming-api-patterns is a skill published in the GitHub repository ArieGoldkin/ai-agent-hub (11 stars, last pushed 9mo ago), licensed MIT. It adds 51 tokens to every session and 1,593 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

realtime-systems

WebSocket, real-time communication, and event-driven architectures.

miles990/claude-software-skills · 16 tokens

nestjs-real-time

Implement WebSocket gateways with Socketio and Server-Sent Events endpoints in NestJS. Use when building chat features, live feeds, or choosing between WebSocket and SSE for real-time communication.

FilippoDeSilva/skills · 42 tokens

senior-data-engineer

World-class data engineering skill for building scalable data pipelines, ETL/ELT systems, real-time streaming, and data infrastructure. Expertise in Python, SQL, Spark, Airflow, dbt, Kafka, Flink, Kinesis, and modern data stack. Includes data modeling, pipeline orchestration, data quality, streaming quality…

benchflow-ai/skillsbench · 100 tokens

testing-websocket-api-security

Tests WebSocket API implementations for security vulnerabilities including missing authentication on WebSocket upgrade, Cross-Site WebSocket Hijacking (CSWSH), injection attacks through WebSocket messages, insufficient input validation, denial-of-service via message flooding, and information leakage through WebSocket…

xalgorix/xalgorix · 117 tokens

grpc-expert

Expert-level gRPC, Protocol Buffers, microservices communication, and streaming. Use when the user mentions Protocol Buffers, microservices, RPC, or streaming, or when the task involves gRPC Fundamentals, Communication Patterns, or Production Features.

personamanagmentlayer/pcl · 53 tokens

tauri

Advanced Tauri event patterns for bidirectional communication, streaming data, window-to-window messaging, and custom event handling.

bobmatnyc/claude-mpm-skills · 25 tokens