laravel-code-quality
/laravel-code-quality
Use when writing, reviewing or cleaning up Laravel PHP for quality and safety rather than layout — formatting with Pint, one-line method signatures, named arguments, the few-comments rule and when PHPDoc is allowed, naming and types, readable conditionals (guard clauses, named conditions, elseif, match), private methods over single-use classes; security (fail-closed authorization, routes inside auth groups, file-route permissions, row-level visibility, Form Request validation, one-value-or-list fields, mass assignment, bound raw SQL, XSS, secrets and env(), throttle keys, random_int, signed pu
- Author
- haythamasalama ↗
- Repository
- skills ↗
- Licence
- MIT
- Last repository change
- 04.11.2026
Assessment and security
- Files in this package
- 8
- Scripts
- 0
- HTML comments
- 0
- URLs in SKILL.md
- 0
No signals detected. Repository changed on 04.11.2026, without references to retired models or APIs.
MIT, open: use and modify while retaining author attribution.
What it does and when to use it
Use when writing, reviewing or cleaning up Laravel PHP for quality and safety rather than layout — formatting with Pint, one-line method signatures, named arguments, the few-comments rule and when PHPDoc is allowed, naming and types, readable conditionals (guard clauses, named conditions, elseif, match), private methods over single-use classes; security (fail-closed authorization, routes inside auth groups, file-route permissions, row-level visibility, Form Request validation, one-value-or-list fields, mass assignment, bound raw SQL, XSS, secrets and env(), throttle keys, random_int, signed pu
Original author description
Use when writing, reviewing or cleaning up Laravel PHP for quality and safety rather than layout — formatting with Pint, one-line method signatures, named arguments, the few-comments rule and when PHPDoc is allowed, naming and types, readable conditionals (guard clauses, named conditions, elseif, match), private methods over single-use classes; security (fail-closed authorization, routes inside auth groups, file-route permissions, row-level visibility, Form Request validation, one-value-or-list fields, mass assignment, bound raw SQL, XSS, secrets and env(), throttle keys, random_int, signed pu
How it works
- TL;DR
- Before you call a change done
- Where each topic lives
- Decided rules that look odd
SKILL.md preview
---
name: laravel-code-quality
description: Use when writing, reviewing or cleaning up Laravel PHP for quality and safety rather than layout — formatting with Pint, one-line method signatures, named arguments, the few-comments rule and when PHPDoc is allowed, naming and types, readable conditionals (guard clauses, named conditions, elseif, match), private methods over single-use classes; security (fail-closed authorization, routes inside auth groups, file-route permissions, row-level visibility, Form Request validation, one-value-or-list fields, mass assignment, bound raw SQL, XSS, secrets and env(), throttle keys, random_int, signed public links); sensitive operations such as refunds, payouts, data exports and access grants (duplicate-submit protection, once-only execution, maker-checker approvals, self-approval, overrides, step-up auth, append-only audit logs, masking, bounded output); tests that guard all of this; the numbered anti-pattern catalogue; the code review report format. Also triggers on "review this diff", "code review", "clean this up", "is this secure", "anti-pattern", "double submit", "approval flow", "audit log", "مراجعة الكود", "جودة الكود", "تنظيف الكود", "التعليقات", "ثغرة", "أمان", "موافقات".
metadata:
summary: "Laravel code style, security, sensitive operations and code review."
tags: laravel, php, security, code-review, clean-code
---
# Laravel code quality
**Read when:** reviewing a diff, finishing a change, or writing code that touches permissions, input,
raw SQL, secrets, audit trails, approvals or anything that must run only once.
**Owns:** style and comments, conditionals, security rules, sensitive-operation patterns, testing rules
for those paths, the anti-pattern catalogue (stable numbers), the review report format and severity.
Written for PHP 8.3+, Laravel 12 and Pest 4 (checked 2026-11-03). Match the codebase first: these are
defaults for new code, not a reason to rewrite working code in an unrelated change.
## TL;DR
- **Pint owns formatting**: `vendor/bin/pint --dirty` on changed files. Never hand-align.
- **One-line method signatures.** Only DTO constructors list one property per line.
- **Named arguments** when a call passes a bare literal or two values that could be swapped unnoticed.
- **Write few comments.** Default to none; keep a 1–2 line WHY a reader would get wrong without it.
- **Readable conditionals:** guard clauses first, named conditions, one `elseif` chain for an exclusive
choice, `match` or a map when branches only pick values.
- **Fail closed.** Deny by default, check on the server every time, record denials. An empty scope
narrows to nothing, never to everything.
- **Every route inside its auth group;** a file or export route checks the linking page's permission.
- **Bind every SQL value.** Identifiers come from an allowlist. `{!! !!}` only through a sanitizer.
- **Secrets never leave**: not in responses, logs, DTOs, errors or the repository. `config()`, not `env()`.
- **Once-only work claims the row atomically;** a form that must not run twice carries a server-issued key.
- **Nobody approves their own request;** nothing is written while a change waits for approval.
- **Audit logs are append-only** and record denials and overrides, without secrets or raw personal data.
- **Never skip or delete a failing test**; never point a test run at a working database.
## Before you call a change done
1. `vendor/bin/pint --dirty`.
2. Run the affected tests (`php artisan test --compact --filter=…`), including a failure path.
3. Read the diff against the [anti-pattern catalogue](references/anti-patterns.md).
4. Run the [comment check](references/code-style-and-comments.md#the-check-before-calling-a-change-done).
5. Security pass for anything touching routes, input, SQL, output, secrets or permissions.
## Where each topic lives
| I'm working on… | Read |
|---|---|
| Formatting, signatures, named arguments, comments, PHPDoc, naming, types, `readonly`, morph types | [code-style-and-comments.md](references/code-style-and-comments.md) |
| An `if`, `elseif`, `match`, ternary or compound condition | [conditionals.md](references/conditionals.md) |
| Routes, permissions, row visibility, validation, mass assignment, raw SQL, XSS, secrets, throttles, public links | [security.md](references/security.md) |
| Refunds, payouts, exports, access grants: duplicate submits, once-only, approvals, overrides, step-up, audit logs, masking | [sensitive-operations.md](references/sensitive-operations.md) |
| The test database, what to test at which layer, fakes, failure paths | [testing.md](references/testing.md) |
| Checking a diff against known mistakes (numbered) | [anti-patterns.md](references/anti-patterns.md) |
| Writing up a review, and what each severity means | [review-output.md](references/review-output.md) |
Cite findings by anti-pattern number (`#40`) and `file:line`; numbers never change. Severity
(🔴 / 🟡 / 🟢) is defined once, in [review-output.md](references/review-output.md#severity).
## Decided rules that look odd
These go against generic Laravel advice on purpose. Do not "fix" them in review.
| Rule | Why |
|---|---|
| Few comments, no docblocks that restate signatures | typed signatures say more; restating comments rot |
| One-line signatures, even long ones | every method scans the same; a signature diff is one line |
| DTO (a `readonly` class that carries data between layers, named `*Data`) properties in `snake_case` | keys match columns and validated input; no mapping layer |
| Static single-operation classes (`final class IssueInvoice { public static function handle() }`) resolve their dependencies with `app()` | a static method cannot take constructor injection; one pattern end to end |
| Methods that read from a module may return Eloquent models instead of read DTOs | a later refactor; never block a change on it (#12) |
| No speculative indexes; never custom-name indexes or constraints | write cost; custom names drift between environments |
| A private method rather than a new single-use class | files earn their place through reuse |
| `$guarded = []` tolerated on existing models whose writes all pass through a DTO | the DTO lists the columns; new user-input models still use `$fillable` |
Files in this package (8)
- SKILL.md 6 KB
- references/anti-patterns.md 18 KB
- references/code-style-and-comments.md 10 KB
- references/conditionals.md 6 KB
- references/review-output.md 3 KB
- references/security.md 16 KB
- references/sensitive-operations.md 12 KB
- references/testing.md 5 KB
Versions
The database has no other skills named laravel-code-quality.
Database snapshot: 13.11.2026 · package version 46ef412e9cdb (SHA-256 digest of the entire package)
Downloads in the last 30 days: 0 · ranking
Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.
Similar skills
- 90laravel-best-practices
Apply this skill whenever writing, reviewing, or refactoring Laravel PHP code. This includes creating or modifying controllers, models, migrations, form requests, policies, jobs, scheduled commands, service classes, and Eloquent queries. Triggers for N+1 and query performance… - 90laravel-best-practices
Apply this skill whenever writing, reviewing, or refactoring Laravel PHP code. This includes creating or modifying controllers, models, migrations, form requests, policies, jobs, scheduled commands, service classes, and Eloquent queries. Triggers for N+1 and query performance… - 100laravel-tooling
Configure Laravel ecosystem with custom Artisan commands, Vite asset bundling, Pint code styling, and Horizon queue monitoring. Use when creating Artisan commands, migrating from Mix to Vite, or configuring Pint code standards. - 100solid-php
Use when applying SOLID principles to Laravel 13 / PHP 8.3+ code — file size limits, interface placement, or PHPDoc enforcement. - 90php-laravel
Build and upgrade PHP/Laravel applications with validated requests, policy authorization and reliable jobs/data access. Use when implementing Laravel routes, Eloquent models or queues; preserve existing project conventions and runtime compatibility. - 100code-quality
PHP and Laravel code quality toolchain — static analysis with Larastan/PHPStan, code style enforcement with Pint, automated refactoring with Rector, baseline management for legacy codebases, and CI pipeline integration via GitHub Actions. Use this skill whenever the user asks to…