What problem does it solve?
Cloudflare Workers expose D1 database bindings only per request, so standard module-scope persistence adapters cannot work. This Skill writes a chat-persistence.ts factory into a Worker that builds TanStack AI chat persistence from the request's D1 binding, plus an optional Durable Object lock store for cross-isolate mutual exclusion.
Core Features & Use Cases
- Per-request persistence factory: Generates a chatPersistence(env.DB) factory exporting a ChatPersistence with messages, runs, interrupts, and metadata stores against raw D1 or Drizzle.
- D1 migrations: Emits a numbered SQL migration file with chat_threads, chat_runs, chat_interrupts, and chat_metadata tables, applied via wrangler d1 migrations apply.
- Durable Object lock store: Implements a lease-based LockStore with expiry, alarm reclamation, and AbortSignal propagation for coordination across Worker isolates.
- Use Case: A team deploying a streaming chat app on Cloudflare Workers needs durable conversation history and run resumption; this Skill scaffolds the persistence layer, wrangler bindings, and conformance tests against Miniflare.
Quick Start
Ask the AI to add TanStack AI chat persistence to your Cloudflare Worker using its D1 binding and wrangler configuration.