ai-generation-persistence
Installation
SKILL.md
AI Generation Persistence
AI generations are expensive, non-reproducible assets. Never discard them.
Every call to an LLM costs real money and produces unique output that cannot be exactly reproduced. Treat generations like database records — assign an ID, persist immediately, and make them retrievable.
Core Rules
- Generate an ID before the LLM call — use
nanoid()orcreateId()from@paralleldrive/cuid2 - Persist every generation — text and metadata to database, images and files to Vercel Blob
- Make every generation addressable — URL pattern:
/chat/[id],/generate/[id],/image/[id] - Track metadata — model name, token usage, estimated cost, timestamp, user ID
- Never stream without saving — if the user refreshes, the generation must survive
Generate-Then-Redirect Pattern
The standard UX flow for AI features: create the resource first, then redirect to its page.