skills/rails-architecture-patterns/SKILL.md
Provides architectural planning, design decisions, and coordination guidance for Rails applications. Use when planning new features, choosing between design approaches (STI vs polymorphic, service vs concern, monolith vs engine), evaluating system architecture, or deciding which domain skill or agent to delegate to. NOT for implementation details within a single domain (use the domain-specific skill instead).
npx skillsauth add ag0os/rails-dev-plugin rails-architecture-patternsInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Architectural planning frameworks and decision guidance. Coordinate across domain skills and agents.
See patterns.md for detailed decision frameworks. Logic-placement and structural-smell fixes fork on Axis A — see decisions.native.md / decisions.extracted.md.
Before recommending patterns, resolve the project's architecture axes via rails-stack-profiles (once per session):
native / extracted): drives where business logic lives and how structural smells are fixed. See decisions.native.md / decisions.extracted.md.html / api): drives view vs serializer choices and which domain skills apply.Orthogonal facts — test framework, job backend, cache store, auth library — come from the project-conventions fingerprint, not from an architecture axis. Never infer them here.
| Domain | Skill | Agent | Covers | |--------|-------|-------|--------| | Models | rails-model-patterns | rails-model | ActiveRecord, associations, migrations, scopes | | Controllers | rails-controller-patterns | rails-controller | RESTful actions, params, routes, error handling | | API | rails-api-patterns | rails-api | API controllers, serialization, versioning, JWT | | Services | rails-service-patterns | rails-service | Service objects, result pattern, DI, external APIs | | Jobs | rails-jobs-patterns | rails-jobs | ActiveJob, Sidekiq, idempotency, batch processing | | GraphQL | rails-graphql-patterns | rails-graphql | Schema, mutations, DataLoader, subscriptions | | Hotwire | hotwire-patterns | rails-hotwire | Stimulus controllers, Turbo frames/streams | | Views | rails-views-patterns | rails-views | ERB, partials, helpers, caching, accessibility | | Testing | rails-testing-patterns | rails-test | RSpec, Minitest, system/integration tests | | DevOps | rails-devops-patterns | rails-devops | Docker, CI/CD, monitoring, security | | Mailers | rails-mailer-patterns | (skill only) | Action Mailer, previews, delivery, interceptors | | Auth | rails-auth-patterns | (skill only) | has_secure_password, Devise, sessions, password reset | | Caching | rails-caching-patterns | (skill only) | Fragment, low-level, HTTP caching, invalidation | | Refactoring | ruby-refactoring | (skill only) | Code smells, refactoring patterns | | Object Design | ruby-object-design | (skill only) | Class vs module, Struct, Data, design decisions |
| Question | Option A | Option B | Choose A when | Choose B when |
|----------|----------|----------|---------------|---------------|
| Inheritance | STI | Polymorphic | >70% shared columns, same behavior | Different attributes per type |
| Shared logic | Concern | Service Object | Axis A native, or adds a model capability | Axis A extracted, or orchestrates a workflow |
| Background work | ActiveJob | Inline | > 100ms or external call | Fast + must be synchronous |
| Job backend | Solid Queue | Sidekiq | Simple needs, no Redis in stack | Redis already in stack |
| API format | JSON:API | Custom JSON | Public API, many clients | Internal API, simple needs |
| Frontend | Hotwire | SPA (React) | Content-heavy, progressive | Complex interactive UI |
| Auth | has_secure_password | Devise | Simple auth needs | Multi-feature auth needed |
For a typical feature:
1. Migration + Model (rails-model)
2. Routes + Controller (rails-controller or rails-api)
3. Views or Serializer (rails-views or rails-api)
4. Service objects (rails-service) -- if complex logic
5. Background jobs (rails-jobs) -- if async work needed
6. Tests (rails-testing-patterns)
Universal (all projects):
Axis A — native:
Axis A — extracted:
Axis B — api:
## Architecture Plan: [feature_name]
**Stack Axes:** logic=[native | extracted], delivery=[html | api]
**Layers Involved:** Models, Controllers, Services, Tests
**Implementation Steps:**
1. [step] -- delegate to [skill/agent]
2. ...
**Design Decisions:**
- [decision]: [rationale]
**Risks:**
- [risk]: [mitigation]
development
WHAT: Language-agnostic corrective guidance for the refactoring phase. WHEN: Agent is restructuring code, fixing code smells, reducing complexity, or improving maintainability. NOT FOR: Writing new features, debugging runtime errors, performance tuning, or object design decisions.
tools
Analyzes Rails view templates, partials, layouts, helpers, and form patterns for best practices. Use when reviewing ERB templates, improving view performance with fragment caching, fixing form helpers, organizing partials, adding accessibility attributes, or evaluating collection rendering. NOT for Stimulus/Turbo logic (use hotwire-patterns), controller concerns, or API-only responses.
testing
Analyzes Rails test suites and recommends testing best practices for RSpec and Minitest. Use when writing new tests, reviewing test coverage, fixing flaky tests, improving test performance, choosing between test types (unit, integration, system, request), or setting up factories and fixtures. NOT for production monitoring, deployment verification, or load/stress testing infrastructure.
development
Detects a Rails project's architecture axes — logic placement (native vs extracted) and delivery (html vs api) — so other skills load profile-appropriate guidance without inline conditionals. Use when planning architecture or when a recommendation depends on where business logic lives or whether the app renders HTML or serves JSON. NOT for test framework, job backend, cache store, or auth library choices — those are orthogonal facts detected by project-conventions.