Skip to main content
skill CX Codex

websocket-streaming — Claude Code skill: what it does, install

websocket-streaming connects a DAG execution engine to a dashboard over a two-way WebSocket channel. Use it for live execution events and graph state changes.

MIT 152 installs ★ 274 updated 2026-10-30

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add curiositech/some_claude_skills --skill websocket-streaming -a claude-code
Open on GitHub

What websocket-streaming does

This skill lays out a typed event protocol between a DAG runner and its visualization dashboard. Server messages cover node state, active edges, cost changes, completion, human gates, and errors. The client can send approval decisions or control execution with pause, resume, and cancel events.

It includes ServerEvent and ClientEvent unions, a React useDAGStream hook, and a Node.js server example with one room per DAG. The hook updates a local store and reconnects with exponential backoff up to 30s. Without reconnect handling, the dashboard can keep showing stale execution state.

What it helps with

  • stream DAG node changes to a dashboard
  • send human gate decisions back to the runner
  • show live cost and progress updates
  • restore a WebSocket connection after it closes

Example prompts for the agent

  • Set up a typed WebSocket stream for DAG state changes and reconnect it with backoff up to 30s.
  • Add useDAGStream to the React dashboard and handle node, cost, and completion events.
  • Let the dashboard pause, resume, or cancel a running DAG through client events.

How to install websocket-streaming

1Skills CLI (Vercel)

npx skills add curiositech/some_claude_skills --skill websocket-streaming -a claude-code

2Manually: put the files in place

~/.claude/skills/websocket-streaming/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/websocket-streaming/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about websocket-streaming

How do I install websocket-streaming in Claude Code?

Run npx skills add curiositech/some_claude_skills --skill websocket-streaming -a claude-code, then check ~/.claude/skills/websocket-streaming/SKILL.md.

What does websocket-streaming do?

It defines two-way WebSocket messaging between a DAG execution engine and a visualization dashboard. The skill covers typed events, a React hook, server rooms, and reconnect handling.

How does the skill reconnect after a disconnect?

useDAGStream retries with exponential backoff, capped at 30s. A successful connection resets the retry counter.

Source text

SKILL.md · MIT
---
name: websocket-streaming
description: Implements real-time bidirectional communication between DAG execution engines and visualization dashboards via WebSocket. Covers connection management, typed event protocols, reconnection
  with backoff, and React hook integration. Activate on "WebSocket", "real-time updates", "live streaming", "execution events", "state streaming", "push notifications". NOT for HTTP REST APIs, server-sent
  events (SSE), or general networking.
allowed-tools: Read,Write,Edit,Bash
metadata:
  category: DevOps & Site Reliability
  tags:
  - websocket
  - streaming
  - real-time-updates
  - live-streaming
  pairs-with:
  - skill: reactflow-expert
    reason: WebSocket connections deliver live DAG state updates to ReactFlow visualization dashboards
  - skill: real-time-collaboration-engine
    reason: WebSocket transport powers the real-time communication layer for collaborative editing
  - skill: llm-streaming-response-handler
    reason: WebSocket is an alternative transport to SSE for bidirectional LLM streaming
---

# WebSocket Streaming

Real-time bidirectional communication between DAG execution engines and dashboards. Typed event protocols, connection management, and React hook integration.

---

## When to Use

✅ **Use for**:
- Streaming DAG node state changes to a visualization dashboard
- Sending human gate decisions from dashboard to execution engine
- Live cost ticker and progress updates during execution
- Bi-directional communication (not just server → client)

❌ **NOT for**:
- One-way server → client updates (consider SSE, simpler)
- REST API design (use `api-architect`)
- Polling-based status checks (WebSocket replaces polling)

---

## Event Protocol

### Server → Client Events

```typescript
type ServerEvent =
  | { type: 'node_state'; node_id: string; status: NodeStatus; output?: any; metrics?: NodeMetrics }
  | { type: 'edge_active'; from: string; to: string }
  | { type: 'dag_mutated'; mutation: DAGMutation }
  | { type: 'cost_update'; spent: number; budget: number; remaining: number }
  | { type: 'execution_complete'; results: Record<string, any> }
  | { type: 'human_gate_waiting'; node_id: string; presentation: GatePresentation }
  | { type: 'error'; node_id?: string; message: string };
```

### Client → Server Events

```typescript
type ClientEvent =
  | { type: 'human_decision'; node_id: string; decision: 'approve' | 'reject' | 'modify'; feedback?: string }
  | { type: 'pause_execution' }
  | { type: 'resume_execution' }
  | { type: 'cancel_execution' };
```

---

## React Hook: useDAGStream

