← ClaudeAtlas

controller-cleanuplisted

Keep Laravel controllers focused on HTTP orchestration by moving validation, authorization, and business workflows outward.
soden46/syarif-laravel-ai-skills · ★ 4 · AI & Automation · score 78
Install: claude install-skill soden46/syarif-laravel-ai-skills
# Controller Cleanup Use this skill when controllers become difficult to understand, test, or maintain. When a Laravel app has several menus/pages, also use `module-per-menu`: avoid one broad controller for the whole app, and split by menu, page group, or resource boundary. Controllers should stay thin and focused on HTTP orchestration. They should not contain long business workflows, provider payload construction, repeated query logic, or file-processing loops. ## Responsibilities A controller may: - receive route-bound models and requests; - call `$this->authorize()` or rely on middleware/Form Request authorization; - call a Form Request's `validated()` data; - invoke an Action or Service; - return redirects, views, JSON resources, streams, or downloads; - attach session flash messages. A controller should not: - build external provider payloads inline; - contain multi-step write workflows without a transaction boundary; - duplicate validation rules; - hide authorization inside unrelated branches; - contain heavy report/query logic that is reused elsewhere. ## Route Boundaries Keep coarse access requirements visible in routes or route groups. ```php Route::middleware(['auth', 'verified'])->group(function () { Route::resource('records', RecordController::class) ->middlewareFor('index', 'can:viewAny,' . Record::class) ->middlewareFor(['create', 'store'], 'can:create,' . Record::class) ->middlewareFor(['edit', 'update'], 'can:update,recor