ai-generation-persistence
AI generation persistence patterns — unique IDs, addressable URLs, database storage, and cost tracking for every LLM generation
Skill by zfifteen
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/zfifteen-ai-generation-persistence
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Use cases: backend, ml
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/ai-generation-persistence
What's inside
- Skill name
ai-generation-persistence- Description
- AI generation persistence patterns — unique IDs, addressable URLs, database storage, and cost tracking for every LLM generation
- License
- MIT
- Metadata
- sitemap: https://sdk.vercel.ai/sitemap.xml · priority: 6
- Instructions
- 169 lines in SKILL.md · view on GitHub
Files (2)
- SKILL.md
- openai.yaml · agents/
SKILL.md (first lines)
# 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
1. **Generate an ID before the LLM call** — use `nanoid()` or `createId()` from `@paralleldrive/cuid2`
2. **Persist every generation** — text and metadata to database, images and files to Vercel Blob
3. **Make every generation addressable** — URL pattern: `/chat/[id]`, `/generate/[id]`, `/image/[id]`
4. **Track metadata** — model name, token usage, estimated cost, timestamp, user ID
5. **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.
```ts
// app/api/chat/route.ts
import { nanoid } from "nanoid";
import { db } from "@/lib/db";
import { redirect } from "next/navigation";
export async function POST(req: Request) {
const { prompt, model } = await req.json();
const id = nanoid();
// Create the record BEFORE generation starts
await db.insert(generations).values({
id,
prompt,
model,
status: "pending",
createdAt: new Date(),
});
// Redirect to the generation page — it handles streaming
redirect(`/chat/${id}`);
}
```
```tsx
// app/chat/[id]/page.tsx
import { db } from "@/lib/db";
import { notFound } from "next/navigation";
export default async function ChatPage({ params }: { params: Promise<{ id: string }> }) {
const { id } = await params;
const generation = await db.query.generations.findFirst({
where: eq(generations.id, id),
});
if (!generation) notFound();
// Render with streaming if still pending, or show saved result
return <ChatView generation={generation} />;
}
```
This gives you: shareable URLs, back-button support, multi-tab sessions, and generation history for free.
## Persistence Schema
```ts
// lib/db/schema.ts
import { pgTable, text, integer, timestamp, jsonb } from "drizzle-orm/pg-core";
export const generations = pgTable("generations", {
id: text("id").primaryKey(), // nanoid
userId: text("user_id"), // auth user
model: text("model").notNull(), // "openai/gpt-5.4"
prompt: text("prompt"), // input text
result: text("result"), // generated output
imageUrls: jsonb("image_urls"), // Blob URLs for generated images
tokenUsage: jsonb("token_usage"), // { promptTokens, completionTokens }
estimatedCostCents: integer("estimated_cost_cents"),
status: text("status").default("pending"), // pending | streaming | complete | error
createdAt: timestamp("created_at").defaultNow(),
});
```
## Storage Strategy
| Data Type | Storage | Why |
|-----------|---------|-----|
| Text, metadata, history | Neon Postgres via Drizzle | Queryable, relational, supports search |
| Generated images & files | Vercel Blob (`@vercel/blob`) | Permanent URLs, CDN-backed, no expiry |
| Prompt dedup cache | Upstash Redis | Fast lookup, TTL-based expiry |
## Image Persistence
Never serve generated images as ephemeral base64 or temporary URLs. Save to Blob immediately:
```ts
import { put } from "@vercel/blob";
import { generateText } from "ai";
const result = await generateText({ model, prompt });
// Save every generated image to permanent storage
const imageUrls: string[] = [];
for (const file of result.files ?? []) {
if (file.mediaType?.startsWith("image/")) {
const ext = file.mediaType.split("/")[1] || "png";
const blob = await put(`generations/${generationId}.${ext}`, file.uint8Array, {
access: "public",
contentType: file.mediaType,
});
imageUrls.push(blob.url);
}
}
// Update the generation record with permanent URLs
await db.update(generations)
.set({ imageUrls, status: "complete" })
.where(eq(generations.id, generationId));
```
## Cost TrackingFrom zfifteen/skills-catalog, MIT.
More from zfifteen/skills-catalog
- 0.502score
30-30-30-technical-note
zfifteen
Turn a PGS research finding into a three-layer technical note bundle: (1) Grade-10 plain prose, (2) embedded SVG infographic with concise figures, (3)…
SkillCFreshness: C★ 1Claude Code +9 - 0.501score
aiq-deploy
NVIDIA AI-Q Blueprint Team <aiq-blueprint@nvidia.com>
Use when asked to install, deploy, run, validate, troubleshoot, or stop NVIDIA AI-Q Blueprint infrastructure.
SkillCFreshness: C★ 1Claude Code +9 - 0.501score
aiq-research
NVIDIA AI-Q Blueprint Team <aiq-blueprint@nvidia.com>
Use when asked to run deep research or AI-Q research through a reachable NVIDIA AI-Q Blueprint backend.
SkillCFreshness: C★ 1Claude Code +9 - 0.499score
agent-vision
zfifteen
CRITICAL WHILE ARMED: (1) capture (2) read_file NEW JPEG (3) USE pixels in reasoning (4) turn-gate record + ready.
SkillCFreshness: C★ 1Claude Code +9 - 0.498score
agy-cli-collab
zfifteen
Sticky Grok→Gemini collaboration via direct local Antigravity CLI (`agy`) subprocess calls only.
SkillCFreshness: C★ 1Claude Code +9 - 0.498score
agent-bus-collab
zfifteen
Use when the user asks Codex to coordinate with Grok or another local peer agent through Agent Bus MCP, mentions agent-bus, bus topics, readiness handshakes…
SkillCFreshness: C★ 1Claude Code +9 - 0.497score
actualize
zfifteen
Reduce reasoning friction and produce the most direct, high-fidelity answer or artifact possible.
SkillCFreshness: C★ 1Claude Code +9 - 0.497score
airtable-cli
zfifteen
Lists bases, reads and writes records, manages tables and fields, filters and searches data in Airtable via the `airtable-mcp` CLI.
SkillCFreshness: C★ 1Claude Code +9 - 0.497score
airtable-overview
airtable
Explains what Airtable is and how data is structured — bases, tables, fields, records, views, automations, and interfaces.
SkillCFreshness: C★ 1Claude Code +9 - 0.493score
agents-sdk
zfifteen
Build, run, deploy, and evaluate OpenAI Agents SDK apps from Codex.
SkillCFreshness: C★ 1Claude Code +9 - 0.491score
alpha
zfifteen
Alpha fixture skill.
SkillCFreshness: C★ 1Claude Code +9 - 0.472score
airtable-filters
airtable
Use this skill when the user wants to find, filter, or narrow down Airtable records by field values, even when they don't explicitly say "filter."
SkillCFreshness: C★ 1Claude Code +9
Signals
- Stars
- 1
- Forks
- 1
- Open issues
- 0
- Last commit (this folder)
- Jul 19, 2026 (3 months ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- MIT
- Repository
- github.com/zfifteen/skills-catalog
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
Same skill elsewhere
Copies of this SKILL.md published by others; search shows only one of them.
More from zfifteen
- 0.502score
30-30-30-technical-note
zfifteen
Turn a PGS research finding into a three-layer technical note bundle: (1) Grade-10 plain prose, (2) embedded SVG infographic with concise figures, (3)…
SkillCFreshness: C★ 1Claude Code +9 - 0.499score
agent-vision
zfifteen
CRITICAL WHILE ARMED: (1) capture (2) read_file NEW JPEG (3) USE pixels in reasoning (4) turn-gate record + ready.
SkillCFreshness: C★ 1Claude Code +9 - 0.498score
agent-bus-collab
zfifteen
Use when the user asks Codex to coordinate with Grok or another local peer agent through Agent Bus MCP, mentions agent-bus, bus topics, readiness handshakes…
SkillCFreshness: C★ 1Claude Code +9 - 0.498score
agy-cli-collab
zfifteen
Sticky Grok→Gemini collaboration via direct local Antigravity CLI (`agy`) subprocess calls only.
SkillCFreshness: C★ 1Claude Code +9 - 0.497score
airtable-cli
zfifteen
Lists bases, reads and writes records, manages tables and fields, filters and searches data in Airtable via the `airtable-mcp` CLI.
SkillCFreshness: C★ 1Claude Code +9 - 0.497score
actualize
zfifteen
Reduce reasoning friction and produce the most direct, high-fidelity answer or artifact possible.
SkillCFreshness: C★ 1Claude Code +9
Cite this page
ai-generation-persistence skill. Agent Mart. https://agentmart.dev/skills/zfifteen-ai-generation-persistence (last updated 2026-10-24)