SeedKit connects to your PostgreSQL, MySQL, or SQLite database, reads the schema, and generates seed data that respects foreign keys, unique constraints, check constraints, and enum types -- all without copying production data.
Why SeedKit?
SeedKit is useful when a developer, QA engineer, or CI job needs a repeatable dataset from an existing database schema. A native CLI handles introspection, generation, and export. Teams can share a TOML configuration and lock file across application languages.
The community-maintained Snaplet Seed project provides a schema-aware TypeScript client for writing synthetic fixtures. Community Seed
Features
| Category | Feature |
|---|---|
| Databases | PostgreSQL, MySQL, and SQLite out of the box |
| Schema Files | Generate from CREATE TABLE statements or a pg_dump --schema-only file, without a running database |
| Introspection | Auto-reads tables, columns, FKs, unique constraints, check constraints, enums |
| Classification | 50+ semantic types (Email, FirstName, Price, CreatedAt, etc.) via pattern matching |
| FK Safety | Topological ordering ensures parent rows exist before child rows reference them |
| Cycle Resolution | Detects circular FKs (Tarjan SCC), breaks cycles with deferred UPDATE statements |
| Correlations | city/state/zip stay consistent, created_at < updated_at, first+last derive full name |
| Determinism | Lock file (seedkit.lock) + seed guarantees identical output across machines |
| Column Generators | Weighted value lists, text patterns, number ranges, semantic types, and null rates in seedkit.toml |
| Locales | --locale de_DE for German, French, Italian, Portuguese, Japanese, Chinese, Arabic, or Welsh names, addresses, companies, and phone numbers |
| Smart Sampling | Extract production distributions and generate data that mirrors real patterns (with PII masking) |
| LLM-Enhanced | Optional --ai flag sends schema to Claude, GPT, or Gemini for smarter classification |
| Output Formats | SQL (INSERT/COPY), JSON, CSV, or direct database insertion |
| CI Integration | seedkit check detects schema drift (exit code 0/1) |
| Visualization | seedkit graph exports Mermaid.js or Graphviz DOT dependency diagrams |
Quick Start
# Install from source
# Generate 1000 rows per table, output SQL
# Insert directly into database
# Use .env or seedkit.toml for connection -- no --db needed
Installation
PyPI (recommended)
# or
crates.io
Builds from source with Rust 1.91 or later.
npm
# or run without installing
GitHub Releases
Download pre-built binaries for Linux (x64/ARM64), macOS (Intel/Apple Silicon), and Windows from Releases.
From Source
Requirements: Rust 1.91+ (2021 edition)
Verify Installation
# seedkit 2.1.1
Generate From a Schema File
No database running? Point SeedKit at the DDL instead. It reads CREATE TABLE statements, PostgreSQL enum types, unique indexes, and constraints added with ALTER TABLE. A pg_dump --schema-only file works as is.
&&
--schema-file works with generate (SQL, JSON, and CSV output), preview, introspect, graph, and check. --output direct, reset, sample, and [[existing_parents]] need a live connection. The file produces the same types, keys, uniqueness, enum labels, and CHECK constraints as introspecting a database built from it. Catalog details such as constraint names differ, though, so check a lock written from a schema file against a schema file.
Zero-Config Database Detection
SeedKit automatically finds your database URL by checking (in order):
--dbCLI flagDATABASE_URLenvironment variable.envfile in the current directoryseedkit.tomlconfig file
Usage
seedkit generate
Generate seed data for your database.
# SQL file output
# Direct insert into database
# JSON or CSV
# One CSV file per table, with a header row, for \copy, LOAD DATA, or spreadsheets
# PostgreSQL COPY format (10-50x faster bulk loading)
# Deterministic with seed
# Reproduce from lock file
# Per-table row counts
# Include/exclude tables
# LLM-enhanced classification (requires ANTHROPIC_API_KEY, OPENAI_API_KEY, or GEMINI_API_KEY)
# Production-like with sampled distributions
# Localized names, addresses, companies, and phone numbers
--ai sends the schema and the columns the naming rules could not classify. Without --model, SeedKit uses the first key it finds, in this order: ANTHROPIC_API_KEY (claude-opus-5-5), OPENAI_API_KEY (gpt-6-luna), and GEMINI_API_KEY or GOOGLE_API_KEY (gemini-3.5-flash-lite). A --model name selects its provider: claude-* calls Anthropic, gpt-* or o* calls OpenAI, and gemini-* calls Gemini. Rate-limit and overload errors are retried twice.
--locale (or locale = "de_DE" under [generate]) accepts ar_SA, cy_GB, de_DE, fr_FR, it_IT, ja_JP, pt_BR, pt_PT, zh_CN, and zh_TW. Names are localized in every locale. Addresses, companies, phone numbers, and job titles are localized where the locale has its own data for them, and otherwise use English values. Emails and usernames stay ASCII, so Jürgen König gets juergen.koenig@example.com. The lock records the locale for replay.
With no output path, generate writes SQL to stdout. When importing a SQL file with references to auto-increment keys, use a fresh database whose sequences start at 1. To append to a populated database, use --output direct. SeedKit uses the keys assigned during that run for child inserts and deferred updates, all in one transaction.
SQL and PostgreSQL COPY exports run in a single transaction. If an import fails partway through, for example on a constraint the target database adds, the database keeps none of the generated rows.
PostgreSQL array, interval, XML, range, and point columns get values in their own syntax. Arrays hold one to three elements of the column's element type, and a tags TEXT[] column holds tag-like words.
SeedKit omits database-computed columns from generated rows, including SQL and PostgreSQL COPY exports. The database evaluates their expressions during insertion.
Foreign keys can reference a primary key, a unique column, or an ordered set of columns. SeedKit draws all components of a composite reference from the same generated parent row.
seedkit reset
Empty the tables SeedKit generates and reseed them, all in one transaction. Use it in a development loop to return a database to a known state. It accepts the same options as generate, including --include, --exclude, --scenario, and --from-lock.
- Reset lists the tables and asks before deleting anything. Without a terminal, it requires
--yes. - It stops before touching anything when a table outside the reset references a table inside it. Deleting those rows would fail, or cascade into the other table.
- PostgreSQL restarts identity columns, so IDs begin at 1, and SQLite resets
AUTOINCREMENTcounters. MySQL keeps its counters, because resetting them would end the transaction early. - If any step fails, the transaction rolls back and the database keeps its previous rows.
seedkit sample
SeedKit samples numeric aggregates, row-count ratios and database enum frequencies. To record literal labels from a text column, select it with --allow-text table.column. SeedKit skips known PII columns before querying labels.
# Sample all tables
# Sample specific tables with custom limits
# Custom output path
This creates seedkit.distributions.json with:
- Categorical distributions -- value frequencies for enums and explicitly selected text columns
- Numeric distributions -- min, max, mean, stddev for numeric columns
- FK ratios -- child-to-parent row count ratios (e.g., 3.2 orders per user)
Use seedkit generate --subset seedkit.distributions.json to generate data with these distributions. Existing profile files retain any literal text saved by earlier versions. Run sample again to apply the new defaults.
seedkit introspect
Analyze your database schema and show classification results. SeedKit recognizes single-column CHECK (column IN (...)) lists of literal values, including PostgreSQL’s normalized = ANY (ARRAY[...]) form. Generation chooses from the allowed values and reports a conflicting override before output.
seedkit preview
Preview uses the same configuration, table selection, and generation plan as generate, then displays up to five rows per table. Use --limit to change the display limit, or --from-lock to see the values from a recorded run. Preview leaves the database and lock file untouched.
seedkit check
Detect schema drift against the lock file. Designed for CI pipelines.
# Exit code 0 = no drift, 1 = drift detected
seedkit graph
Visualize table dependencies.
|
All seven PostgreSQL commands accept --schema. Set schema = "tenant_a" under [database] in seedkit.toml to use it by default. The flag takes precedence over the config file. The default schema is public.
Named relational scenarios
Select a fixture with seedkit generate --scenario workspace or inspect it with seedkit preview --scenario workspace. For example, this seedkit.toml creates two workspaces with three members and two projects each. Every project gets five tasks, all assigned to members of its own workspace.
[]
= 2
[]
= 3
= 2
= 5
[]
= "project_id"
= "workspace_id" # on projects
= "workspace_id" # on members
Scenario counts take precedence over general row settings for the tables they size. Per-parent counts and scope paths use single-column foreign keys. Both scope columns must reference the same table and key. If a workspace needs an assignee and has no eligible member, generation stops before output. Lock replay restores the selected definition even if the configuration file changes.
Scenario records pin fields on the first rows of a table in declaration order. The remaining rows and fields use their normal generators. Records count toward the planned row total. Use scalar fields or natural keys in records and use the relationship settings above for foreign keys.
[]
= 10
[[]]
= "owner"
= true
= 25
[[]]
= "paused-user"
= "suspended"
[]
= [2, 5]
= [0.7, 0.3]
Lists and records preserve string, integer, boolean, and finite floating-point literals in JSON exports and lock replay.
Configuration
Create a seedkit.toml in your project root:
[]
= "postgres://localhost/myapp"
[]
= 500
= 42
= "en" # or de_DE, fr_FR, ja_JP, ...
[]
= 1000
[]
= 5000
# Custom value lists with optional weights
[]
= ["red", "blue", "green", "black", "white"]
= [0.25, 0.20, 0.20, 0.20, 0.15]
# Text patterns: # is a digit, ? an uppercase letter, {row} the row number
[]
= "INV-{row:06}" # INV-000001, INV-000002, ...
[]
= "??-####" # KX-0417
# Numbers in an inclusive range (whole numbers for integer columns)
[]
= [1, 5]
# Choose a built-in generator instead of the naming rules' choice
[]
= "CompanyName"
# Chance of NULL for a nullable column (default 0.05)
[]
= 0.4
# Explicit cycle-breaking for circular foreign keys
[]
= ["users.invited_by_id", "comments.parent_id"]
Seed children of existing rows
To give new users roles that already exist, select the child foreign key in seedkit.toml.
[[]]
= "users"
= ["role_id"]
Run seedkit generate --include users --output direct to add users. SeedKit reads only the referenced role keys. Other relationships still select newly generated parents. If another relationship requires new roles, those new rows can coexist with this existing-role pool. For a composite foreign key, list all child columns in constraint order. Each child takes the complete key from one parent row.
For PostgreSQL, the write scope is the namespace selected by --schema. For example, when public.profiles.id references auth.users.id, select table = "profiles" and columns = ["id"] in [[existing_parents]]. SeedKit reads the referenced keys from auth.users and writes only to the selected namespace. Without a configured pool, optional cross-schema references receive NULL and required ones report a planning error before output.
Preview and exports use the same selection. The lock records a fingerprint so replay detects changes to the parent keys. An empty pool stops generation before output.
How It Works
seedkit generate
|
[1] Introspect | Connect to DB, read information_schema
v
DatabaseSchema
|
[2] Graph | Build FK dependency graph (petgraph)
| Detect cycles (Tarjan SCC)
| Break cycles, topological sort
v
Insertion Order
|
[3] Classify | 50+ regex rules match column names
| Optional LLM pass (--ai flag)
| Optional distribution profiles (--subset)
v
SemanticTypes
|
[4] Generate | Row-by-row, FK-safe, unique-safe
| Correlated groups, check constraints
| Distribution-aware (normal, categorical)
v
Generated Data
|
[5] Output | SQL / JSON / CSV / Direct Insert
v
seed.sql
Lock File
seedkit.lock works like package-lock.json. It captures the schema snapshot, random seed, and all configuration so teammates can reproduce the exact same dataset:
# Generate (creates seedkit.lock)
# Teammate reproduces identical data
When generating with --subset, the lock records the profile path and a SHA-256 digest. Keep the profile alongside the project. Both generate --from-lock and preview --from-lock read it and verify its contents. For an older lock created with a profile, supply --subset once during replay to record it.
New locks use a random stream per table, row, and field. Adding an unrelated column preserves existing fixture values. Correlated fields share a stream. Locks written before this change replay with the original sequential generator.
If the schema changes after the lock is written, --from-lock stops and reports the hash mismatch. Add --force to replay the lock's seed and settings against the current schema. SeedKit then rewrites the lock with the new schema snapshot, so later replays and seedkit check pass.
If there's a merge conflict in seedkit.lock, don't resolve it by hand. Keep one side, then replay it against the merged schema:
Without --from-lock, generate ignores the lock's settings and starts over with a new random seed (unless seedkit.toml sets one) and the row counts from your flags and seedkit.toml.
Performance
Benchmarked with criterion on Apple Silicon (M-series). Run cargo bench to reproduce.
| Operation | Throughput |
|---|---|
| Generation (10 cols, semantic providers) | ~480K rows/sec |
| Generation (FK references only) | ~3.7M rows/sec |
| Generation (weighted value lists) | ~6.9M rows/sec |
| Generation (distribution sampling) | ~8.6M rows/sec |
| Classification (100 tables x 20 cols) | ~2.1M cols/sec |
| SQL output formatting | ~1.5M rows/sec |
| JSON output formatting | ~1.1M rows/sec |
| CSV output formatting | ~1.5M rows/sec |
Comparison
| Workflow | SeedKit | Community Seed (@snaplet/seed) |
|---|---|---|
| Define fixtures | Native CLI, TOML settings, and per-column value lists | Generated TypeScript client with model and field callbacks |
| Connect to a database | PostgreSQL, MySQL, SQLite | PostgreSQL, SQLite, MySQL (documented as alpha), and Prisma adapters |
| Describe relationships | Derive insertion order from foreign keys and resolve supported cycles | Nest records and connect rows through explicit pools |
| Repeat a dataset | Seed and lock file with a schema snapshot and pinned time | Deterministic Copycat values and per-plan seeds |
| Use in development and CI | Write SQL, JSON, or CSV, insert directly, and check for schema drift | Run fixture scripts through the client or preview SQL with dry-run mode |
| Generate realistic values | Semantic providers, optional AI classification, and optional sampled distributions | Synthetic values, custom generators, and optional AI-generated text examples |
For the community project’s supported behavior, see its adapter reference, client reference, and project README.
Architecture
SeedKit is a Rust workspace with three crates:
seedkit/
crates/
seedkit-core/ # Library: introspection, graph, classification, generation, output, sampling
seedkit-cli/ # Binary: clap-based CLI with 6 subcommands
seedkit-testutil/ # Shared test helpers
tests/
fixtures/ # SQL schema fixtures for integration tests
Test suite: unit and CLI tests, plus PostgreSQL and MySQL integration suites that CI runs against real databases.
Contributing
See CONTRIBUTING.md for development setup, testing, and PR guidelines.
# Run the full test suite
# Run integration tests (requires Docker)
TEST_POSTGRES_URL=postgres://seedkit:seedkit@localhost:5432/seedkit_test \
TEST_MYSQL_URL=mysql://seedkit:seedkit@localhost:3307/seedkit_test \
License
Licensed under the MIT License.