β All skills
Rails Expert
Use when building full-stack Rails 7+ applications with Hotwire, ActiveRecord patterns, Turbo, and Stimulus.
About this skill
Use when building full-stack Rails 7+ applications with Hotwire, ActiveRecord patterns, Turbo, and Stimulus.
SKILL.md
rails-expert.SKILL.mdPlace it in your Syntic skills folder. For Syntic Code, install in your local skills directory, review the contents and run it in a controlled environment first.
---
name: Rails Expert
description: Use when building full-stack Rails 7+ applications with Hotwire, ActiveRecord patterns, Turbo, and Stimulus.
category: Languages
version: 1.0.0
tools: []
---
# Rails 7+ Development
Build applications using Rails 7+ conventions, Hotwire for interactivity, and ActiveRecord patterns that scale.
## Core Principles
- Follow Rails conventions; if fighting the framework, reconsider the approach
- Use Hotwire first: Turbo and Stimulus before reaching for JavaScript frameworks
- Keep models focused on associations, validations, scopes; extract business logic to service objects
- Every foreign key and `WHERE` column gets an index; database indexes are not optional
## Project Conventions
```
app/
controllers/ # Thin controllers, one action per concern
models/ # ActiveRecord models, validations, scopes
services/ # Business logic (PlaceOrderService, SendNotificationService)
queries/ # Complex query objects
views/ # ERB templates with Turbo Frames
components/ # ViewComponent classes for reusable UI
jobs/ # ActiveJob background processors
```
## ActiveRecord Patterns
- Use scopes for reusable query fragments: `scope :active, -> { where(status: :active) }`
- Use `has_many :through` for many-to-many relationships; avoid `has_and_belongs_to_many`
- Use `counter_cache: true` on `belongs_to` for frequently counted associations
- Use `find_each` or `in_batches` for large datasets; never load entire tables
- Enable `config.active_record.strict_loading_by_default` to catch N+1 queries in development
- Use `strong_migrations` gem; verify safety before using `safety_assured` blocks
## Hotwire Stack
- Use Turbo Drive for SPA-like navigation without JavaScript
- Use Turbo Frames to update specific page sections: `<turbo-frame id="user_profile">`
- Use Turbo Streams for real-time updates: `broadcast_append_to`, `broadcast_replace_to`
- Use Stimulus for small JavaScript behaviors: toggles, form validation, clipboard copy
- Use `turbo_stream.erb` response templates for multi-target updates
## Background Jobs & Testing
- Use Sidekiq with Redis for background processing; configure `config.active_job.queue_adapter = :sidekiq`
- Make every job idempotent; design for at-least-once execution
- Use separate queues: `default`, `mailers`, `critical`, `low_priority`
- Set `retry: 5` with exponential backoff; move to dead letter queue after exhaustion
- Use RSpec with `factory_bot` and `shoulda-matchers`
- Use `VCR` or `WebMock` for external HTTP mocking; never hit real APIs in tests
- Use `DatabaseCleaner` with transaction strategy for speed
## Performance & Security
- Use `includes` for eager-loading; use `bullet` gem to detect N+1 queries
- Cache view fragments: `cache [user, user.updated_at]` with `touch: true`
- Use `Rails.cache.fetch` for expensive computations
- Profile with `rack-mini-profiler` and `memory_profiler` gems
- Run `bundle exec brakeman` for security vulnerability scanning
## Before Completing
- Run `bundle exec rspec` to verify specs pass
- Run `bundle exec rubocop` for code style compliance
- Run `bin/rails db:migrate:status` to verify migration state
- Run `bundle exec brakeman` for security scanning
Install
Syntic App
- 1Create a dedicated folder for this skill in your local skills library.
- 2Place SKILL.md into that folder.
- 3Restart Syntic and invoke this skill on matching tasks.
Syntic Code (CLI)
- 1Save SKILL.md in your local Syntic Code skills directory.
- 2Keep related files in the same skill folder.
- 3Run in a safe environment and validate outputs.