laravel:controller-cleanup

Move Laravel controller validation and authorization into Form Requests and business logic into Actions or Services.

Updated Mar 30, 2026
One-click install
npx skills add https://github.com/Patkik/Multi-tenant-SaaS-Catering-V2 --skill laravel-controller-cleanup-patkik
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: laravel:controller-cleanup
Source: https://github.com/Patkik/Multi-tenant-SaaS-Catering-V2/tree/main/.agents/skills/controller-cleanup
Command: npx skills add https://github.com/Patkik/Multi-tenant-SaaS-Catering-V2 --skill laravel-controller-cleanup-patkik

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Reduces controller bloat by enforcing Validation/Authorization in dedicated Form Requests and by moving business logic to small Actions/Services with DTOs.

Core Features & Use Cases

  • Move auth/validation to Form Requests to centralize validation and authorization.
  • Extract business logic to Actions/Services and pass DTOs from Requests to keep controllers thin.
  • Prefer Resource or Single-Action (invokable) controllers to simplify orchestration and testing.
  • Testing: write feature tests for routes and unit tests for Actions/Services.

Quick Start

Create a form request (e.g., StoreUserRequest) and type-hint it in the controller to run validation before the action.

Frequently Asked Questions about laravel:controller-cleanup

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

FAQPage Schema
How do I slim down fat Laravel controllers?

To slim down Laravel controllers, move validation and authorization into dedicated Form Requests and delegate business logic to small Actions or Services using DTOs. This reduces controller bloat and centralizes request handling.

What is the best way to organize Laravel validation and authorization logic?

The best way to organize Laravel validation and authorization is to move them into dedicated Form Request classes. Type-hinting these Form Requests in controller methods ensures validation runs automatically before the action executes.

How do I pass data to Laravel Actions using DTOs?

To pass data to Laravel Actions using DTOs, extract business logic into Actions or Services and pass DTOs directly from the Form Requests. This keeps controllers thin and maintains a structured data flow across requests and actions.

Does this Laravel controller refactoring approach support resource controllers?

Yes, this Laravel refactoring approach supports resource controllers and single-action invokable controllers. Preferring these controller types simplifies orchestration and testing while keeping the controller layer thin.

How do I test Laravel Actions and Form Requests?

To test Laravel Actions and Form Requests, write feature tests for the routes and unit tests for the extracted Actions or Services. This separation makes testing easier by isolating business logic from HTTP request orchestration.

When should I extract Laravel controller logic into separate Actions?

You should extract Laravel controller logic into separate Actions when controllers become bloated with business logic. Moving this logic to small Actions or Services that accept DTOs improves testability and reduces controller bloat.