ai-persistence/build-cloudflare-adapter

ai-persistence/build-cloudflare-adapter is a skill for Claude Code from TanStack/ai. It costs 68 tokens per session (3,706 once invoked), scanned A, original, MIT.

A setup helper for saving TanStack AI chat data in a Cloudflare Worker using D1, Cloudflare’s database service. It can also add a Durable Object lock store for coordinating access.

In plain words
What is it for?
Use it to add chat storage, database migrations, request binding access, and lease-based locks to a Cloudflare Worker.
Why use it?
It removes the application-specific wiring between chat persistence, request database bindings, configuration, and migrations. A migration is a tracked database change applied over time.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin. Also seen: mentions subagents.

Needs its repository: it reads a path above its own folder, which exists only inside the repository. The line is import { chatPersistence } from '../src/lib/chat-persistence'.

Part of the tanstack-ai plugin — 47 skills shipped together

Good fit Use it to add chat storage, database migrations, request binding access, and lease-based locks to a Cloudflare Worker.

Compare 6 skills from other repositories ↓
About the project

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.

TanStack/ai · 3,336 stars · on GitHub · tanstack.com

Install

Getting it into your agent

It runs from inside its repository, so the clone comes first — what it calls does not travel with the file alone.

Clone the repo
git clone --depth 1 https://github.com/TanStack/ai
agentmods
npx agentmods add skills/tanstack/ai/build-cloudflare-adapter

Made for: Claude Code.

Or install tanstack-ai, the plugin that ships this one along with the rest of its 47 skills.

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-persistence/build-cloudflare-adapter

README.md
[![agentmods](https://agentmods.dev/badge/skills/tanstack/ai/build-cloudflare-adapter/github.svg)](https://agentmods.dev/skills/tanstack/ai/build-cloudflare-adapter)
Your own site
<a href="https://agentmods.dev/skills/tanstack/ai/build-cloudflare-adapter"><img src="https://agentmods.dev/badge/skills/tanstack/ai/build-cloudflare-adapter/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.

agentmods 80×15 button for ai-persistence/build-cloudflare-adapter

Your own site · 80×15
<a href="https://agentmods.dev/skills/tanstack/ai/build-cloudflare-adapter"><img src="https://agentmods.dev/badge/skills/tanstack/ai/build-cloudflare-adapter.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 68 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 3,706 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 1 finding. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector warn 7 Sept 2026
SkillSpector: 10 findings, up to medium

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 →

  • medium Prompt Injection · line 24
    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 93
    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 95
    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 96
    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 97
    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 98
    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 99
    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 101
    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 102
    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 103
    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
How audits are shown
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.00068 $0.03706
Opus 5.5 $0.00027 $0.01482
Sonnet 5.5 $0.00014 $0.00741
Haiku 4.5 $0.00007 $0.00371

Measured 10d ago against content hash f073ed26fa2e, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

ai-persistence/build-cloudflare-adapter scanned grade A with 1 finding 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 10d 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.

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

| How `env` reaches code | the Worker `fetch(request, env)`, or an async-local helper (`getDb()`, `getCloudflareContext()`) | Whether the factory takes `env` or reads a helper |
packages/ai-persistence/skills/ai-persistence/build-cloudflare-adapter/SKILL.md · 339 lines

How it starts

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

Cloudflare Chat Persistence

The deliverable is one file in the Worker — src/lib/chat-persistence.ts — exporting a factory that builds a ChatPersistence from the request's D1 binding, plus (when the app needs coordination) a Durable Object lock store. Tables go into the app's existing migrations/ directory and are applied with wrangler d1 migrations apply.

Do not create a package or a migration runner. Wrangler already tracks applied migrations; a second bookkeeping table only creates drift.

Read the Store Reference (docs/persistence/store-reference.md) for the store contracts, and ai-persistence/stores for the shape rules. This skill covers only the Cloudflare-specific parts.

1. Read the app before writing anything

Find Where to look What it decides
D1 binding name wrangler.jsonc d1_databases[].binding env.DB vs env.AI_STATE in the factory
How env reaches code the Worker fetch(request, env), or an async-local helper (getDb(), getCloudflareContext()) Whether the factory takes env or reads a helper
Drizzle or raw D1 drizzle-orm in package.json, a src/db/schema.ts Which recipe below to follow
Migrations dir wrangler.jsonc migrations_dir, default migrations/ Where the new .sql file goes
Existing table names the current migrations / schema Prefix (chat_*) so nothing collides

Read the full file on GitHub · 339 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. 10d ago Changed f073ed26fa2e
  2. 1mo ago Changed · +25 lines 3941b1de3bd5
  3. 2mo ago First seen · 314 lines · 68 tokens per session scan A 6d9d7d142478

Subscribe to this mod's changes

ai-persistence/build-cloudflare-adapter is a skill published in the GitHub repository TanStack/ai (3,336 stars, last pushed yesterday), licensed MIT. It adds 68 tokens to every session and 3,706 once invoked, about $0.0003 per session on Opus 5.5. A static security scan graded it A with 1 finding (makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

ai-persistence/build-cloudflare-adapter compared with skills from other repositories

ai-persistence/build-cloudflare-adapter next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
ai-persistence/build-cloudflare-adapterTanStack/aiSkill3.3kyesterdayMITA68Claude Code
muse_dbasgeirtj/system_prompts_leaksSkill71k2d agoCC0-1.0A27Claude Code, Codex
tailscaleasgeirtj/system_prompts_leaksSkill71k2d agoCC0-1.0A62Claude Code, Codex
ha-data-storesshiwenwen/hope-agentSkill1.9kyesterdayMITA115Claude Code, Codex
forge-infratonone-ai/tononeSkill7723d agoMITA53Claude Code
flux-recontonone-ai/tononeSkill7723d agoMITA48Claude Code
forge-audittonone-ai/tononeSkill7723d agoMITA54Claude Code