What problem does it solve?
TanStack AI chat persistence needs four stores (messages, runs, interrupts, metadata) with strict idempotency invariants, but databases like raw Postgres, Kysely, node:sqlite, MongoDB, or Redis have no dedicated adapter recipe. This Skill writes a working chat-persistence.ts against the app's existing database client without inventing new infrastructure.
Core Features & Use Cases
- Custom adapter generation: Produces a single
src/lib/chat-persistence.ts exporting a ChatPersistence built from the app's existing client, with DDL added through the app's own migration flow.
- Invariant enforcement: Encodes the seven idempotency invariants (full-overwrite
saveThread, insert-if-absent createOrResume, silent no-op updates, explicit-clear vs omitted-field handling) that prevent stuck approvals and wiped history.
- Engine-specific guidance: Covers Postgres/pg, Kysely, node:sqlite, MongoDB, and Redis with driver-specific patterns for JSON handling, composite keys, and upsert semantics.
- Use Case: An app using raw
pg with no ORM needs durable chat threads and resumable runs; this Skill writes the four stores, wires withPersistence into the chat route, and sets up the conformance test suite.
Quick Start
Ask the AI to build a TanStack AI chat persistence adapter for your existing database client, for example: "Write chat persistence for my app using the pg pool in src/db.ts and verify it with the conformance testkit."