About laravel-controller-cleanup
A Laravel development skill for keeping controllers focused on request orchestration. It guides developers in separating validation, business logic, and endpoint responsibilities, with tests for each layer.
Key features
- 01Move validation into Form Requests
- 02Extract logic into Actions or Services
- 03Use resource or single-action controllers
- 04Test routes and business logic separately
Use cases
- 01Refactoring controllers with mixed responsibilities
- 02Building CRUD or one-off endpoints
- 03Testing business logic independently
Install
Copy the command and run it in a terminal.
$
npx skills add https:/ / github.com/ noartem/ skills --skill laravel-controller-cleanupAfter installing, type/laravel-controller-cleanupin Claude Code to confirm it loaded.
Details
From the project READMEController Cleanup
Keep controllers small and focused on orchestration.
Move auth/validation to Form Requests
- Create a Request class (e.g.,
StoreUserRequest) and useauthorize()+rules() - Type-hint the Request in your controller method; Laravel runs it before the action
php artisan make:request StoreUserRequest
Extract business logic to Actions/Services
- Create a small Action (one thing well) or a Service for larger workflows
- Pass a DTO from the Request to the Action to avoid leaking framework concerns
final class CreateUserAction {
public function __invoke(CreateUserDTO $dto): User { /* ... */ }
}
Prefer Resource or Single-Action Controllers
- Use resource controllers for standard CRUD
- For one-off endpoints, use invokable (single-action) controllers
Testing
- Write feature tests for the controller route
- Unit test Actions/Services independently with DTOs
Comments
Markdown supported