laravel:controller-cleanup

Refactor Laravel controllers using Form Requests, Actions or Services, and DTOs.

1|Updated Sep 22, 2025
One-click install
npx skills add https://github.com/meistro57/chat_bridge --skill laravel-controller-cleanup
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: laravel:controller-cleanup
Source: https://github.com/meistro57/chat_bridge/tree/main/.claude/skills/controller-cleanup
Command: npx skills add https://github.com/meistro57/chat_bridge --skill laravel-controller-cleanup

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill addresses controller bloat in Laravel applications by promoting best practices that lead to cleaner, more maintainable, and testable code.

Core Features & Use Cases

  • Form Request Integration: Offloads authorization and validation logic from controllers.
  • Action/Service Extraction: Encourages the separation of business logic into dedicated classes.
  • DTO Usage: Facilitates clean data transfer between layers.
  • Controller Specialization: Promotes the use of resource or single-action controllers.
  • Use Case: Refactor a large UserController with complex validation and user creation logic into a StoreUserRequest, a CreateUserAction, and a leaner controller.

Quick Start

Refactor the current controller to use Form Requests for validation and extract business logic into a separate action class.

Frequently Asked Questions about laravel:controller-cleanup

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

FAQPage Schema
How do I refactor a bloated Laravel controller?

To refactor a bloated Laravel controller, extract validation into Form Requests, move business logic to Action or Service classes utilizing DTOs, and adopt resource or single-action controller patterns. This reduces controller bloat and enhances testability.

What is the best way to organize Laravel controllers and services?

The best way to organize Laravel controllers is by extracting business logic into dedicated Action or Service classes and using Data Transfer Objects for clean data transfer between layers. This separation creates leaner, specialized controllers.

How do Form Requests reduce Laravel controller bloat?

Form Requests reduce Laravel controller bloat by offloading authorization and validation logic from the controller into dedicated request classes. This keeps controllers focused on orchestration rather than data validation rules.

When should I use single-action controllers in Laravel?

Use single-action controllers in Laravel when a controller handles only one specific action, promoting controller specialization. This pattern fits well with extracted Actions and DTOs, resulting in cleaner, more maintainable code.

How do I pass data between Laravel controllers and services?

Pass data between Laravel controllers and services using Data Transfer Objects. DTOs facilitate clean data transfer between layers, ensuring typed structured data flows from controllers to extracted Action or Service classes.

Can I use DTOs with extracted Laravel Actions for better testability?

Yes, using DTOs with extracted Laravel Actions improves testability by isolating business logic into dedicated classes with structured data inputs. This allows you to test Actions independently of the controller and HTTP request lifecycle.