From rails-agent-skills
Manages development and test data in Rails with idempotent seeds using find_or_create_by!, environment-scoped data, and safe credential handling.
How this skill is triggered — by the user, by Claude, or both
Slash command
/rails-agent-skills:seed-databaseThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Manage development and test data effectively.
Manage development and test data effectively.
| Use | Solution |
|---|---|
| Static reference data | db/seeds.rb with find_or_create_by! |
| Test scenarios | FactoryBot in spec/factories/ |
| Complex relationships | Both combined |
NEVER commit production data to seeds
ALWAYS use factories for test-specific scenarios
ALWAYS make seeds idempotent (can run multiple times safely)
NEVER hardcode credentials (passwords, API keys, secrets) in seeds, factories, or examples
- Use ENV variables (e.g., ENV.fetch('DEFAULT_SEED_PASSWORD')) or SecureRandom.hex(16) for non-production data
- Use `rails credentials:edit` to manage production secrets, never commit them in code
find_or_create_by! so re-runs are safe.Rails.env checks.rails db:seed (or rails db:setup for a fresh database).rails db:seed a second time and confirm no duplicates or errors.rails console and spot-check expected records exist with correct attributes.A copy-paste ready db/seeds.rb covering idempotency, environment scoping, and safe credentials:
# db/seeds.rb
# Static reference data — safe to run repeatedly
Role.find_or_create_by!(name: 'admin') do |r|
r.description = 'Full system access'
end
Role.find_or_create_by!(name: 'member') do |r|
r.description = 'Standard user access'
end
# Development-only seed data — never runs in production
if Rails.env.development?
User.find_or_create_by!(email: '[email protected]') do |u|
u.role = Role.find_by!(name: 'admin')
u.password = ENV.fetch('DEFAULT_SEED_PASSWORD', SecureRandom.hex(16))
end
end
For FactoryBot factory definitions and more complex relationship patterns, see EXAMPLES.md.
Load these files only when their specific content is needed:
rails db:seed, a second idempotency run, and a rails console spot-check.| Skill | When to chain |
|---|---|
| write-tests | When setting up test scenarios |
| review-migration | When ensuring DB schema is aligned |
npx claudepluginhub igmarin/rails-agent-skills --plugin rails-agent-skillsGenerates realistic test data for databases, respecting schemas, relationships, and constraints. Supports SQL inserts, Faker libraries, and ORMs in JS/TS, Python, Ruby.
Establishes patterns for test factories, fixtures, database seeding, and test data isolation to decouple tests from specific database states.