seedkit 2.1.1

Generate realistic, constraint-safe seed data for PostgreSQL, MySQL, and SQLite
seedkit-2.1.1 is not a library.

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.

seedkit generate --db postgres://localhost/myapp --rows 1000 --output seed.sql

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
cargo install --path crates/seedkit-cli

# Generate 1000 rows per table, output SQL
seedkit generate --db postgres://localhost/myapp --rows 1000 --output seed.sql

# Insert directly into database
seedkit generate --db postgres://localhost/myapp --rows 1000 --output direct

# Use .env or seedkit.toml for connection -- no --db needed
seedkit generate --rows 500 --output seed.sql

Installation

PyPI (recommended)

pip install seedkit
# or
pipx install seedkit

crates.io

cargo install seedkit

Builds from source with Rust 1.91 or later.

npm

npm install -g @seed-kit/cli
# or run without installing
npx @seed-kit/cli --help

GitHub Releases

Download pre-built binaries for Linux (x64/ARM64), macOS (Intel/Apple Silicon), and Windows from Releases.

From Source

git clone https://github.com/kclaka/seedkit.git
cd seedkit
cargo install --path crates/seedkit-cli

Requirements: Rust 1.91+ (2021 edition)

Verify Installation

seedkit --version
# 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.

seedkit generate --schema-file schema.sql --dialect postgres --rows 100 --output seed.sql
pg_dump --schema-only myapp > schema.sql && seedkit preview --schema-file schema.sql --dialect postgres
seedkit check --schema-file schema.sql --dialect postgres     # CI: has the schema drifted from seedkit.lock?

--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):

  1. --db CLI flag
  2. DATABASE_URL environment variable
  3. .env file in the current directory
  4. seedkit.toml config file

Usage

seedkit generate

Generate seed data for your database.

# SQL file output
seedkit generate --db postgres://localhost/myapp --rows 500 --output seed.sql

# Direct insert into database
seedkit generate --db postgres://localhost/myapp --rows 1000 --output direct

# JSON or CSV
seedkit generate --rows 100 --output data.json
seedkit generate --rows 100 --output data.csv

# One CSV file per table, with a header row, for \copy, LOAD DATA, or spreadsheets
seedkit generate --rows 100 --format csv --output seed/

# PostgreSQL COPY format (10-50x faster bulk loading)
seedkit generate --rows 10000 --output seed.sql --copy

# Deterministic with seed
seedkit generate --rows 100 --seed 42 --output seed.sql

# Reproduce from lock file
seedkit generate --from-lock

# Per-table row counts
seedkit generate --rows 100 --table-rows users=500,orders=2000

# Include/exclude tables
seedkit generate --include users,orders --rows 100
seedkit generate --exclude audit_logs,migrations --rows 100

# LLM-enhanced classification (requires ANTHROPIC_API_KEY, OPENAI_API_KEY, or GEMINI_API_KEY)
export ANTHROPIC_API_KEY=sk-ant-...
seedkit generate --rows 100 --ai --output seed.sql
seedkit generate --rows 100 --ai --model claude-sonnet-5-5 --output seed.sql
seedkit generate --rows 100 --ai --model gpt-6-luna --output seed.sql   # OpenAI
seedkit generate --rows 100 --ai --model gemini-3.5-flash-lite --output seed.sql   # Gemini

# Production-like with sampled distributions
seedkit generate --rows 1000 --subset seedkit.distributions.json

# Localized names, addresses, companies, and phone numbers
seedkit generate --rows 100 --locale de_DE

--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.

seedkit reset --db postgres://localhost/myapp --rows 50        # asks before deleting
seedkit reset --rows 50 --exclude audit_logs --yes             # no prompt, for scripts and CI
seedkit reset --from-lock --yes                                # restore the dataset in seedkit.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 AUTOINCREMENT counters. 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
seedkit sample --db postgres://readonly-replica:5432/myapp

# Sample specific tables with custom limits
seedkit sample --db postgres://localhost/myapp --tables users,orders --allow-text orders.status --categorical-limit 100

# Custom output path
seedkit sample --db postgres://localhost/myapp -o profiles.json

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 introspect --db postgres://localhost/myapp
seedkit introspect --db postgres://localhost/myapp --format json

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 preview --db postgres://localhost/myapp --rows 5

seedkit check

Detect schema drift against the lock file. Designed for CI pipelines.

seedkit check --db postgres://localhost/myapp
# Exit code 0 = no drift, 1 = drift detected

seedkit check --db postgres://localhost/myapp --format json

seedkit graph

Visualize table dependencies.

seedkit graph --db postgres://localhost/myapp --format mermaid > schema.mmd
seedkit graph --db postgres://localhost/myapp --format dot | dot -Tpng > schema.png

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.

[scenarios.workspace.rows]
workspaces = 2

[scenarios.workspace.per_parent]
"members.workspace_id" = 3
"projects.workspace_id" = 2
"tasks.project_id" = 5

[scenarios.workspace.scope."tasks.assignee_id"]
via = "project_id"
parent_scope = "workspace_id"  # on projects
target_scope = "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.

[scenarios.accounts.rows]
users = 10

[[scenarios.accounts.records.users]]
username = "owner"
is_admin = true
quota = 25

[[scenarios.accounts.records.users]]
username = "paused-user"
status = "suspended"

[columns."users.quota"]
values = [2, 5]
weights = [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:

[database]
url = "postgres://localhost/myapp"

[generate]
rows = 500
seed = 42
locale = "en"   # or de_DE, fr_FR, ja_JP, ...

[tables.users]
rows = 1000

[tables.orders]
rows = 5000

# Custom value lists with optional weights
[columns."products.color"]
values = ["red", "blue", "green", "black", "white"]
weights = [0.25, 0.20, 0.20, 0.20, 0.15]

# Text patterns: # is a digit, ? an uppercase letter, {row} the row number
[columns."orders.number"]
pattern = "INV-{row:06}"     # INV-000001, INV-000002, ...

[columns."products.sku"]
pattern = "??-####"          # KX-0417

# Numbers in an inclusive range (whole numbers for integer columns)
[columns."order_items.quantity"]
range = [1, 5]

# Choose a built-in generator instead of the naming rules' choice
[columns."accounts.employer"]
semantic = "CompanyName"

# Chance of NULL for a nullable column (default 0.05)
[columns."users.bio"]
null_rate = 0.4

# Explicit cycle-breaking for circular foreign keys
[graph]
break_cycle_at = ["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.

[[existing_parents]]
table = "users"
columns = ["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)
seedkit generate --rows 100

# Teammate reproduces identical data
seedkit generate --from-lock

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:

git checkout --ours seedkit.lock
seedkit generate --from-lock --force --output /dev/null

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
cargo test

# Run integration tests (requires Docker)
docker compose -f docker/docker-compose.test.yml up -d
TEST_POSTGRES_URL=postgres://seedkit:seedkit@localhost:5432/seedkit_test \
TEST_MYSQL_URL=mysql://seedkit:seedkit@localhost:3307/seedkit_test \
  cargo test --test '*' -- --test-threads=1

License

Licensed under the MIT License.