seed-db

Generate and insert idempotent seed data for Rails applications.

Updated Apr 20, 2026
One-click install
npx skills add https://github.com/erwaen/one-shot-test --skill seed-db
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: seed-db
Source: https://github.com/erwaen/one-shot-test/tree/main/.claude/skills/seed-db
Command: npx skills add https://github.com/erwaen/one-shot-test --skill seed-db

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Seed data is essential for development and testing, but creating consistent, repeatable datasets is time-consuming and error-prone without automated seeds.

Core Features & Use Cases

  • Idempotent seeds using find_or_create_by! to avoid duplicates and ensure repeatable results.
  • Deterministic ordering to respect foreign key dependencies (Departments, TimeOffTypes, Users, TimeOffRequests, Approvals).
  • Verifiable outputs with counts and an idempotent pattern, enabling safe re-seeding during development.

Quick Start

Run bundle exec rails db:seed to populate the seed data.

Frequently Asked Questions about seed-db

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I seed a Rails database without creating duplicate records?

Idempotent Rails database seeding prevents duplicate records by using the find_or_create_by! pattern. This approach safely checks for existing entries before insertion, allowing you to run seed scripts repeatedly without generating redundant data.

What is the best way to manage seed data dependencies in Rails?

Managing seed data dependencies requires deterministic ordering to respect foreign key constraints. By structuring your seed scripts to create parent records like Departments and TimeOffTypes before child records like Users and Approvals, you maintain relational integrity.

How do I ensure repeatable seed data generation during Rails development?

Repeatable seed data generation is achieved by wrapping insertions in a database transaction. This ensures that if any part of the seeding process fails, all changes are rolled back, keeping your database state consistent and predictable for testing.

Does Rails seed data support verification outputs after insertion?

Rails seed data can provide verification outputs by returning row counts after the script executes. Checking the inserted record counts against expected values confirms the seeding process completed successfully and the dataset matches requirements.

Can I re-run database seeds safely after modifying a Rails schema?

Re-running database seeds safely is possible if the schema migrations have completed and you apply an idempotent pattern. Using find_or_create_by! ensures existing records are updated or skipped, preventing errors when populating new relational tables.

Why does my Rails seed script fail with foreign key constraint errors?

Rails seed scripts fail with foreign key errors when insertion order violates relational dependencies. Seeding child records before their parent records triggers these constraints, so you must order operations to create independent tables first.