action-controller-best-practices

Refactors large Rails controllers by extracting logic into service, query, and form objects.

3|3|Updated Jan 18, 2026
One-click install
npx skills add https://github.com/CodySwannGT/lisa --skill action-controller-best-practices
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: action-controller-best-practices
Source: https://github.com/CodySwannGT/lisa/tree/main/plugins/lisa-rails/skills/action-controller-best-practices
Command: npx skills add https://github.com/CodySwannGT/lisa --skill action-controller-best-practices

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill addresses the issue of large, complex Rails controller files that become difficult to maintain, refactor, and understand. It helps developers adhere to the principle of "thin controllers."

Core Features & Use Cases

  • Refactoring Large Controllers: Breaks down lengthy controller actions and large controller files into more manageable and reusable components.
  • Applying Design Patterns: Implements patterns like Service Objects, Query Objects, Form Objects, Controller Concerns, and Presenters/Decorators to improve code organization.
  • Use Case: You have a PlayersController with an index action that has over 20 lines of complex filtering and sorting logic, and a create action that handles multiple business rules. This Skill will help you extract that logic into appropriate classes.

Quick Start

Use the action-controller-best-practices skill to refactor the PlayersController to extract business logic into service objects.

Frequently Asked Questions about action-controller-best-practices

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

FAQPage Schema
How do I refactor a Rails controller with complex business logic?

To refactor a Rails controller with complex business logic, this Skill extracts lengthy action logic into design patterns like service objects, query objects, and form objects to restore the "thin controller" principle and improve maintainability.

When should I extract service objects from Rails controllers?

You should extract service objects from Rails controllers when actions exceed approximately ten lines, contain multiple business rules, or include custom non-RESTful actions that make the file difficult to understand and maintain.

What is the best way to organize a Rails controller with filtering and sorting logic?

The best way to organize a Rails controller with filtering and sorting logic is to apply query objects and presenters, moving the heavy data retrieval and presentation logic out of the controller actions into dedicated, reusable classes.

Can I use controller concerns to slim down large Rails controller files?

Yes, you can use controller concerns to slim down large Rails controller files. This Skill applies concerns alongside form objects and service objects to break down complex controllers into clean, manageable components.

Does this Rails controller refactoring approach work for non-RESTful actions?

Yes, this Rails controller refactoring approach explicitly handles non-RESTful actions by extracting their custom logic into appropriate design patterns such as service objects, ensuring the controller remains clean and organized.