CtrlK
BlogDocsLog inGet started
Tessl Logo

igmarin/rails-agent-skills

Curated library of 41 public AI agent skills for Ruby on Rails development. Organized by category: planning, testing, code-quality, ddd, engines, infrastructure, api, patterns, context, and orchestration. Covers code review, architecture, security, testing (RSpec), engines, service objects, DDD patterns, and TDD automation. Repository workflows remain documented in GitHub but are intentionally excluded from the Tessl tile.

95

1.77x
Quality

93%

Does it follow best practices?

Impact

96%

1.77x

Average score across 41 eval scenarios

SecuritybySnyk

Passed

No known issues

Overview
Quality
Evals
Security
Files

EXAMPLES.mdskills/infrastructure/seed-database/

Database Seeding Examples

Complete examples for managing development and test data.

Idempotent Seeds

# db/seeds.rb
# Admin user - idempotent with find_or_create_by!
admin = User.find_or_create_by!(email: 'admin@example.com') do |u|
  u.password = ENV.fetch('DEFAULT_SEED_PASSWORD', SecureRandom.hex(16))
  u.admin = true
  u.confirmed_at = Time.now
end

# Reference data - using first_or_create for lookup tables
['pending', 'processing', 'completed', 'cancelled'].each do |status|
  OrderStatus.find_or_create_by!(name: status)
end

# Bulk creation with validation
if User.count < 10
  10.times do |n|
    User.create_with(
      password: ENV.fetch('DEFAULT_SEED_PASSWORD', SecureRandom.hex(16)),
      confirmed_at: Time.now
    ).find_or_create_by!(email: "user#{n}@example.com")
  end
end

Environment-Specific Seeds

Structure

db/
├── seeds.rb           # Base seeds (always runs)
└── seeds/
    ├── development.rb # Dev-specific (100 fake users)
    ├── test.rb        # Test-specific (minimal data)
    └── staging.rb     # Staging-specific

Auto-Loader

# db/seeds.rb (bottom of file)
# Load environment-specific seeds
env_seed_file = Rails.root.join("db/seeds/#{Rails.env}.rb")
load env_seed_file if env_seed_file.exist?

Development Seeds

# db/seeds/development.rb
puts "Loading development seeds..."

# Load base seeds first
load Rails.root.join('db/seeds.rb')

# Create fake data
require 'faker'

50.times do
  User.create!(
    email: Faker::Internet.unique.email,
    name: Faker::Name.name,
    password: ENV.fetch('DEFAULT_SEED_PASSWORD', SecureRandom.hex(16)),
    confirmed_at: Time.now
  )
end

# Complex relationships
users = User.limit(10)
users.each do |user|
  5.times do
    Post.create!(
      user: user,
      title: Faker::Lorem.sentence,
      body: Faker::Lorem.paragraphs(number: 3).join("\n\n"),
      published_at: [nil, Time.now - rand(30).days].sample
    )
  end
end

FactoryBot Examples

Basic Factory

# spec/factories/users.rb
FactoryBot.define do
  factory :user do
    sequence(:email) { |n| "user#{n}@example.com" }
    password { ENV.fetch('DEFAULT_SEED_PASSWORD', SecureRandom.hex(16)) }
    name { 'Test User' }
    confirmed_at { Time.now }

    trait :admin do
      admin { true }
    end

    trait :unconfirmed do
      confirmed_at { nil }
    end
  end
end

Factory with Associations

# spec/factories/posts.rb
FactoryBot.define do
  factory :post do
    sequence(:title) { |n| "Post #{n}" }
    body { Faker::Lorem.paragraphs.join("\n\n") }
    user

    trait :published do
      published_at { Time.now }
    end

    trait :draft do
      published_at { nil }
    end

    # Create comments with the post
    after(:create) do |post|
      create_list(:comment, 3, post: post)
    end
  end
end

Using Factories in Seeds

# db/seeds/development.rb
# Mix of factories and manual creation
admin = FactoryBot.create(:user, :admin, email: 'admin@example.com')
regular_users = FactoryBot.create_list(:user, 10)

# Create posts for each user
regular_users.each do |user|
  FactoryBot.create_list(:post, 3, :published, user: user)
  FactoryBot.create_list(:post, 2, :draft, user: user)
end

Fixtures vs Factories Decision Guide

ScenarioRecommendation
Static reference data (roles, statuses)Seeds with find_or_create_by!
Complex relationshipsFactoryBot
Performance-critical testsFixtures
Integration testsFactories for realism
Unit testsFactories for isolation

Troubleshooting

Reset Database

# Full reset
rails db:drop db:create db:migrate db:seed

# Quick reset (keep structure)
rails db:seed:replant

Debug Seed Failures

# db/seeds.rb
begin
  User.create!(email: 'test@example.com')
rescue ActiveRecord::RecordInvalid => e
  puts "Failed to create user: #{e.message}"
  puts e.record.errors.full_messages
end

skills

infrastructure

seed-database

README.md

server.json

tile.json