ruby-rails
Skill0 starsChanged 5 months agoMITView on GitHub
Use for Ruby on Rails 7+ apps — ActiveRecord, Action Mailer, Sidekiq, Hotwire (Turbo/Stimulus), RSpec/Minitest. Triggers — Gemfile, bin/rails, models/controllers/migrations, or just 'Ruby'.
2 other projects use a version of this.
Adopted by
Most recently taken up by
- matthull/my-skillstheir own version, first seen Oct 20, 2026
- Mindrally/skillstheir own version, first seen Oct 8, 2026
Other versions2 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 2
- Mindrally/skills★ 275same name
- matthull/my-skills★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository74 other files it gives its agents.
- AGENTS.mdAGENTS.md
- wiki/Agents.mdAGENTS.md
- .claude/CLAUDE.mdCLAUDE.md
- .github/copilot-instructions.mdCopilot instructions
- .cursor/rules/000-claude-os.mdcCursor rule
- .cursor/rules/desktop.mdcCursor rule
- .cursor/rules/mobile.mdcCursor rule
- .cursor/rules/skills-index.mdcCursor rule
- .cursor/rules/web.mdcCursor rule
- ai-mlSkill
- analyticsSkill
- api-designSkill
- architectureSkill
- awsSkill
- azureSkill
- backendSkill
- blockchainSkill
- browser-extensionSkill
- clickhouseSkill
- cliSkill
- cloudflareSkill
- data-modelingSkill
- data-platformSkill
- desktopSkill
- devopsSkill
- discoverySkill
- docker-kubernetesSkill
- documentationSkill
- dotnetSkill
- firebaseSkill
- flutterSkill
- gameSkill
- gcpSkill
- go-backendSkill
- godotSkill
- headless-automationSkill
- iot-embeddedSkill
- java-springSkill
- mcp-integrationSkill
- memory-managementSkill
- messaging-queuesSkill
- mobileSkill
- mongodbSkill
- mysqlSkill
- native-androidSkill
- native-iosSkill
- node-backendSkill
- observabilitySkill
- paymentsSkill
- performanceSkill
- php-laravelSkill
- postgresSkill
- production-readinessSkill
- project-classificationSkill
- python-backendSkill
- react-nativeSkill
- react-nextSkill
- realtimeSkill
- redisSkill
- requirements-engineeringSkill
- The first 60 shown.
The file
Show its rules and text
We split this skill into the rules it gives an agent
14 rules. About 0 are common, 5 are distinctive, and 9 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈5
Distinctive · estimate
This author's own choices. Worth a look.
9
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 30
Keep controllers thin — one controller action should: permit params → call one service object → render/redirect.
- Distinctive: line 34
Add database-level constraints AND ActiveRecord validations — they are complementary, not redundant.
- Very specific: line 35
Use named scopes (scope :active, -> { where(status: 'active') }) for reusable query fragments.
- Very specific: line 47
Use Sidekiq::Testing.fake!
- Distinctive: line 52
Avoid full-page redirects where a Turbo Stream response keeps the user in context.
- Very specific: line 70
Add counter_cache: true for has_many counts that are queried frequently.
- Very specific: line 71
Avoid where("column = '#{value}'") — always use hash syntax or parameterised strings: where(column: value) or where("column = ?", value).
- Very specific: line 72
Use find_each or in_batches for bulk processing — never .all on a potentially large table.
- Very specific: line 77
Use add_index with algorithm: :concurrently on PostgreSQL for zero-lock index creation.
- Distinctive: line 87
Do not put business logic in controllers or views.
- Very specific: line 88
Do not use update_column (skips validations and callbacks) unless you explicitly need that and document why.
- Very specific: line 89
Do not use Model.all without a limit in application code paths that could return unbounded rows.
- Very specific: line 90
Do not enable config.allow_all_hosts in staging or production.
- Distinctive: line 91
Do not use synchronous HTTP calls in a controller action without a timeout.
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 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
Ruby on Rails Development
When to use
- Scaffolding or extending a Rails 7+ application (full-stack, API-only, or hybrid)
- Designing ActiveRecord models, associations, validations, and callbacks
- Writing database migrations and managing schema changes
- Implementing background jobs with Sidekiq and ActiveJob
- Building reactive UIs with Hotwire (Turbo Frames, Turbo Streams, Stimulus)
- Hardening Rails security defaults (CSRF, CSP, mass-assignment, host authorisation)
- Testing with RSpec + FactoryBot or Minitest
Workflow
- Scaffold with
rails new my-app(full stack) orrails new my-api --api(API-only). For API-only apps add--skip-asset-pipeline --skip-javascript. Use Ruby 3.3+ and Rails 7.2+. - Structure the application:
Keep controllers thin — one controller action should: permit params → call one service object → render/redirect.app/ controllers/ ← Thin: permit params, call service/command, respond models/ ← ActiveRecord: associations, validations, scopes services/ ← Business logic POROs (Plain Old Ruby Objects) jobs/ ← ActiveJob / Sidekiq jobs views/ ← ERB templates + Turbo partials components/ ← ViewComponent for complex UI components (optional) - Define the data model — see
.claude/skills/data-modeling/SKILL.md. Generate migrations withrails generate migration. Follow theYYYYMMDDHHMMSS_verb_noun_on_table.rbnaming convention. - ActiveRecord models:
- Declare
belongs_to,has_many,has_one,has_and_belongs_to_manyrelationships explicitly. - Add database-level constraints AND ActiveRecord validations — they are complementary, not redundant.
- Use named scopes (
scope :active, -> { where(status: 'active') }) for reusable query fragments. - Callbacks (
before_save,after_create) only for concerns tightly coupled to persistence. Side effects (emails, jobs) belong in service objects, not callbacks.
- Declare
- Strong parameters: permit only what is needed in
params.require(:model).permit(:field1, :field2). Neverparams.permit!. Extract a privatemodel_paramsmethod in the controller. - Authenticate and authorise:
- Authentication:
has_secure_password+authenticatefor simple apps; Devise for full auth with email confirmation, 2FA, etc. - Authorisation: Pundit (policy objects, clean
authorize @model) or CanCanCan (ability-based). Never inlineif current_user.admin?in views. - API tokens: Devise Token Auth or JWT via
jwtgem with a server-side allowlist for revocation.
- Authentication:
- Background jobs with Sidekiq + ActiveJob:
- Inherit from
ApplicationJob < ActiveJob::Base; setqueue_as :defaultor:critical. - Jobs must be idempotent — they may run more than once (retry on failure).
- Pass only primitive arguments (IDs, strings) — not ActiveRecord objects (they serialise and may be stale).
- Set
sidekiq_options retry: 5, backtrace: 10on the job class for tuning. - Use
Sidekiq::Testing.fake!in tests; assert withassert_enqueued_with.
- Inherit from
- Hotwire (Turbo + Stimulus):
- Turbo Frames (
<turbo-frame id="…">) for lazy-loading and partial page updates. - Turbo Streams for broadcasting real-time updates via
ActionCableor from controller responses. - Stimulus controllers for JavaScript behaviour scoped to a DOM element — never global jQuery-style selectors.
- Avoid full-page redirects where a Turbo Stream response keeps the user in context.
- Turbo Frames (
- Security defaults:
protect_from_forgeryis on by default for HTML responses — never disable it.- Content Security Policy: configure in
config/initializers/content_security_policy.rb— tightenscript-src,style-src,connect-src. config.hosts(Rails 6.1+): restrict to known hostnames in production;allow_all_hostsis development-only.- Force SSL:
config.force_ssl = trueinproduction.rb. - Sensitive attributes:
has_secure_passwordmanages the digest; never store plain passwords.
- Write tests:
- RSpec: model specs (validations, scopes), request specs (API endpoints), system specs (Capybara for full browser flow).
- FactoryBot for test data — define factories, not fixtures, for flexibility.
database_cleaneroruse_transactional_fixtures: trueto reset state between tests.- VCR (
vcrgem) to record and replay external HTTP interactions in tests.
- Audit against
.claude/checklists/security.mdand.claude/checklists/production.md.
Standards
ActiveRecord
belongs_tois required by default (Rails 5+) — addoptional: trueonly when the FK is genuinely nullable.- Add
counter_cache: trueforhas_manycounts that are queried frequently. - Avoid
where("column = '#{value}'")— always use hash syntax or parameterised strings:where(column: value)orwhere("column = ?", value). - Use
find_eachorin_batchesfor bulk processing — never.allon a potentially large table. - Transactions:
ActiveRecord::Base.transaction { ... }for multi-model writes.
Migrations
- Migrations are immutable once run on shared environments — create new migrations, never edit committed ones.
- Use
add_indexwithalgorithm: :concurrentlyon PostgreSQL for zero-lock index creation; note this requires running the migration outside a transaction (disable_ddl_transaction!). - Column removals: two-step — first deploy ignoring the column, then drop it in the next release (avoids
ActiveRecord::UnknownAttributeError). null: falseanddefault:constraints in migrations for required columns.
Services / POROs
- One public method (typically
call), one responsibility. - Accept dependencies via constructor injection — makes testing with mocks straightforward.
- Raise a typed error (
MyService::Error < StandardError) instead of returningfalsefor failure.
Do not
- Do not put business logic in controllers or views.
- Do not use
update_column(skips validations and callbacks) unless you explicitly need that and document why. - Do not use
Model.allwithout alimitin application code paths that could return unbounded rows. - Do not enable
config.allow_all_hostsin staging or production. - Do not use synchronous HTTP calls in a controller action without a timeout; move to a background job.
Common mistakes to avoid
| Mistake | Fix |
N+1 queries from missing includes | Use includes(:association) or eager_load; detect with bullet gem |
| Callback side-effects (emails, jobs) in ActiveRecord | Move to service objects; trigger from controller after successful save |
params.permit! allowing arbitrary mass assignment | Explicitly whitelist each attribute in permit(...) |
Memory bloat from Post.all on large tables | Use find_each(batch_size: 500) or lazy enumerators |
| Synchronous Sidekiq tests asserting on real queue | Use Sidekiq::Testing.fake! in spec helper; Sidekiq::Testing.drain_all to process inline |
| Missing database-level uniqueness constraint | add_index :users, :email, unique: true plus validates :email, uniqueness: true |
String interpolation in where clauses | Always use where("name = ?", value) or hash syntax to prevent SQL injection |
Output format
- New resource: migration, model with validations and associations, controller with strong params, RSpec request spec.
- Service object: PORO with
callmethod, constructor dependencies, typed error class, and RSpec unit spec. - Background job: ActiveJob class, Sidekiq options, idempotency check, and
assert_enqueued_withtest. - Hotwire interaction: controller action returning
turbo_streamformat, partial template, and Stimulus controller.
Output artifacts go to docs/specs/ for design decisions; code files in app/ tree.
Related checklists
- .claude/checklists/security.md
- .claude/checklists/performance.md
- .claude/checklists/qa.md
- .claude/checklists/production.md
Related agents
- .claude/agents/core/solution-architect.md
- .claude/agents/engineering/backend-engineer.md
- .claude/agents/engineering/database-architect.md
- .claude/agents/quality/security-auditor.md
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.

