laravel-conventions
Skill2 starsChanged 3 months agoMITView on GitHub
Follow Laravel conventions before adding routes, controllers, models, validation, or background work. Use when working in a Laravel codebase.
- Reads credentials
- Deletes or force-pushes
2 other projects use a version of this.
Adopted by
Most recently taken up by
- aegntic/compound-engineeringtheir own version, first seen Nov 8, 2026
- techmefr/mentistheir own version, first seen Sep 11, 2026
Other versions2 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 2
- aegntic/compound-engineering★ 1same name
- techmefr/mentis★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository25 other files it gives its agents.
- ai-agent-pr-metadataSkill
- changesets-releaseSkill
- clarify-workSkill
- decompose-to-issuesSkill
- define-doneSkill
- diagnoseSkill
- external-pr-styleSkill
- git-guardrails-claude-codeSkill
- hitl-blockerSkill
- open-code-review-setupSkill
- release-gateSkill
- resolving-merge-conflictsSkill
- review-gateSkill
- subagent-pipelineSkill
- to-prdSkill
- wizardSkill
- workflow-routerSkill
- filament-conventionsSkill
- filament-plugin-firstSkill
- livewire-conventionsSkill
- laravel-securitySkill
- laravel-testingSkill
- php-principlesSkill
- handoverSkill
- roastSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
21 rules. About 0 are common, 17 are distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈17
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 8
Use this when writing or changing Laravel application code.
- Distinctive: line 17
Keep controllers thin; introduce service classes only when the project's existing structure or real complexity warrants them.
- Distinctive: line 18
Use named routes and route helpers for application links and redirects.
- Distinctive: line 19
Check the installed Laravel major version before applying framework structure or API guidance.
- Distinctive: line 23
Use explicit fillable or guarded declarations.
- Distinctive: line 25
Avoid N+1 queries; eager load relationships in resources and controllers.
- Distinctive: line 26
Use database transactions when modifying multiple related records.
- Distinctive: line 42
Never let a migration silently truncate or drop data as a side effect of a schema change (e.g.
- Distinctive: line 46
Create a Form Request for every non-trivial store/update endpoint.
- Distinctive: line 47
Keep rules declarative; extract reusable rules into custom Rule classes.
- Distinctive: line 52
Use API Resources to shape public API responses.
- Distinctive: line 54
Put authorization in policies and validate every request at the boundary.
- Distinctive: line 60
Use feature flags or config values instead of environment checks scattered through code.
- Distinctive: line 65
Use queues with retry limits and failed-job handling.
- Distinctive: line 66
Keep job classes single-purpose and idempotent where possible.
- Distinctive: line 67
Use Horizon for Redis queue visibility and control when it is installed.
- Very specific: line 71
Use php artisan make:<type> --no-interaction for all generated classes (models, requests, jobs, policies, migrations) instead of …
- Distinctive: line 73
Use model factories and focused feature tests for application behavior.
- Very specific: line 77
Run php artisan test --filter=<Name> for affected code.
- Very specific: line 78
Run php artisan route:list and php artisan about after structural changes.
- Very specific: line 79
Run project linting: vendor/bin/pint --dirty (or duster, or project equivalent).
≈ “Common” is an estimate: at least 1 in 5 of the 372,429 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Laravel Conventions
Use this when writing or changing Laravel application code.
Defaults
- Inspect existing routes, models, config, tests, and installed Laravel version before choosing a pattern; match established project conventions where they are sound.
- Eloquent over raw SQL unless the query is too complex for the ORM.
- Form Request classes for all validation; never inline validate in controllers.
config('key')instead ofenv('KEY')outside config files.- Queue jobs (
ShouldQueue) for anything slow, external, or async. - Keep controllers thin; introduce service classes only when the project's existing structure or real complexity warrants them.
- Use named routes and route helpers for application links and redirects.
- Check the installed Laravel major version before applying framework structure or API guidance; Laravel 10, 11, and 12 are not interchangeable.
Models
- Use explicit fillable or guarded declarations.
- Define relationships, casts, and scopes on the model.
- Avoid N+1 queries; eager load relationships in resources and controllers.
- Use database transactions when modifying multiple related records.
Foreign Keys And Migrations
- Match the foreign key column's type exactly to the referenced table's primary key type (
foreignIdforbigIncrements/id(), not a mismatchedunsignedInteger). - Set an explicit
onDelete/onUpdatepolicy (cascade,restrict,nullOnDelete) — don't leave it at the database default. - Index every foreign key column and any column used in a frequent
WHERE/JOIN/ORDER BY; verify withphp artisan schema:dumpor by reviewing the migration diff against the referenced table before merge. - Idempotent job handling on retry is covered in Background Work above — apply it to anything a migration or FK change feeds into a queue.
Production Migration Safety
- Take a database backup immediately before running any migration that drops a column/table, renames a column, or transforms data in place. A destructive migration with no preceding backup is not deployable — document the backup step in the PR or deploy runbook, not just in your head.
php artisan migraterefuses to run against an environment whereapp.envisproductionunless you pass--force. Treat that prompt as a guardrail, not friction to script around — never bake--forceinto a deploy step that isn't gated by its own review/approval (CI job, deploy script) that a human or protected pipeline controls.- For any migration with meaningful table-lock time (adding an index or column to a large table, an unbounded
UPDATEinside a migration) or any downtime-sensitive change, put the app in maintenance mode first:php artisan down --secret=...before,php artisan upafter. Preferphp artisan down --render="errors::503"(or a custom view) over a bare 503, and confirm the app supports zero-downtime alternatives (online DDL tools, additive-then-backfill-then-cleanup migrations) before assumingdownis required. - MySQL DDL (
ALTER TABLE,CREATE TABLE,DROP TABLE) is not transactional — unlike PostgreSQL, a failed statement partway through a multi-statement migration can leave the schema partially applied, and Laravel's migration wrapping transaction will not roll back the already-committed DDL. Keep migrations small and single-purpose (one schema change per migration) so a failure is easy to diagnose and the blast radius is one operation, not five. - Test the migration's
down()locally (php artisan migrate:rollback) before merging, not justup(). Do not ship a migration you can't cleanly reverse; if a migration is genuinely irreversible (e.g. it drops a column with data that isn't recoverable from the backup taken above), leavedown()throwing\RuntimeExceptionwith a one-line explanation instead of a silent no-op, so a future rollback attempt fails loud instead of pretending to succeed. - Never let a migration silently truncate or drop data as a side effect of a schema change (e.g. changing a column type in a way that MySQL will truncate on conversion) without an explicit backup step called out in the PR description or deploy checklist.
Validation
- Create a Form Request for every non-trivial store/update endpoint.
- Keep rules declarative; extract reusable rules into custom Rule classes.
- Authorize inside the request, not the controller.
APIs And Authentication
- Use API Resources to shape public API responses; do not return models directly.
- Authenticate first-party API clients with the project's configured guard; use Sanctum only when its token or SPA-cookie model fits the client.
- Put authorization in policies and validate every request at the boundary.
Configuration
- Centralize environment access in config files.
- Cache config in production; never commit
.envfiles. - Use feature flags or config values instead of environment checks scattered through code.
Background Work
- Dispatch jobs for external API calls, emails, exports, and heavy computations.
- Use queues with retry limits and failed-job handling.
- Keep job classes single-purpose and idempotent where possible.
- Use Horizon for Redis queue visibility and control when it is installed; otherwise follow the project's queue monitoring setup.
Generated Files
- Use
php artisan make:<type> --no-interactionfor all generated classes (models, requests, jobs, policies, migrations) instead of hand-writing boilerplate. - Tests must use disposable storage or a dedicated test database whose name contains
test; never staging, production, or shared operational databases. - Use model factories and focused feature tests for application behavior.
Verification
- Run
php artisan test --filter=<Name>for affected code. - Run
php artisan route:listandphp artisan aboutafter structural changes. - Run project linting:
vendor/bin/pint --dirty(orduster, or project equivalent).
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

