/clean-code-in-laravel:clean-code-in-laravel [build|refactor|review] [what or which files]from clean-code-in-laravel
Applies Clean Code in Laravel conventions: thin controllers, Actions, DTOs, Form Requests, lean Eloquent models, custom query builders, enums, value objects, idempotent jobs, Policies, and Pest tests. Use when creating, refactoring, or reviewing Laravel code.
Ships in clean-code-in-laravel. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
You are applying the conventions from Clean Code in Laravel by Ahmad Mayahi (https://github.com/ahmadmayahi/clean-code-in-laravel). The goal is code a Laravel team can read in thirty seconds: simple, conventional, typed, tested. These are conventions, not commandments — when the project already has a clear, consistent convention that differs, follow the project and say so.
composer.json for the Laravel and PHP versions and for installed packages (Pest, Larastan, spatie/laravel-data, spatie/laravel-permission, spatie/laravel-query-builder, spatie/laravel-model-states, Horizon, Sanctum). Only use features and packages the project actually has. Do not add a package without asking.CLAUDE.md, AGENTS.md, .claude/rules/, .ai/guidelines/). Project rules win over this skill.| The code... | Goes in | Reference |
|---|---|---|
| Receives HTTP input and returns a response | Thin controller (7 resource methods max; invokable for single actions) | references/controllers-and-routes.md |
| Validates input or authorizes the request | Form Request with a toDto() method | references/form-requests-and-dtos.md |
| Carries typed data between layers | final readonly DTO ({UseCase}Data) | references/form-requests-and-dtos.md |
| Performs a business operation | Action: app/Actions/{Domain}/VerbNounAction.php, one execute() method | references/actions-and-services.md |
| Wraps a reusable capability or third-party API | Service named for the capability (TaxCalculator) | references/actions-and-services.md |
| Has many ordered steps | Pipeline inside an Action | references/actions-and-services.md |
| Prepares page-specific view data | View Model | references/views-and-apis.md |
| Shapes JSON output | API Resource with whenLoaded() | references/views-and-apis.md |
| Runs in the background | Queued, idempotent Job | references/jobs-and-queues.md |
| Decides who may do what | Policy (models) or Gate (everything else) | references/authorization.md |
| Defines data, relationships, casts | Lean Eloquent model with attributes and casts() | references/eloquent-models.md |
| Encapsulates query logic | #[Scope] methods, or a custom builder after ~5 scopes | references/query-builders-and-collections.md |
| Represents a fixed set of values | Backed enum with label() etc. | references/enums-value-objects-and-states.md |
| Represents a domain concept with rules | Immutable value object + custom cast | references/enums-value-objects-and-states.md |
| Changes the schema | Descriptive migration with constraints and indexes | references/database-and-migrations.md |
| Proves behavior | Pest feature test (unit test for pure logic) | references/testing.md |
Read only the reference files relevant to the task. references/core-principles.md and references/modern-laravel-and-php.md apply to every task — skim them first. Other references: naming-conventions.md, webhooks-and-rate-limiting.md, code-quality-and-tooling.md, packages-and-deployment.md (packages, dependency security, CI hardening, deployment).
->can() or Gate::authorize()).Rule::enum(), toDto().DB::transaction() for multi-record writes, events or jobs for side effects.casts(), typed relationships, enum casts, scopes — no business logic.Do not over-apply patterns. A trivial CRUD endpoint with two fields does not need a DTO and an Action; a scope called from the controller is already clean. Match the scale and existing style of the project.
Check the code against the references and report findings grouped by severity:
$request->all()), N+1 queries, non-idempotent jobs, env() outside config, SQL injection, float money, unbounded queries, swallowed exceptions.For each finding give the file and line, what is wrong, why it matters, and a concrete fix (a short code snippet). Acknowledge what is already clean. Do not invent problems to fill the list.
Run what the project has, fix what it reports, and mention anything you could not run:
vendor/bin/pint --dirty
vendor/bin/phpstan analyse --memory-limit=1G
php artisan test --compact
Then re-read your own diff as a reviewer: authorization present, input validated, no N+1, no debug calls left (dd, dump, ray), no unrelated changes, names follow references/naming-conventions.md.
$request->all() to create()/update(); use validated data.env() outside config/.float for money.new a service; inject it. (new is fine for DTOs and value objects.)$casts property, scopeX() methods, app/Http/Kernel.php, job $tries properties) on Laravel 13.references/actions-and-services.md (opens in a new tab)references/authorization.md (opens in a new tab)references/code-quality-and-tooling.md (opens in a new tab)references/controllers-and-routes.md (opens in a new tab)references/core-principles.md (opens in a new tab)references/database-and-migrations.md (opens in a new tab)references/eloquent-models.md (opens in a new tab)references/enums-value-objects-and-states.md (opens in a new tab)references/form-requests-and-dtos.md (opens in a new tab)references/jobs-and-queues.md (opens in a new tab)references/modern-laravel-and-php.md (opens in a new tab)references/naming-conventions.md (opens in a new tab)references/packages-and-deployment.md (opens in a new tab)references/query-builders-and-collections.md (opens in a new tab)references/testing.md (opens in a new tab)references/views-and-apis.md (opens in a new tab)references/webhooks-and-rate-limiting.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub ahmadmayahi/clean-code-in-laravel --plugin clean-code-in-laravelOther plugins' skills for the same job