seed-database
Skill26 starsChanged 4 months agoMITView on GitHub
Use when choosing seeds, fixtures, or factories for Rails dev/test data. Seeds must be idempotent. Trigger words: seeds, fixtures, test data, development data.
- Reads credentials
In this repository32 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- apply-code-conventionsSkill
- apply-stack-conventionsSkill
- code-reviewSkill
- create-engine-installerSkill
- create-engineSkill
- document-engineSkill
- extract-engineSkill
- generate-api-collectionSkill
- implement-authorizationSkill
- implement-background-jobSkill
- implement-graphqlSkill
- implement-hotwireSkill
- load-contextSkill
- optimize-performanceSkill
- plan-testsSkill
- rails-featureSkill
- rails-maintenanceSkill
- rails-reviewSkill
- refactor-codeSkill
- release-engineSkill
- review-architectureSkill
- review-engineSkill
- review-migrationSkill
- security-checkSkill
- setup-environmentSkill
- test-engineSkill
- test-serviceSkill
- upgrade-engineSkill
- version-apiSkill
- write-testsSkill
The file
We split this skill into the rules it gives an agent
2 rules. About 0 are common, 2 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 82
Use idiomatic Rails seeding patterns.
- Distinctive: line 84
Follow the credential and idempotency rules in HARD-GATE without exception.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
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 codeCore 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: 'admin@example.com') do |u|
u.role = Role.find_by!(name: 'admin')
u.password = ENV.fetch('DEFAULT_SEED_PASSWORD', SecureRandom.hex(16))
end
endFor 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 |
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

