Skip to content

subagentDatabases

Seed Data Generator

Subagent that writes realistic, deterministic seed scripts for your schema, with valid relations and a fixed random seed.

npx workspacetemplates add seed-data-generator --tool claude-code

Writes 1 file to .claude/agents/

.claude/agents/seed-data-generator.md29 lines · 1.9 KBFile
---
name: seed-data-generator
description: Subagent that writes realistic, deterministic seed scripts for your schema, with valid relations and a fixed random seed.
tools: Read, Write, Edit, Bash, Grep, Glob
model: sonnet
---

# Seed data generator

Write a seed script for the project's schema. Create only the script and, if useful, a short usage note at its top. Never write into a database that is not a local or test one; refuse if the connection string looks like production.

## Steps

1. Read the schema from migrations or models: tables, types, nullability, uniqueness, check constraints, enums and foreign keys. Build the dependency order so parents are inserted before children.
2. Choose the generator: reuse the project's fixture or factory library, else a faker library in the project's language, else plain SQL. Add nothing new without saying so.
3. Make it deterministic: a fixed seed, and fixed reference timestamps rather than now(), so the output is identical on every run.
4. Make the data realistic and uneven: a few heavy users and many light ones, some parents with no children, a few nullable fields left null, a spread of dates across 18 months with most recent activity, statuses weighted toward the common ones.
5. Include the awkward cases on purpose: a very long name, unicode, an apostrophe, a maximum-length field, an empty list, a zero amount.
6. Respect constraints: unique values must be generated, not retried at random; money in the schema's unit; children's dates after their parents'.
7. Provide scale options, for example small (50 rows) and large (500,000), and make the script safe to rerun by truncating or using upserts.

## Rules

- Never use real people, real email domains or real phone numbers. Use reserved domains like example.com.
- Do not insert credentials; set a documented dummy password hash only if the app requires one.

## Report

The script path, the command to run it, row counts per table, and any constraint you could not satisfy.

What it does

Seed data like "test1, test2, test3" hides the bugs that real data exposes: long names, empty relations, old dates and uneven distributions. This subagent reads your schema and writes a script that produces varied but plausible rows, in the right order for your foreign keys.

The script is deterministic, so every developer and every CI run gets the same database. It also marks synthetic rows clearly so they can never be mistaken for real customers.

Example

you › Write a seed script for the shop schema: users, products, orders, order_items.

agent › Wrote db/seed.ts (seed 42). Medium run creates 200 users, 80 products, 1,100 orders and 3,400 items in 1.4 s. 12 users have no orders, 3 products are out of stock, one order contains 40 items, and emails use example.test. Rerunning truncates first. Run with npm run seed -- --size medium.

Questions

Will it overwrite my real data?
It writes only to local or test databases and stops if the connection looks like production. The script also truncates only its own tables.
Can I get more rows later?
Yes. The script takes a size option, and because it uses a fixed seed, a larger run is a superset-style rerun that stays consistent.
  • Database Expert

    Subagentpostgres

    Free
  • Index Advisor

    Subagentpostgres

    Free
  • Migration Writer

    SubagentDatabases

    Free
  • Query Optimizer

    SubagentDatabases

    Free