```typescript
import { useEffect, useRef, useCallback } from 'react';

export function useDAGStream(dagId: string, store: DAGStore) {
  const wsRef = useRef<WebSocket | null>(null);
  const reconnectAttempt = useRef(0);

  const connect = useCallback(() => {
    const ws = new WebSocket(`/api/dags/${dagId}/stream`);

    ws.onopen = () => { reconnectAttempt.current = 0; };

    ws.onmessage = (event) => {
      const msg = JSON.parse(event.data) as ServerEvent;
      switch (msg.type) {
        case 'node_state':
          store.updateNodeData(msg.node_id, {
            status: msg.status, output: msg.output, metrics: msg.metrics,
          });
          break;
        case 'cost_update':
          store.setCostState({ spent: msg.spent, budget: msg.budget });
          break;
        case 'dag_mutated':
          store.applyMutation(msg.mutation);
          break;
        case 'execution_complete':
          store.setExecutionComplete(msg.results);
          break;
      }
    };

    ws.onclose = () => {
      // Reconnect with exponential backoff (max 30s)
      const delay = Math.min(1000 * 2 ** reconnectAttempt.current, 30000);
      reconnectAttempt.current++;
      setTimeout(connect, delay);
    };

    wsRef.current = ws;
  }, [dagId, store]);

  useEffect(() => { connect(); return () => wsRef.current?.close(); }, [connect]);

  // Send client events
  const send = useCallback((event: ClientEvent) => {
    wsRef.current?.send(JSON.stringify(event));
  }, []);

  return { send };
}
```

---

## Server Implementation (Node.js)

```typescript
import { WebSocketServer } from 'ws';

const wss = new WebSocketServer({ noServer: true });

// Per-DAG rooms
const rooms = new Map<string, Set<WebSocket>>();

function broadcast(dagId: string, event: ServerEvent) {
  const clients = rooms.get(dagId);
  if (!clients) return;
  const msg = JSON.stringify(event);
  for (const ws of clients) {
    if (ws.readyState === ws.OPEN) ws.send(msg);
  }
}

// Usage in execution engine:
function onNodeComplete(dagId: string, nodeId: string, result: any) {
  broadcast(dagId, {
    type: 'node_state',
    node_id: nodeId,
    status: 'completed',
    output: result.output,
    metrics: result.metrics,
  });
}
```

---

## Anti-Patterns

### No Reconnection Logic
**Wrong**: WebSocket closes and the dashboard shows stale data forever.
**Right**: Exponential backoff reconnection (1s, 2s, 4s, 8s... max 30s). Resync state on reconnect.

### Sending Full State on Every Event
**Wrong**: Broadcasting the entire DAG state on every node update.
**Right**: Send only the delta: which node changed, to what status. The client applies the update to its local store.

### No Typed Protocol
**Wrong**: Sending untyped JSON objects and parsing with `any`.
**Right**: Define `ServerEvent` and `ClientEvent` union types. Exhaustive switch on `msg.type`.

© curiositech · MIT · curiositech/some_claude_skills

Similar skills

All skills for Backend and APIs →

From the same set180

The whole set →
research-craft research-craft is a Claude Code skill for framing academic problems, validating evidence, and drafting thesis chapters or scholarly papers. CX Codex +1 153installs database-design-patterns database-design-patterns guides relational schema design, 3NF normalization, index selection, and zero-downtime migrations using the expand-contract pattern. CX Codex +1 152installs mermaid-graph-renderer mermaid-graph-renderer — a skill for turning Mermaid diagrams into SVG, PNG, and PDF. Covers lazy loading on the web, CLI batch export, and picking a renderer. CX Codex +1 152installs logging-observability logging-observability sets up structured logging, OpenTelemetry tracing, and alerting thresholds for production backends. Connects distributed services with correlation IDs. CX Codex +1 152installs performance-profiling performance-profiling guides performance analysis across Node.js and React, covering flame graphs, heap snapshot diffing, and event loop saturation. CX Codex +1 148installs typescript-advanced-patterns The typescript-advanced-patterns skill applies advanced TypeScript type patterns to domain models, type-safe APIs, generic utilities, and compile-time checks. CX Codex +1 148installs ml-system-design-interview Coaches staff+ engineers through end-to-end ML system design interviews. Structures recommendation or RAG architectures into a 45-minute whiteboard run. CX Codex +1 147installs monorepo-management The monorepo-management skill for Claude Code helps structure JavaScript and TypeScript workspaces, configure Turborepo or Nx tasks, and manage package dependencies when creating or moving a project into a monorepo. CX Codex +1 147installs

Project sponsors

Companies that keep this analytics open