All skills
Skillintermediate
/seed-db - Seed Database
Seed a database with generated test data.
Claude Code Knowledge Pack7/10/2026
Overview
/seed-db - Seed Database
Seed a database with generated test data.
Steps
- Detect the database type and ORM from project configuration (Prisma, TypeORM, Sequelize, Django, etc.)
- Read the database schema to understand tables, columns, and relationships
- Determine the correct insertion order based on foreign key dependencies
- Generate appropriate test data for each table using realistic values
- Create the seed script in the project's preferred format and language
- Handle auto-increment IDs and UUID generation appropriately
- Include data for lookup tables and enum-like reference data
- Add transaction wrapping to ensure atomic seeding (all or nothing)
- Include a cleanup step to truncate tables before seeding
- Run the seed script against the development database
- Verify seed data by querying record counts for each table
- Report: tables seeded, total records inserted, execution time
Rules
- Never run seed scripts against production databases
- Always wrap seed operations in transactions for rollback safety
- Respect foreign key constraints by inserting parent records first
- Use the ORM's built-in seeding mechanism when available
- Include idempotent checks so seeds can be re-run safely
- Generate enough data to test pagination (at least 25 records for list endpoints)
- Store seed scripts in a dedicated seeds or fixtures directory