Agent skill · affaan-m
rails-patterns
Ruby on Rails framework patterns for Rails 7.1+ and 8.x apps. Covers the directory contract, skinny controllers with service objects, form objects, query objects, idiomatic ActiveRecord, background jobs, ViewComponent, Hotwire, and the Rails 8 Solid stack. Use when building or reviewing Rails apps, controllers, models, services, jobs, or views.
What it needs
About 8k tokens when loaded.
What this skill does
Rails Patterns Framework patterns for modern Ruby on Rails applications (Rails 7.1+ and 8.x). Rails is opinionated by design; these are the patterns the community has converged on for apps that stay maintainable past the 50-model mark. This skill is the "how." For the "what" and "when" (the decisions about which pattern to reach for), see the Ruby patterns rules — rules/ruby/patterns.md in this repository, installed as rules/ecc/ruby/patterns.md. When to Activate Building a Rails application (full-stack, API-only, or hybrid) Reviewing a PR that touches app/ or config/ Generating models, controllers, services, or jobs A controller action grows past ~10 lines A model file grows past ~200 lines ActiveRecord queries start appearing in controllers or views Core Concepts The directory contract Rails apps follow a predictable structure. Add directories deliberately, not casually. Avoid app/lib/, app/utils/, app/managers/. If something does not fit the directories above, the design usually needs rethinking, not a new directory. Truly generic code goes in lib/. Skinny controllers Controllers receive a request, delegate to the right object, and render a response. Business logic lives elsewhere. (Per the Ruby patterns rules, extract to a service object when the controller starts carrying multiple responsibilities.) Service objects The default for business operations that touch more than a single model save. Conventions that keep them consistent: Namespace by domain (Invoices::Create), not by suffix (InvoiceCreator). A class method .call delegates to an instance #call. Return a Result object, not a boolean or a bare record, so the caller can branch on success, errors, and the affected record. Wrap multi-record writes in a transaction. Keep each service single-purpose (Invoices::Create, Invoices::MarkPaid), never Invoices::Manager. …
How to use it
Reference it in AdaL, Claude Code, Cursor or any coding agent — nothing to install:
@skills affaan-m/rails-patterns--18bf46