What problem does it solve?
Apps already running Drizzle ORM need durable TanStack AI chat state (threads, runs, interrupts, metadata) without creating a second database connection, a parallel migration system, or a separate package. This Skill writes a single chat-persistence.ts file against the app's existing db handle, schema file, and drizzle-kit journal.
Core Features & Use Cases
- Schema Integration: Appends four tables (chat_threads, chat_runs, chat_interrupts, chat_metadata) to the app's existing schema file for SQLite, Postgres, or MySQL dialects, matching existing naming conventions.
- Idempotent Store Implementations: Implements MessageStore, RunStore, InterruptStore, and MetadataStore with onConflict rules, NULL-clearing semantics for detached runs, and insert-if-absent interrupt creation that pass the shared conformance testkit.
- Per-Request Bindings: Supports request-scoped database handles like Cloudflare D1 by exporting a factory function instead of a module-level constant.
- Use Case: A team with a Postgres-backed Drizzle app adds resumable AI chat: the Skill inspects their drizzle.config.ts, appends the tables, generates chat-persistence.ts, wires withPersistence into the chat route, and verifies with runPersistenceConformance.
Quick Start
Add TanStack AI chat persistence to my existing Drizzle app by generating the four tables and the chat-persistence.ts store file against my current db setup.