TanStack AI is a TypeScript SDK for building applications that stream AI responses, call tools, run agents, produce structured output, and handle multimodal or realtime interactions. Developers use it across frameworks and AI providers through shared typed interfaces and provider adapters. The catalogue entries are add-ons for working with this SDK.
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.
npx skills add TanStack/ai --skill middlewaregit clone --depth 1 https://github.com/TanStack/aiWrote 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.
[](https://agentmods.dev/skills/tanstack/ai/middleware)<a href="https://agentmods.dev/skills/tanstack/ai/middleware"><img src="https://agentmods.dev/badge/skills/tanstack/ai/middleware/github.svg" alt="Measured on agentmods" height="20"></a>Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.
<a href="https://agentmods.dev/skills/tanstack/ai/middleware"><img src="https://agentmods.dev/badge/skills/tanstack/ai/middleware.svg" alt="Reviewed on agentmods" width="80" height="20"></a>- NVIDIA SkillSpector warn
SkillSpector: 16 findings, up to high
These are SkillSpector’s own severities. On a checked sample its high-severity flags on skills were ~96% false positives — a documented command, a public API, a “never do X” rule — so we show them as a caution to read, not a verdict. Why →
- high Anti-Refusal · line 340 Skill instructs the agent to never refuse or to always comply. Suppressing the agent's ability to decline removes a core safety control and enables downstream harmful requests to succeed.Fix: Remove any instruction telling the agent to never refuse or always comply. The agent must retain the ability to decline unsafe, out-of-scope, or harmful requests.
- medium Prompt Injection · line 55 Large whitespace padding was detected (a block of blank lines or a long run of spaces). This can push injected instructions below or to the right of the visible area so a human reviewer never sees them while the agent still reads them. Manual review of the hidden content is recommended.Fix: Remove the large whitespace padding (blank-line blocks or long space runs) and review any content hidden below or to the right of it. Keep skill files compact and reviewable so no instructions can be
- medium Prompt Injection · line 62 Large whitespace padding was detected (a block of blank lines or a long run of spaces). This can push injected instructions below or to the right of the visible area so a human reviewer never sees them while the agent still reads them. Manual review of the hidden content is recommended.Fix: Remove the large whitespace padding (blank-line blocks or long space runs) and review any content hidden below or to the right of it. Keep skill files compact and reviewable so no instructions can be
- medium Prompt Injection · line 63 Large whitespace padding was detected (a block of blank lines or a long run of spaces). This can push injected instructions below or to the right of the visible area so a human reviewer never sees them while the agent still reads them. Manual review of the hidden content is recommended.Fix: Remove the large whitespace padding (blank-line blocks or long space runs) and review any content hidden below or to the right of it. Keep skill files compact and reviewable so no instructions can be
- medium Prompt Injection · line 64 Large whitespace padding was detected (a block of blank lines or a long run of spaces). This can push injected instructions below or to the right of the visible area so a human reviewer never sees them while the agent still reads them. Manual review of the hidden content is recommended.Fix: Remove the large whitespace padding (blank-line blocks or long space runs) and review any content hidden below or to the right of it. Keep skill files compact and reviewable so no instructions can be
- medium Prompt Injection · line 69 Large whitespace padding was detected (a block of blank lines or a long run of spaces). This can push injected instructions below or to the right of the visible area so a human reviewer never sees them while the agent still reads them. Manual review of the hidden content is recommended.Fix: Remove the large whitespace padding (blank-line blocks or long space runs) and review any content hidden below or to the right of it. Keep skill files compact and reviewable so no instructions can be
- medium Prompt Injection · line 67 Large whitespace padding was detected (a block of blank lines or a long run of spaces). This can push injected instructions below or to the right of the visible area so a human reviewer never sees them while the agent still reads them. Manual review of the hidden content is recommended.Fix: Remove the large whitespace padding (blank-line blocks or long space runs) and review any content hidden below or to the right of it. Keep skill files compact and reviewable so no instructions can be
- medium Prompt Injection · line 68 Large whitespace padding was detected (a block of blank lines or a long run of spaces). This can push injected instructions below or to the right of the visible area so a human reviewer never sees them while the agent still reads them. Manual review of the hidden content is recommended.Fix: Remove the large whitespace padding (blank-line blocks or long space runs) and review any content hidden below or to the right of it. Keep skill files compact and reviewable so no instructions can be
- medium Prompt Injection · line 85 Large whitespace padding was detected (a block of blank lines or a long run of spaces). This can push injected instructions below or to the right of the visible area so a human reviewer never sees them while the agent still reads them. Manual review of the hidden content is recommended.Fix: Remove the large whitespace padding (blank-line blocks or long space runs) and review any content hidden below or to the right of it. Keep skill files compact and reviewable so no instructions can be
- medium Prompt Injection · line 87 Large whitespace padding was detected (a block of blank lines or a long run of spaces). This can push injected instructions below or to the right of the visible area so a human reviewer never sees them while the agent still reads them. Manual review of the hidden content is recommended.Fix: Remove the large whitespace padding (blank-line blocks or long space runs) and review any content hidden below or to the right of it. Keep skill files compact and reviewable so no instructions can be
- medium Prompt Injection · line 88 Large whitespace padding was detected (a block of blank lines or a long run of spaces). This can push injected instructions below or to the right of the visible area so a human reviewer never sees them while the agent still reads them. Manual review of the hidden content is recommended.Fix: Remove the large whitespace padding (blank-line blocks or long space runs) and review any content hidden below or to the right of it. Keep skill files compact and reviewable so no instructions can be
- medium Prompt Injection · line 89 Large whitespace padding was detected (a block of blank lines or a long run of spaces). This can push injected instructions below or to the right of the visible area so a human reviewer never sees them while the agent still reads them. Manual review of the hidden content is recommended.Fix: Remove the large whitespace padding (blank-line blocks or long space runs) and review any content hidden below or to the right of it. Keep skill files compact and reviewable so no instructions can be
- medium Prompt Injection · line 90 Large whitespace padding was detected (a block of blank lines or a long run of spaces). This can push injected instructions below or to the right of the visible area so a human reviewer never sees them while the agent still reads them. Manual review of the hidden content is recommended.Fix: Remove the large whitespace padding (blank-line blocks or long space runs) and review any content hidden below or to the right of it. Keep skill files compact and reviewable so no instructions can be
- medium Prompt Injection · line 91 Large whitespace padding was detected (a block of blank lines or a long run of spaces). This can push injected instructions below or to the right of the visible area so a human reviewer never sees them while the agent still reads them. Manual review of the hidden content is recommended.Fix: Remove the large whitespace padding (blank-line blocks or long space runs) and review any content hidden below or to the right of it. Keep skill files compact and reviewable so no instructions can be
- medium Agent Snooping · line 566 Skill enumerates or reads other installed skills. Access to other skills' SKILL.md files or the skills directory reveals prompt instructions, capabilities, and secrets that should be invisible to peer skills.Fix: Remove all code or instructions that list or read other skills' files or directories. Skills should operate independently; cross-skill access is a privilege escalation.
- medium Agent Snooping · line 793 Skill enumerates or reads other installed skills. Access to other skills' SKILL.md files or the skills directory reveals prompt instructions, capabilities, and secrets that should be invisible to peer skills.Fix: Remove all code or instructions that list or read other skills' files or directories. Skills should operate independently; cross-skill access is a privilege escalation.
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.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00086 | $0.08891 |
| Opus 5.5 | $0.00034 | $0.03556 |
| Sonnet 5.5 | $0.00017 | $0.01778 |
| Haiku 4.5 | $0.00009 | $0.00889 |
Grade A, and why
ai-core/middleware 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 3d 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.
How it starts
The opening of the file, as written. The whole thing — 907 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Middleware
Dependency note: This skill builds on ai-core. Read it first for critical rules.
Setup — Analytics Tracking Middleware
import { chat, toServerSentEventsResponse } from '@tanstack/ai'
import { openaiText } from '@tanstack/ai-openai'
import { trackAnalytics, reportError } from './analytics'
export async function POST(request: Request) {
const { messages, threadId } = await request.json()
const stream = chat({
adapter: openaiText('gpt-5.5'),
messages,
threadId,
middleware: [
{
onStart: (ctx) => {
console.log('Chat started:', ctx.model)
},
onFinish: (ctx, info) => {
trackAnalytics({ model: ctx.model, tokens: info.usage?.totalTokens })
},
onError: (ctx, info) => {
reportError(info.error)
},
},
],
})
return toServerSentEventsResponse(stream)
}
Hooks Reference
Every hook receives a ChatMiddlewareContext as its first argument, which provides
requestId, streamId, phase, iteration, chunkIndex, callMetadata, model, provider,
signal, abort(), defer(), and more. parentRunId names the run this one continues. subagentRunId is set only inside a subagent and names its card.
| Hook | When | Second Argument |
|---|---|---|
onConfig |
Once at startup (init) + once per iteration (beforeModel) + once at a separate-finalization boundary |
ChatMiddlewareConfig (return partial to merge) |
onStructuredOutputConfig |
Once at the separate-finalization boundary | StructuredOutputMiddlewareConfig (return partial) |
onStart |
Once after initial onConfig |
none |
onIteration |
Start of each agent loop iteration | IterationInfo |
onShouldContinue |
Whether to start another agent-loop iteration (AND with strategy; false stops) |
AgentLoopState |
onChunk |
Every streamed chunk | StreamChunk (return void/chunk/chunk[]/null) |
onBeforeToolCall |
Before each tool executes | ToolCallHookContext (return decision or void) |
onAfterToolCall |
After each tool executes | AfterToolCallInfo |
onToolPhaseComplete |
After all tool calls in an iteration | ToolPhaseCompleteInfo |
onUsage |
When RUN_FINISHED includes usage data |
UsageInfo |
onFinish |
Run completed normally | FinishInfo |
onAbort |
Run was aborted, including a consumer break or return() |
AbortInfo |
onError |
Unhandled error occurred | ErrorInfo |
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.
- 3d ago Changed b5a76c2cbd08
- 24d ago Changed · +5 lines 2579c6f26dd5
- 1mo ago Changed · +3 lines 621882e064f5
- 2mo ago Changed · +105 lines aa2dffb4c00b
- 2mo ago First seen · 794 lines · 86 tokens per session scan A 13d23d966f6a
ai-core/middleware is a skill published in the GitHub repository TanStack/ai (3,359 stars, last pushed yesterday), licensed MIT. It adds 86 tokens to every session and 8,891 once invoked, about $0.0003 per session on Opus 5.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.
ai-core/middleware compared with skills from other repositories
| Mod | Type | Stars | Last push | Licence | Scan | Tokens | Works with |
|---|---|---|---|---|---|---|---|
| ai-core/middlewareTanStack/ai | Skill | 3.4k | yesterday | MIT | A | 86 | Claude Code |
| claude-apiasgeirtj/system_prompts_leaks | Skill | 71k | yesterday | CC0-1.0 | A | 317 | Claude Code, Codex |
| non-storybookasgeirtj/system_prompts_leaks | Skill | 71k | yesterday | CC0-1.0 | A | 0 | Claude Code, Codex |
| setup-writing-styleasgeirtj/system_prompts_leaks | Skill | 71k | yesterday | CC0-1.0 | A | 97 | Claude Code, Codex |
| shoppingasgeirtj/system_prompts_leaks | Skill | 71k | yesterday | CC0-1.0 | A | 0 | Claude Code, Codex |
| instagramasgeirtj/system_prompts_leaks | Skill | 71k | yesterday | CC0-1.0 | A | 57 | Claude Code, Codex |
| pptxasgeirtj/system_prompts_leaks | Skill | 71k | yesterday | CC0-1.0 | A | 217 | Claude Code, Codex |