ai-streaming-setup

ai-streaming-setup is a command for Claude Code from Matt-Dionis/claude-code-configs. It costs 9 tokens per session (657 once invoked), scanned A, original, MIT.

A setup guide for adding live, gradually delivered AI responses to a TypeScript application using the Vercel AI SDK.

In plain words
What is it for?
Use it to add streaming text, structured data, chat messages, or single-turn completions to an application, with TypeScript types and error handling.
Why use it?
It helps avoid incomplete handling when a response is interrupted or fails. It also covers loading feedback, cancellation, and the different ways AI output can arrive.

Command for Claude Code

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 commands/matt-dionis/claude-code-configs/ai-streaming-setup
Clone the repo
git clone --depth 1 https://github.com/Matt-Dionis/claude-code-configs

Made for: Claude Code.

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 ai-streaming-setup

README.md
[![agentmods](https://agentmods.dev/badge/commands/matt-dionis/claude-code-configs/ai-streaming-setup.svg)](https://agentmods.dev/commands/matt-dionis/claude-code-configs/ai-streaming-setup)
Your own site
<a href="https://agentmods.dev/commands/matt-dionis/claude-code-configs/ai-streaming-setup"><img src="https://agentmods.dev/badge/commands/matt-dionis/claude-code-configs/ai-streaming-setup.svg" alt="Measured on agentmods" height="20"></a>
Per session 9 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 657 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.00009 $0.00657
Opus 5 $0.00005 $0.00329
Sonnet 5 $0.00002 $0.00131
Haiku 4.5 $0.00001 $0.00066

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

Security

Grade A, and why

ai-streaming-setup 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 2d ago.

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.

configurations/tooling/vercel-ai-sdk/.claude/commands/ai-streaming-setup.md · 83 lines

How it starts

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

Set up AI Streaming Implementation

Create a robust streaming AI implementation with the Vercel AI SDK for: $ARGUMENTS

Current Project Analysis

Project structure: !find . -type f -name "*.ts" -o -name "*.tsx" | grep -E "(api|components|lib)" | head -10

Existing AI SDK setup: !grep -r "from 'ai'" . --include="*.ts" --include="*.tsx" | head -5

Package dependencies: !cat package.json | jq '.dependencies | to_entries[] | select(.key | contains("ai")) | "\(.key): \(.value)"' -r 2>/dev/null || echo "No AI dependencies found"

Streaming Type Analysis

Text Streaming: Real-time text generation with token-by-token updates Object Streaming: Structured data streaming with partial object updates
Chat Streaming: Conversational interfaces with message history Completion Streaming: Single-turn completions with progressive updates

Your Task

  1. Assess current streaming setup and identify gaps
  2. Implement the appropriate streaming pattern based on the specified type
  3. Create robust error handling for stream interruptions and failures
  4. Add proper loading states and user feedback
  5. Implement stream cancellation for better UX
  6. Set up proper TypeScript types for streaming responses
  7. Add performance optimizations (chunking, backpressure handling)
  8. Include comprehensive testing for edge cases

Implementation Requirements

Server-Side Streaming
  • Proper route handler setup with maxDuration
  • Model configuration with appropriate parameters
  • Stream response formatting with toUIMessageStreamResponse() or toTextStreamResponse()
  • Abort signal handling for stream cancellation
  • Error boundaries and fallback responses
Client-Side Streaming
  • React hooks for stream management (useChat, useCompletion, useObject)
  • Progressive UI updates with optimistic rendering
  • Loading states and stream status indicators
  • Error handling with retry mechanisms
  • Stream interruption and cancellation

Read the full file on GitHub · 83 lines

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. 2d ago First seen · 83 lines · 9 tokens per session scan A 4a838f814fc8

Subscribe to this mod's changes

ai-streaming-setup is a command published in the GitHub repository Matt-Dionis/claude-code-configs (625 stars, last pushed 1y ago), licensed MIT. It adds 9 tokens to every session and 657 once invoked, about $0.0000 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-09-03.