From Rails 8 and Hotwire to RSpec, Sidekiq, Sorbet, and dry-rb — everything Ruby developers need to get the most out of Claude Code, with 40+ copy-paste prompts.
Claude Code understands Rails conventions inside-out — from routing and controllers to ActiveRecord associations, migrations, and the new Rails 8 defaults including Solid Queue, Solid Cache, and Propshaft.
N+1 prevention with includes/preload/eager_load, counter caches, complex joins, custom scopes, raw SQL with sanitize_sql, and Arel for dynamic query building.
Reversible migrations, adding indices safely on large tables (algorithm: :concurrently), bulk changes, change_column_null, polymorphic associations, and STI patterns.
Strong parameters, nested resources, concerns, before_action filters, respond_to blocks, API-mode controllers, and Rails 8 authentication generator.
Solid Queue (no Redis background jobs), Solid Cache (DB-backed fragment caching), Solid Cable (DB-backed ActionCable), Propshaft asset pipeline, and the new authentication scaffold.
Channel subscriptions, broadcasting from models and jobs, Turbo Streams over cable, authentication with current_user, and scaling with Redis Pub/Sub or Solid Cable.
PORO service objects, ActiveSupport::Concern for shared model/controller behaviour, policy objects, query objects, and form objects wrapping complex multi-model forms.
Claude Code writes idiomatic test suites — shared examples, FactoryBot factories with traits, request specs, system specs with Capybara, and VCR cassettes for external APIs.
describe/context/it nesting, let/let! memoisation, subject, custom matchers with RSpec::Matchers.define, shared examples via it_behaves_like, and aggregate failures.
Factory inheritance, traits, sequences, lazy attributes, after(:create) hooks, create_list, and association strategies (build vs create) to keep test suite fast.
Feature specs with Capybara + Cuprite (no Selenium), driven_by :cuprite, screenshot-on-failure, login helpers, JS interactions, and testing Hotwire Turbo streams end-to-end.
RSpec doubles, instance_double, class_double, allow/expect on doubles, partial doubles, spy, and when to use Mocha vs RSpec mocks.
Claude Code writes idempotent Sidekiq workers, handles retries correctly, and also understands Rails 8's Solid Queue for when Redis isn't available.
Idempotent perform methods, sidekiq_options retry: 5, custom retry logic with sidekiq_retries_exhausted, unique jobs, scheduled jobs with sidekiq-cron, and Sidekiq Pro batches.
DB-backed queue with no Redis dependency, recurring jobs via config/recurring.yml, concurrency controls, pausing queues, and monitoring via Mission Control Jobs UI.
Switching between Sidekiq and Solid Queue via Active Job, perform_later/perform_now, wait/wait_until, queue priority, and bulk enqueue.
RSpec with sidekiq/testing inline or fake mode, ActiveJob::TestCase, perform_enqueued_jobs, assert_enqueued_with, and testing retry exhaustion.
Claude Code is fluent in all three Hotwire layers: Turbo Drive for navigation, Turbo Frames for partial replacement, Turbo Streams for server-push DOM updates, and Stimulus for sprinkled JavaScript.
Lazy-loaded frames with src attribute, inline editing patterns, replacing only the results section of a search, and avoiding the common Devise redirect pitfall with turbo_frame_tag.
Broadcasting from controllers with respond_to do |f| f.turbo_stream, from jobs via Turbo::StreamsChannel.broadcast_replace_to, and template helpers like turbo_stream.replace.
Lifecycle callbacks (connect/disconnect/initialize), targets, values with type coercion, CSS classes, outlets for cross-controller communication, and lazy controller registration.
Rails 8's native broadcasts_refreshes with Turbo 8 morphing — whole-page refresh that preserves scroll position, retains input focus, and only patches changed DOM nodes.
Claude Code adds Sorbet signatures incrementally, generates RBI stubs for gems, and integrates type checking into your CI pipeline.
sig { params(x: Integer).returns(String) }, T.nilable, T::Array[Model], T.proc.params(arg0: String).returns(T::Boolean), and typed struct values.
Gradual adoption with # typed: false → ignore → true → strict → strong, using T.untyped and T.unsafe as escape hatches while migrating a large codebase incrementally.
Generating RBI files for ActiveRecord models (rails generate sorbet:rails), annotating associations, scopes, and attribute accessors, and running srb tc in CI.
Writing .rbs signature files, using steep type checker, generating stubs with rbs prototype, and integrating with VSCode via the ruby-lsp extension.
Claude Code composes dry-rb pipelines for complex business logic: validation schemas, monadic result types, immutable structs, and dependency injection.
Contract schemas with type coercions (params vs json vs hash schemas), custom predicates, cross-field rules, array schemas, and message customisation.
Result (Success/Failure), Maybe (Some/None), Try for exception wrapping, Do notation for flat monadic pipelines, and pattern matching on outcomes.
Immutable value objects with strict coercion, optional/default attributes, sum types with Types::Strict::String.enum, and nested structs for rich domain models.
Multi-step business logic pipelines with step, map, tee, and check operations, short-circuiting on Failure, composing transactions, and Around middleware.
Bullet gem for N+1 detection, EXPLAIN ANALYZE in console, adding partial indices, covering indices for counter caches, and PostgreSQL-specific optimisations via pg gem.
memory_profiler, allocation_tracer, identifying string object churn, frozen_string_literal: true across the codebase, and Symbol vs String key decisions.
Ractor-safe data sharing, immutable Ractor communication, the Async gem for non-blocking I/O, Fiber.scheduler integration, and when concurrency beats parallelism in MRI.
rack-mini-profiler for page-level flamegraphs, StackProf for CPU sampling, rbspy for profiling without instrumentation overhead, and Skylight/Scout APM integration.
Use these verbatim in Claude Code — each is written to produce production-ready Ruby/Rails code.
Find all N+1 queries in this controller and its views using includes/preload/eager_load. Show the EXPLAIN ANALYZE output before and after, add a Bullet initializer to catch regressions, and write an RSpec spec that asserts the query count stays under 3.
Use the Rails 8 authentication generator to add email/password auth. Extend it with: email confirmation via token (15-minute expiry), password reset flow, remember-me cookie (30 days), and rate-limiting login attempts with rack-attack (5 attempts per 20 seconds per IP).
Write a reversible migration that adds a NOT NULL column to a 10M-row table safely: add nullable, backfill in batches of 1000 with sleep(0.05) between batches, then add NOT NULL constraint using PostgreSQL's NOT VALID + VALIDATE CONSTRAINT approach to avoid locking the table.
Create a form object (PORO, include ActiveModel::Model) for a checkout form that creates an Order, OrderItems, and Address in a single transaction. Add validations on each, wrap in ApplicationRecord.transaction with a rollback on any failure, and write RSpec model + controller specs.
Add a GraphQL endpoint using graphql-ruby with: query for paginated products (Relay cursor pagination), mutation for creating an order with line items, N+1 prevention using dataloader, authentication via context[:current_user], and rate limiting per user. Write RSpec specs using graphql-ruby's spec helpers.
Write complete RSpec coverage for this service class: model specs for validations and associations, service spec with mocked external dependencies, request spec for the API endpoint, and a system spec with Capybara that tests the UI flow end-to-end. Use FactoryBot with traits for test data.
Add VCR cassettes for all specs that hit the Stripe API. Configure record: :none in CI (raise on missing cassette), record: :new_episodes locally, filter the Stripe secret key from cassettes, and add a Rake task to refresh all cassettes against the Stripe test environment.
Extract shared RSpec examples for "acts as soft-deletable" (has deleted_at, .only_deleted scope, .with_deleted scope, #restore! method) and "acts as auditable" (creates AuditLog on create/update/destroy). Apply them to User and Order models.
Add an RSpec performance spec using rspec-benchmark that asserts the OrdersController#index action stays under 50ms for 1000 records, uses perform_under matcher, seeds data with FactoryBot.create_list, and runs only when PERF_SPECS=1 env var is set.
Create an idempotent Sidekiq worker that processes webhook events: check for duplicate event IDs using Redis SET NX with 24h TTL, parse the payload, update the database, emit a domain event, retry up to 5 times with exponential backoff, and log to structured JSON. Write RSpec using sidekiq/testing fake mode.
Implement a batch CSV import using Sidekiq Pro batches: a parent BatchImportJob that reads S3 and enqueues child ItemImportJob for each row, tracks progress via Sidekiq batch callbacks, upserts using activerecord-import in chunks of 500, and sends a completion email when all children succeed.
Migrate our Active Job queues from Sidekiq to Solid Queue (Rails 8): add the gem, run the migration generator, configure recurring jobs in config/recurring.yml, set up Mission Control Jobs for monitoring, and update the Procfile to use the solid_queue supervisor process instead of Sidekiq.
Build a live product search with Hotwire: Stimulus controller that debounces input by 300ms, issues a Turbo Frame GET request to /products?q=, replaces only the results turbo-frame, shows a loading spinner during fetch via CSS class toggling, announces result count to screen readers with aria-live, and writes a Capybara system spec.
Implement inline record editing using Turbo Frames: clicking a field replaces a frame with an frame (form), submitting sends a PATCH and responds with turbo_stream.replace back to show mode on success or turbo_stream.replace with errors on failure. Add optimistic UI via a pending CSS class during save.
Add real-time order status updates using Turbo Streams over ActionCable: subscribe from the order show page using turbo_stream_from, broadcast from an OrderStatusJob using Turbo::StreamsChannel.broadcast_replace_to, authenticate the cable connection using signed stream name, and write a system spec with Capybara that asserts the status badge updates without a page refresh.
Enable Turbo 8 morphing for our dashboard: add broadcasts_refreshes to the Dashboard model, configure Turbo.session.drive = false for forms that shouldn't trigger morphing, add data-turbo-permanent to the sidebar to preserve state across refreshes, and test that the scroll position is maintained after a live update.
Migrate this service class to Sorbet strict typing: add sig blocks to all public methods, use T.nilable for optional returns, type the params hash with T::Hash[Symbol, T.untyped], run srb tc and fix all type errors, update CI to fail on Sorbet errors, and generate RBI stubs for any untyped gems.
Refactor this fat controller action into a dry-transaction pipeline: step :validate (dry-validation schema), step :authorize (pundit policy check returning Failure on deny), step :persist (ActiveRecord wrapped in Result), step :notify (Sidekiq enqueue), step :track (analytics event). Handle each Failure type distinctly in the controller and write RSpec specs for each step in isolation.
Create dry-struct value objects for Money (amount_cents: Integer, currency: String), Email (value: String with format validation), and PhoneNumber. Add custom coercions, equality by value, and serialize/deserialize for ActiveRecord using composed_of or custom attribute types. Write RSpec specs for edge cases.
Profile this Rails controller action: add rack-mini-profiler with Flamegraph, identify the slowest SQL queries using EXPLAIN (ANALYZE, BUFFERS), add missing indices, convert any N+1 to includes, cache the result with Rails.cache.fetch keyed by a cache_key_with_version, and add an RSpec spec that asserts query count stays under 5.
Run a memory profiler on this CSV export action using the memory_profiler gem: identify the top 10 object allocations by class, add frozen_string_literal: true to the file, switch from Array to lazy Enumerator for streaming, use find_each instead of all for the ActiveRecord query, and measure before/after RSS with ab or wrk.
Design a caching strategy for the /products page: HTTP cache headers (stale-while-revalidate), Russian-doll fragment caching in the view using cache/touch, counter caches for product counts, low-level Rails.cache.fetch for expensive computations, and cache invalidation on model callbacks. Use Solid Cache for the cache store (Rails 8 default).