Seed database
Skill igmarin/rails-agent-skills/skills/infrastructure/seed-database
This is my personal configuration of skills as a Ruby on Rails Dev
npx -y skills add igmarin/rails-agent-skills --skill seed-databaseAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 22 stars22 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
What its author says it does
Copied from the file, not written here
Use when managing development and test data in Rails — must write idempotent seeds using find_or_create_by!, run seeds with rails db:seed or rails db:setup, verify data by opening rails console and spot-checking records, use ENV variables or SecureRandom for non-production data without committing secrets in code, and use rails credentials:edit for production secrets. Trigger words: seeds, fixtures, seeding, db:seed, test data.
The file declares its own license as MIT. That is the author’s claim about this one file, and it is not the same thing as the license GitHub reports for the repository, which is listed with the other numbers below.
SKILL.md
3.4 KB, as published. Nobody here has run it
Seed Database
Manage development and test data effectively.
Quick Reference
| Use | Solution |
|---|---|
| Static reference data | db/seeds.rb with find_or_create_by! |
| Test scenarios | FactoryBot in spec/factories/ |
| Complex relationships | Both combined |
HARD-GATE
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
Core Process
- Write idempotent seeds — use
find_or_create_by!so re-runs are safe. - Scope by environment — guard non-production data with
Rails.envchecks. - Run seeds — execute
rails db:seed(orrails db:setupfor a fresh database). - Validate idempotency — run
rails db:seeda second time and confirm no duplicates or errors. - Verify data — open
rails consoleand spot-check expected records exist with correct attributes.
Minimal Inline Example
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.
Extended Resources (Progressive Disclosure)
Load these files only when their specific content is needed:
- EXAMPLES.md — Use when you need complete seeding examples with environment-specific patterns and FactoryBot factory definitions
- references/workflow.md — Use when implementing complex seeding workflows or migration-dependent seed data
Output Style
- Use idiomatic Rails seeding patterns.
- Structure factories clearly.
- Follow the credential and idempotency rules in HARD-GATE without exception.
- Include verification commands:
rails db:seed, a second idempotency run, and arails consolespot-check. - Language — Must be in English unless explicitly requested otherwise.
Integration
| Skill | When to chain |
|---|---|
| write-tests | When setting up test scenarios |
| review-migration | When ensuring DB schema is aligned |