ai-persistence/build-cloudflare-artifact-store

ai-persistence/build-cloudflare-artifact-store is a skill for Claude Code from TanStack/ai. It costs 104 tokens per session (7,746 once invoked), scanned A, original, MIT.

A storage setup for Cloudflare Workers that saves generated media bytes in R2 and their descriptions in D1. Cloudflare Workers are server-side programs, R2 stores files, and D1 is a SQL database.

In plain words
What is it for?
Use it to add media storage to TanStack AI generation persistence and serve saved artifacts through a GET route.
Why use it?
It gives generated images, audio, video, and transcripts a durable place to live instead of keeping them only during a request.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin.

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

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

Good fit Use it to add media storage to TanStack AI generation persistence and serve saved artifacts through a GET route.

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-artifact-store

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-artifact-store

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

Your own site · 80×15
<a href="https://agentmods.dev/skills/tanstack/ai/build-cloudflare-artifact-store"><img src="https://agentmods.dev/badge/skills/tanstack/ai/build-cloudflare-artifact-store.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 104 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 7,746 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: 4 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 Memory Poisoning · line 660
    Skill attempts to fill the context window with filler content, displacing legitimate instructions and safety constraints. This can degrade agent performance or bypass safety boundaries.
    Fix: Implement context-window management that detects and rejects padding or stuffing attempts. Prioritize system instructions over user-injected content.
  • medium Prompt Injection · line 660
    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 663
    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 664
    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.00104 $0.07746
Opus 5.5 $0.00042 $0.03098
Sonnet 5.5 $0.00021 $0.01549
Haiku 4.5 $0.00010 $0.00775

Measured 15d ago against content hash dc1997027533, 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-artifact-store 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 15d 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.

async fetch(request: Request, env: Env) {
packages/ai-persistence/skills/ai-persistence/build-cloudflare-artifact-store/SKILL.md · 735 lines

How it starts

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

Cloudflare Artifact + Blob Store

withGenerationPersistence(persistence) needs only stores.generationRuns to track a generation's lifecycle. Add stores.artifacts (metadata) and stores.blobs (the bytes) — both, or neither — and the middleware also persists the generated media: image/audio/TTS/video/transcription bytes land at blob key artifacts/<runId>/<artifactId>, with an ArtifactRecord row describing each.

The deliverable is one file in the Worker — e.g. src/lib/generation-persistence.ts — exporting a factory that builds an AIPersistence from the request's R2 + D1 bindings, plus a GET route that serves artifact bytes with retrieveArtifact / retrieveBlob.

Read the sibling ai-persistence/build-cloudflare-adapter skill for the per-request-binding rule, wrangler config shape, D1 migration workflow, and the chat (generation-run/message) side. This skill covers only the two byte-storage stores and how to compose them.

The two contracts

Both come from @tanstack/ai-persistence. defineBlobStore / defineArtifactStore type an object literal inline (autocomplete + contract checking, no separate annotation).

import type {
  ArtifactRecord,
  BlobBody,
  BlobGetOptions,
  BlobListOptions,
  BlobListPage,
  BlobObject,
  BlobPutOptions,
  BlobRecord,
} from '@tanstack/ai-persistence'

// BlobStore — the byte layer. R2 backs it.
interface BlobStore {
  put: (
    key: string,
    body: BlobBody,
    options?: BlobPutOptions,
  ) => Promise<BlobRecord>
  // metadata + byte accessors; `options.range` reads one slice (for `206`s)
  get: (key: string, options?: BlobGetOptions) => Promise<BlobObject | null>
  head: (key: string) => Promise<BlobRecord | null> // metadata only
  delete: (key: string) => Promise<void> // no-op if absent
  list: (options?: BlobListOptions) => Promise<BlobListPage>
}

// ArtifactStore — the metadata layer. D1 backs it.
interface ArtifactStore {
  save: (record: ArtifactRecord) => Promise<void> // insert or overwrite
  get: (artifactId: string) => Promise<ArtifactRecord | null>
  list: (runId: string) => Promise<Array<ArtifactRecord>> // [] when none
  listForThread: (threadId: string) => Promise<Array<ArtifactRecord>>
  delete: (artifactId: string) => Promise<void>
  deleteForRun: (runId: string) => Promise<void>
}

Read the full file on GitHub · 735 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. 15d ago Changed dc1997027533
  2. 1mo ago Changed · +8 lines 6a0ec04f66d6
  3. 1mo ago Changed · +11 lines fd895225b184
  4. 2mo ago First seen · 716 lines · 104 tokens per session scan A 61f02020ee85

Subscribe to this mod's changes

ai-persistence/build-cloudflare-artifact-store is a skill published in the GitHub repository TanStack/ai (3,336 stars, last pushed yesterday), licensed MIT. It adds 104 tokens to every session and 7,746 once invoked, about $0.0004 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-artifact-store compared with skills from other repositories

ai-persistence/build-cloudflare-artifact-store next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
ai-persistence/build-cloudflare-artifact-storeTanStack/aiSkill3.3kyesterdayMITA104Claude 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