rails-architecture

Guide Rails 8 code placement across architectural layers using a decision tree.

1|Updated Jan 8, 2026
One-click install
npx skills add https://github.com/LaunchPadLab/ai-bank --skill rails-architecture-launchpadlab
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: rails-architecture
Source: https://github.com/LaunchPadLab/ai-bank/tree/main/claude/skills/rails-architecture
Command: npx skills add https://github.com/LaunchPadLab/ai-bank --skill rails-architecture-launchpadlab

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

It solves the confusion of where specific Rails code should live, helping you avoid god objects, fat controllers, and hard-to-maintain private abstractions.

Core Features & Use Cases

  • Rails-layer decision tree: Choose the correct layer (controller, model, service, query object, policy, presenter, ViewComponent, job, form, mailer, channel) based on intent like orchestration, querying, authorization, formatting, or async work.
  • Layer interaction flow: Use a clear request-to-response and async/email/realtime flow diagram to keep responsibilities separated.
  • Refactoring and anti-pattern guidance: Recognize over-engineering and common pitfalls (fat controller, callback hell, helper soup, N+1, premature abstraction) and apply targeted fixes.
  • Multi-tenancy defaults & testing strategy: Keep queries scoped through account and map each layer to appropriate test types to prevent regressions.

Quick Start

Tell your AI assistant: “I’m refactoring a Rails 8 feature where a controller action calls multiple models, needs authorization, and triggers background notifications—what layer(s) should each piece go into, and what refactor steps should I take?”

Frequently Asked Questions about rails-architecture

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I decide between using a service object, query object, or policy in Rails 8?

Choosing between a service object, query object, or policy in Rails 8 depends on intent: use service objects for cross-model orchestration, query objects for complex database querying, and policies for authorization. A Rails-layer decision tree maps each piece of logic to its correct architectural layer based on what it does.

What is the best way to refactor a fat controller that calls multiple models and triggers background notifications?

Refactoring a fat controller in Rails involves separating responsibilities by intent: move cross-model orchestration into service objects, push complex queries into query objects, authorize through policies, and dispatch background notifications to async jobs. This layered design keeps controllers thin and code maintainable.

When should I use a presenter vs a ViewComponent for formatting logic in Rails?

Use a presenter for formatting logic and view-specific data transformation, whereas ViewComponents are for reusable UI elements. The Rails layer decision tree guides this selection by matching presentation intent to the appropriate structural abstraction, preventing helper soup and maintaining testable boundaries.

Does this Rails architecture decision tree support multi-tenancy through account scoping?

Yes, the Rails architecture decision tree enforces multi-tenancy defaults by requiring queries to be scoped through the account. This ensures that all data retrieval across models remains isolated per tenant, preventing cross-tenant data leaks and maintaining secure layered design.

How do I avoid callback hell and over-engineering when structuring Rails models?

Avoid callback hell and over-engineering by recognizing these anti-patterns and applying targeted fixes through layered design. Move complex aggregate behavior out of models into appropriate layers like service objects, ensuring Rails conventions are followed first and preventing premature abstraction.

What testing strategy maps to each Rails architectural layer?

The testing strategy maps each Rails architectural layer to appropriate test types to prevent regressions. Controllers, models, service objects, and query objects each receive targeted tests matching their specific responsibilities, ensuring maintainable code and clear testable boundaries across the presentation and business layers.