Verification loop for Rails projects: migrations, routes, security, performance, tests with coverage, asset pipeline, and deployment readiness checks before release or PR.
التثبيت
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
Verification loop for Rails projects: migrations, routes, security, performance, tests with coverage, asset pipeline, and deployment readiness checks before release or PR.
Rails Verification Loop
Run before PRs, after major changes, and pre-deploy to ensure Rails application quality, security, and production readiness.
Phase 1: Environment Check
# Verify Ruby version
ruby --version # Should match .ruby-version# Check bundler and gems
bundle --version
bundle outdated
# Verify Rails version
rails --version
# Check for environment variables
ruby -e "puts 'SECRET_KEY_BASE set' if ENV['SECRET_KEY_BASE']; puts 'DATABASE_URL set' if ENV['DATABASE_URL']"# Verify Node.js (for asset pipeline)
node --version
yarn --version # or npm --version
If environment is misconfigured, stop and fix before proceeding.
Route constraints validate parameters (format, id ranges)
No wildcard routes exposing internal actions
CORS configured correctly for API endpoints
RESTful Route Review:
# Good: Standard RESTful routes
resources :postsdo
resources :comments, only: [:index, :create, :destroy]
end# Warning: Too many custom routes
resources :postsdo
member do
post :publish
post :unpublish
post :archive
get :preview
post :restoreendend# Consider: Use state machine or nested resources instead# Bad: Exposing dangerous routes# DELETE /users/:id/destroy_with_data # Should require confirmation
# Run full test suite with SimpleCov
COVERAGE=true bundle exec rspec
# Or with Minitest
COVERAGE=true bundle exec rails test# Run specific test types
bundle exec rspec spec/models/
bundle exec rspec spec/controllers/
bundle exec rspec spec/requests/
bundle exec rspec spec/system/
# Check coverage report
open coverage/index.html
Test Coverage Report:
Total tests: X passed, Y failed, Z skipped
Overall coverage: XX%
Per-component breakdown
Coverage Targets:
Component
Target
Models
90%+
Controllers
80%+
Serializers
85%+
Services/POROs
90%+
Jobs
85%+
Mailers
80%+
Overall
80%+
Test Quality Checks:
All models have unit tests
Controllers have request/integration tests
Happy path and error cases covered
Edge cases tested (nil, empty, boundary values)
Authentication/authorization tested
Background jobs tested
Mailers have tests
Phase 10: Deployment Readiness
# Health check endpoint
curl http://localhost:3000/health
# Should return 200 OK with system status# Database connectivity
bundle exec rails runner "ActiveRecord::Base.connection.execute('SELECT 1')"# Cache connectivity (Redis)
bundle exec rails runner "Rails.cache.write('test', 'value'); puts Rails.cache.read('test')"# Background job processor# Ensure Sidekiq/DelayedJob is running
bundle exec sidekiq -C config/sidekiq.yml &
# Solution: Check for missing gems in production group
bundle exec rails assets:precompile RAILS_ENV=production
# Review error messages for missing gems or Node.js issues
Issue: Database migration fails in production
# Solution: Test migration on production copy
pg_dump production_db | psql staging_db
RAILS_ENV=staging bundle exec rails db:migrate
Issue: Tests pass locally but fail in CI
# Common causes:# 1. Database not reset between runs
bundle exec rails db:test:prepare
# 2. Time zone differences# Add to spec_helper.rb: Time.zone = 'UTC'# 3. Flaky tests (race conditions)# Run with --seed to reproduce: bundle exec rspec --seed 12345
Issue: N+1 queries in production
# Detection: Enable Bullet in production (carefully)# Or use APM tools (New Relic, Scout)# Fix: Use includes/preload# Before: @posts.each { |p| p.user.name }# After: @posts.includes(:user).each { |p| p.user.name }
Issue: Memory bloat in background jobs
# Solution: Process in batches
User.find_in_batches(batch_size: 100) do |batch|
batch.each { |user| process_user(user) }
end
Remember: Automated verification catches common issues but doesn't replace manual code review, staging environment testing, and production monitoring. Always have a rollback plan.