
Db Seed
Generate idempotent TypeScript or SQL seed scripts with realistic domain data from Drizzle, Prisma, or SQL schemas—including FK order and D1 batch limits.
Overview
db-seed is an agent skill for the Build phase that generates idempotent database seed scripts from Drizzle, Prisma, or SQL schemas with FK-safe ordering and D1-aware batching.
Install
npx skills add https://github.com/jezweb/claude-skills --skill db-seedWhat is this skill?
- Auto-discovers Drizzle, Prisma, D1/SQL migrations, and raw SQL schema locations
- Respects foreign key ordering and unique constraints when generating rows
- Produces idempotent TypeScript or SQL seed files tuned for dev, demo, or testing purpose
- Handles Cloudflare D1 batch limits and JSON-as-TEXT columns common in SQLite/D1
- Prompts for volume, domain tone, and purpose with documented defaults
- Schema scan covers Drizzle, Prisma, D1/SQL migrations, and raw SQL patterns
- Seed purpose options documented as dev, demo, and testing
- Explicit handling for D1 batch limits and JSON fields stored as TEXT
Adoption & trust: 659 installs on skills.sh; 841 GitHub stars; 3/3 security scanners passed (skills.sh audits).
What problem does it solve?
Your schema and migrations exist but dev, demo, and test environments stay empty because manual seed data breaks foreign keys or unique constraints.
Who is it for?
Solo builders on Drizzle/D1, Prisma, or SQL stacks who need believable fixtures fast for local dev, demos, or automated tests.
Skip if: Production anonymized dumps, large-scale performance load datasets, or projects with no checked-in schema to read.
When should I use this skill?
Triggers include 'seed database', 'seed data', 'sample data', 'populate database', 'db seed', 'test data', 'demo data', 'generate fixtures'.
What do I get? / Deliverables
You get ready-to-run TypeScript or SQL seed files with realistic, domain-shaped rows ordered for safe inserts and reruns.
- Idempotent TypeScript or SQL seed script file(s)
- FK-ordered insert data with domain-appropriate sample values
Recommended Skills
Journey fit
Seeding is backend data layer work done while building features that need dev, demo, or test fixtures. It operates on schema/migrations and produces seed files, not frontend components or production monitoring.
How it compares
Schema-driven seed generator skill—not a hosted database GUI or one-click cloud console import.
Common Questions / FAQ
Who is db-seed for?
Indie developers using Claude Code who maintain Drizzle, Prisma, or SQL schemas and need consistent sample data for local apps and test pipelines.
When should I use db-seed?
Use it during Build backend work when you say "seed database", "sample data", "populate database", "demo data", or "generate fixtures" after migrations are in place.
Is db-seed safe to install?
It can write seed files and run shell commands per allowed-tools; review the Security Audits panel on this Prism page and inspect generated SQL/TS before executing against shared or production databases.
SKILL.md
READMESKILL.md - Db Seed
# Database Seed Generator Generate seed scripts that populate databases with realistic, domain-appropriate sample data. Reads your schema and produces ready-to-run seed files. ## Workflow ### 1. Find the Schema Scan the project for schema definitions: | Source | Location pattern | |--------|-----------------| | Drizzle schema | `src/db/schema.ts`, `src/schema/*.ts`, `db/schema.ts` | | D1 migrations | `drizzle/*.sql`, `migrations/*.sql` | | Raw SQL | `schema.sql`, `db/*.sql` | | Prisma | `prisma/schema.prisma` | Read all schema files. Build a mental model of: - Tables and their columns - Data types and constraints (NOT NULL, UNIQUE, DEFAULT) - Foreign key relationships (which tables reference which) - JSON fields stored as TEXT (common in D1/SQLite) ### 2. Determine Seed Parameters Ask the user: | Parameter | Options | Default | |-----------|---------|---------| | Purpose | dev, demo, testing | dev | | Volume | small (5-10 rows/table), medium (20-50), large (100+) | small | | Domain context | "e-commerce store", "SaaS app", "blog", etc. | Infer from schema | | Output format | TypeScript (Drizzle), raw SQL, or both | Match project's ORM | **Purpose affects data quality**: - **dev**: Varied data, some edge cases (empty fields, long strings, unicode) - **demo**: Polished data that looks good in screenshots and presentations - **testing**: Systematic data covering boundary conditions, duplicates, special characters ### 3. Plan Insert Order Build a dependency graph from foreign keys. Insert parent tables before children. Example order for a blog schema: ``` 1. users (no dependencies) 2. categories (no dependencies) 3. posts (depends on users, categories) 4. comments (depends on users, posts) 5. tags (no dependencies) 6. post_tags (depends on posts, tags) ``` **Circular dependencies**: If table A references B and B references A, use nullable foreign keys and insert in two passes (insert with NULL, then UPDATE). ### 4. Generate Realistic Data **Do NOT use generic placeholders** like "test123", "foo@bar.com", or "Lorem ipsum". Generate data that matches the domain. #### Data Generation Patterns (no external libraries needed) **Names**: Use a hardcoded list of common names. Mix genders and cultural backgrounds. ```typescript const firstNames = ['Sarah', 'James', 'Priya', 'Mohammed', 'Emma', 'Wei', 'Carlos', 'Aisha']; const lastNames = ['Chen', 'Smith', 'Patel', 'Garcia', 'Kim', 'O\'Brien', 'Nguyen', 'Wilson']; ``` **Emails**: Derive from names — `sarah.chen@example.com`. Use `example.com` domain (RFC 2606 reserved). **Dates**: Generate within a realistic range. Use ISO 8601 format for D1/SQLite. ```typescript const randomDate = (daysBack: number) => { const d = new Date(); d.setDate(d.getDate() - Math.floor(Math.random() * daysBack)); return d.toISOString(); }; ``` **IDs**: Use `crypto.randomUUID()` for UUIDs, or sequential integers if the schema uses auto-increment. **Deterministic seeding**: For reproducible data, use a seeded PRNG: ```typescript function seededRandom(seed: number) { return () => { seed = (seed * 16807) % 2147483647; return (seed - 1) / 2147483646; }; } const rand = seededRandom(42); // Same seed = same data every time ``` **Prices/amounts**: Use realistic ranges. `(rand() * 900 + 100).toFixed(2)` for $1-$10 range. **Descriptions/content**: Write 3-5 realistic variations per content