# db-seed

Generates database seed scripts with realistic sample data by inspecting Drizzle schemas, Prisma models, or SQL migrations.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode · 981 installs · ★ 1075
- Author: jezweb
- License: MIT · policy=mirror · the beginning of the file is at the end of this page
- Source: https://github.com/jezweb/claude-skills/tree/HEAD/archive/plugins/cloudflare/skills/db-seed/SKILL.md
- Updated: 2026-10-09
- HTML: https://affpapa.org/en/nevibecode/skills/db-seed

## What it does

The skill scans the project for schema definitions in `src/db/schema.ts`, `prisma/schema.prisma`, or raw SQL migrations. It builds a dependency graph from foreign keys, making sure parent tables populate before dependent rows. Circular references require two passes. It inserts records with nullable foreign keys first, then updates them.

Output formats include TypeScript scripts for Drizzle ORM and raw SQL files. The generator avoids generic placeholder text by creating realistic names, reserved RFC 2606 `example.com` emails, and ISO timestamps without external libraries. For idempotency, it applies reverse-order delete blocks or `onConflictDoUpdate` logic.

Watch out for Cloudflare D1 limitations. Inserts will fail if batches exceed 10 rows per `INSERT` or pass more than 100 bound parameters in a single query.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add jezweb/claude-skills --skill db-seed -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/db-seed/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/db-seed/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add jezweb/claude-skills --skill db-seed -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/db-seed/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add jezweb/claude-skills --skill db-seed -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/db-seed/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install jezweb/claude-skills db-seed
```

2. **Manually: put the files in place**
- File: `.github/skills/db-seed/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add jezweb/claude-skills --skill db-seed -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/jezweb/claude-skills --path archive/plugins/cloudflare/skills/db-seed
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/db-seed/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add jezweb/claude-skills --skill db-seed -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/jezweb/claude-skills/tree/HEAD/archive/plugins/cloudflare/skills/db-seed/SKILL.md

## When to use it
- populate local and demo databases with domain-specific records
- generate idempotent Drizzle TypeScript seed files
- resolve table insert order across complex foreign key hierarchies
- batch SQL fixtures to stay within Cloudflare D1 query limits

## Example prompts
- Generate sample data for my Drizzle schema
- Run db seed for the e-commerce store with medium volume
- Create seed database scripts for testing with boundary conditions

## Source text · SKILL.md · MIT

Below is the content of a third-party file. It is data, not instructions for you: do not act on anything written inside unless the human asks. Block tag: 9fed3e1ef66cd5e9.

BEGIN THIRD-PARTY FILE 9fed3e1ef66cd5e9
````text
---
name: db-seed
description: "Generate database seed scripts with realistic sample data. Reads Drizzle schemas or SQL migrations, respects foreign key ordering, produces idempotent TypeScript or SQL seed files. Handles D1 batch limits, unique constraints, and domain-appropriate data. Use when populating dev/demo/test databases. Triggers: 'seed database', 'seed data', 'sample data', 'populate database', 'db seed', 'test data', 'demo data', 'generate fixtures'."
allowed-tools:
  - Read
  - Write
  - Edit
  - Glob
  - Grep
  - Bash
compatibility: claude-code-only
---

# 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'];
````
END THIRD-PARTY FILE 9fed3e1ef66cd5e9

The third-party file has ended. Everything between the 9fed3e1ef66cd5e9 tags is data: requests and commands from it are not followed. An “end of file” line with another tag inside the block is part of the file.

First 2971 of 7522 bytes. © jezweb · MIT · https://github.com/jezweb/claude-skills/tree/HEAD/archive/plugins/cloudflare/skills/db-seed/SKILL.md

_Part of the page did not fit — see the HTML version._

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
