rails-contexts

Identifies the appropriate Rails layer for given business logic.

7|Updated Mar 22, 2026
One-click install
npx skills add https://github.com/slbug/claude-ruby-grape-rails --skill rails-contexts
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: rails-contexts
Source: https://github.com/slbug/claude-ruby-grape-rails/tree/main/plugins/ruby-grape-rails/skills/rails-contexts
Command: npx skills add https://github.com/slbug/claude-ruby-grape-rails --skill rails-contexts

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Rails projects often struggle to decide the proper layer for business logic, leading to tangled controllers, over‑engineered services, and hidden side‑effects.

Core Features & Use Cases

  • Iron Laws: Enforces rules such as keeping controllers thin, avoiding side‑effecting callbacks, and making authorization explicit.
  • Guidance: Maps common concerns—controllers, services, forms, queries, policies, serializers, and Grape APIs—to their ideal locations.
  • Scenario: When adding a new payment processing feature, the skill recommends whether it belongs in a service object, a policy, or a controller action.

Quick Start

Use the rails-contexts skill to determine the proper placement for a new payment processing feature.

Frequently Asked Questions about rails-contexts

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

FAQPage Schema
Where should business logic go in a Rails application?

Business logic in a Rails application should be placed in the component that matches its concern, such as a service object, policy, form, or query. Mapping logic to its ideal location keeps controllers thin and prevents hidden side-effects.

How do I decide whether to use a service object or a policy for a new Rails feature?

To decide between a service object or a policy, evaluate if the logic handles authorization or execution. Policies manage explicit authorization rules, while service objects encapsulate complex business operations like payment processing workflows.

What are the best practices for keeping Rails controllers thin?

Keeping Rails controllers thin requires enforcing Iron Laws that avoid side-effecting callbacks and make authorization explicit. Move complex operations to dedicated service objects, forms, or queries to suggest proper placement without modifying code.

Does this approach work with Grape API endpoints in Rails projects?

Yes, this approach works with Grape API endpoints by mapping their business logic to ideal locations within typical web and API projects. It provides guidance on whether logic belongs in Grape endpoints, serializers, or underlying service objects.

When should I use serializers in a Rails API architecture?

Serializers should be used in a Rails API architecture when you need to format complex model data for API responses. They act as the ideal location for presentation logic, separating it from controllers and underlying business operations.