Keep controllers small and focused on orchestration.
Move auth/validation to Form Requests
Create a Request class (e.g., StoreUserRequest) and use authorize() + 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
1---2name: laravel-controller-cleanup3description: Controller Cleanup4---5# Controller Cleanup67Keep controllers small and focused on orchestration.89## Move auth/validation to Form Requests1011- Create a Request class (e.g., `StoreUserRequest`) and use `authorize()` + `rules()`12- Type-hint the Request in your controller method; Laravel runs it before the action1314```15php artisan make:request StoreUserRequest16```1718## Extract business logic to Actions/Services1920- Create a small Action (one thing well) or a Service for larger workflows21- Pass a DTO from the Request to the Action to avoid leaking framework concerns2223```php24final class CreateUserAction {25 public function __invoke(CreateUserDTO $dto): User { /* ... */ }26}27```2829## Prefer Resource or Single-Action Controllers3031- Use resource controllers for standard CRUD32- For one-off endpoints, use invokable (single-action) controllers3334## Testing3536- Write feature tests for the controller route37- Unit test Actions/Services independently with DTOs
Run npx skillmds@latest add comeonoliver/laravel-controller-cleanup in your terminal (requires Node.js), paste this page's agent-chat prompt into Claude, Cursor, or any MCP-connected agent, or download the SKILL.md file and copy it into your agent's skills directory.
Controller Cleanup It is listed under Coding & Dev Tools on SkillMD.
This skill has not completed SkillMD's automated safety review yet. Independent scanners report: SkillSpector: PASS, Skill Scanner: PASS. SkillMD never runs a skill's scripts for you; review the SKILL.md before installing.
This skill is tagged as working with Claude Code, Claude.ai, OpenAI Codex. SKILL.md is an open format, so most agents that read a skills directory can load it too.
Yes. Installing skills from SkillMD is free, and the skill stays under its author's original license.
ComeOnOliver (@comeonoliver) published this skill. Their other Agent Skills are listed on their SkillMD profile.