mcpField
L
laravel:controller-cleanup

laravel:controller-cleanup

github.com/jpcaparasDevelopment157127 installsUpdated 18w ago
Repository

About laravel:controller-cleanup

A Laravel development skill for keeping controllers focused on orchestration. It guides developers in moving validation and authorization into Form Requests and business logic into Actions or Services.

Key features

  1. 01Form Requestへの認証と検証の移動
  2. 02ActionやServiceへのロジック抽出
  3. 03Resourceまたは単一アクションの採用
  4. 04ルートとロジックの個別テスト

Use cases

  1. 01コントローラーの責務を整理
  2. 02フォーム入力の認証と検証
  3. 03ビジネスロジックの単体テスト

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/jpcaparas/superpowers-laravel --skill laravel:controller-cleanup

After installing, type/laravel:controller-cleanupin Claude Code to confirm it loaded.

Details

From the project README

Controller Cleanup

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

Comments

Markdown supported