laravel-best-practices
Skill184 starsChanged 2 months agoApache-2.0View on GitHub
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 issues, caching strategies, authorization and security patterns, validation, error handling, queue and job configuration, route definitions, and architectural decisions. Also use for Laravel code reviews and refactoring existing Laravel code to follow best practices. Covers any task involving Laravel backend PHP code patterns.
We split this skill into the rules it gives an agent
8 rules. 2 are common, 5 are distinctive, and 1 is very specific to this project.
2
Common
Most of the 20 edited versions we read keep these.
5
Distinctive
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Common: line 15
Before applying any rule, check what the application already does.
- Common: line 17
Check sibling files, related controllers, models, or tests for established patterns.
- Distinctive: line 21
Check the changed files, nearby code, project configuration, and relevant tests for established patterns.
- Very specific: line 24
Verify version-sensitive Laravel APIs for the installed version with search-docs, or inspect the installed framework when it is unavailable.
- Distinctive: line 25
Run the narrowest relevant tests first, then the project's formatting and static-analysis checks when the change warrants them.
- Distinctive: line 57
Prefer framework features and existing application abstractions over new helpers or dependencies.
- Distinctive: line 58
Avoid speculative abstractions.
- Distinctive: line 59
Keep database access out of Blade views and prevent hidden N+1 queries across controllers, resources, jobs, and serialization.
“Common” is measured: kept by at least 6 in 10 of the 20 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Laravel Best Practices
Best practices for Laravel, organized as an index of rule files. Each rule file teaches what to do and why. For exact API syntax, verify with search-docs.
Consistency First
Before applying any rule, check what the application already does. Laravel offers multiple valid approaches, and the best choice is the one the codebase already uses, even if another pattern would be theoretically better. Inconsistency is worse than a suboptimal pattern.
Check sibling files, related controllers, models, or tests for established patterns. If one exists, follow it. Don't introduce a second way. These rules are defaults for when no pattern exists yet, not overrides.
How to Apply
- Check the changed files, nearby code, project configuration, and relevant tests for established patterns. Deviate only for a correctness or security defect, and call the deviation out.
- Map every affected concern to the rule index below. Read each mapped rule file before editing. Skip unrelated rule files.
- Make the smallest coherent change. Keep the application's architecture and naming instead of introducing a second pattern for the same job.
- Verify version-sensitive Laravel APIs for the installed version with
search-docs, or inspect the installed framework when it is unavailable. - Run the narrowest relevant tests first, then the project's formatting and static-analysis checks when the change warrants them.
- Re-read the diff against every mapped rule before finishing.
Rule Index
Cross-cutting changes often need more than one rule file.
| Concern | Read |
| Query count, eager loading, indexes, large datasets | rules/db-performance.md |
| Subqueries, aggregates, complex ordering and query plans | rules/advanced-queries.md |
| Models, relationships, scopes, casts | rules/eloquent.md |
| Authentication, authorization, input safety, secrets, uploads | rules/security.md |
| Form Requests and validation rules | rules/validation.md |
| Controllers, route binding, resources, middleware | rules/routing.md |
| Schema changes, columns, foreign keys, indexes | rules/migrations.md |
| Jobs, retries, uniqueness, batches, Horizon | rules/queue-jobs.md |
| Cache lifetime, invalidation, locks, memoization | rules/caching.md |
| Outbound requests, retries, timeouts, fakes | rules/http-client.md |
| Exceptions, reporting, rendering, log context | rules/error-handling.md |
| Events and notifications | rules/events-notifications.md |
| Mailables and mail assertions | rules/mail.md |
| Scheduled tasks and overlap protection | rules/scheduling.md |
| Collections, lazy iteration, bulk operations | rules/collections.md |
| Blade components, attributes, composers | rules/blade-views.md |
| Environment values and application configuration | rules/config.md |
| Tests: coverage, factories, fakes, and assertions | the testing-best-practices skill |
| Naming, helpers, file boundaries, PHP style | rules/style.md |
| Actions, services, dependencies, application structure | rules/architecture.md |
Decision Rules
- Prefer framework features and existing application abstractions over new helpers or dependencies.
- Avoid speculative abstractions. Extract code when it creates a clear domain boundary, removes meaningful duplication, or makes behavior independently testable.
- Keep database access out of Blade views and prevent hidden N+1 queries across controllers, resources, jobs, and serialization.
Other versions33 projects use a version of this.
Word for word · 13
- coollabsio/coolify★ 65k100% same
- anonaddy/anonaddy★ 4.9k100% same
- yaojingang/GEOFlow★ 3.8k100% same
- relaticle/relaticle★ 1.8k100% same
- Relaticle/relaticle★ 1.8k100% same
- nasirkhan/laravel-starter★ 1.4k100% same
- WINBIGFOX/TimeScribe★ 913100% same
- trypostit/trypost★ 792100% same
- Dricle/eveil★ 10100% same
- BhargavDetroja/claude-tracker★ 8100% same
3 more not listed
Edited · 15
- Blair2004/NexoPOS★ 1.3k15% same
- whisper-money/whisper-money★ 1.1k98% same
- nunomaduro/laravel-starter-kit★ 88115% same
- m3ue/m3u-editor★ 87015% same
- sparkison/m3u-editor★ 87015% same
- owlchester/kanka★ 35815% same
- gdarko/laravel-vue-starter★ 14415% same
- RiprLutuk/PasPapan★ 8815% same
- felipeArnold/filament-ai-skills★ 915% same
- robiparvez/claude-code-guidelines★ 258% same
5 more not listed
Wrote their own version · 5
- PauloFelipeM/agent-laravel-skills★ 14same name
- rcdelfin/agentkit★ 2same name
- tikhomirov/skills★ 1same name
- davidanthonyn/claude-skills★ 0same name
- pablopetr/claude-skills★ 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.
Used alongsideProjects with it also use passport-development, ai-sdk-development and 3 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
datashamanSkillpassport-development
Develops OAuth2 API authentication with Laravel Passport. Activates when installing or configuring Passport; setting up OAuth2 grants (authorization code, client credentials, personal access tokens, device authorization); managing OAuth clients; protecting API routes with token authentication; defining or checking token scopes; configuring SPA cookie authentication; handling token lifetimes and refresh tokens; or when the user mentions Passport, OAuth2, API tokens, bearer tokens, or API authentication. Make sure to use this skill whenever the user works with OAuth2, API tokens, or third-party API access, even if they don't explicitly mention Passport.
Also in 7 projects that use this
m3ueSkillai-sdk-development
TRIGGER when working with ai-sdk which is Laravel official first-party AI SDK. Activate when building, editing AI agents, chatbots, text generation, image generation, audio/TTS, transcription/STT, embeddings, RAG, vector stores, reranking, structured output, streaming, conversation memory, tools, queueing, broadcasting, and provider failover across OpenAI, Anthropic, Gemini, Azure, Groq, xAI, DeepSeek, Mistral, Ollama, ElevenLabs, Cohere, Jina, and VoyageAI. Invoke when the user references ai-sdk, the `Laravel\Ai\` namespace, or this project's AI features — not for Prism PHP or other AI packages used directly.
Also in 9 projects that use this
datashamanSkilllivewire-development
Use for any task or question involving Livewire. Activate if user mentions Livewire, wire: directives, or Livewire-specific concepts like wire:model, wire:click, wire:sort, or islands, invoke this skill. Covers building new components, debugging reactivity issues, real-time form validation, drag-and-drop, loading states, migrating from Livewire 3 to 4, converting component formats (SFC/MFC/class-based), and performance optimization. Do not use for non-Livewire reactive UI (React, Vue, Alpine-only, Inertia.js) or standard Laravel forms without Livewire.
Also in 8 projects that use this
whisper-moneySkillcashier-stripe-development
Handles Laravel Cashier Stripe integration including subscriptions, webhooks, Stripe Checkout, invoices, charges, refunds, trials, coupons, metered billing, and payment failure handling. Triggered when a user mentions Cashier, Billable, IncompletePayment, stripe_id, newSubscription, Stripe subscriptions, or billing. Also applies when setting up webhooks, handling SCA/3DS payment failures, testing with Stripe test cards, or troubleshooting incomplete subscriptions, CSRF webhook errors, or migration publish issues.
Also in 5 projects that use this
felipeArnoldSkillpennant-development
Use when working with Laravel Pennant the official Laravel feature flag package. Trigger whenever the query mentions Pennant by name or involves feature flags or feature toggles in a Laravel project. Tasks include defining feature flags checking whether features are active creating class based features in `app/Features` using Blade `@feature` directives scoping flags to users or teams building custom Pennant storage drivers protecting routes with feature flags testing feature flags with Pest or PHPUnit and implementing A B testing or gradual rollouts with feature flags. Do not trigger for generic Laravel configuration authorization policies authentication or non Pennant feature management systems.
Also in 4 projects that use this
In this repository33 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- .github/copilot-instructions.mdCopilot instructions
- .cursor/rules/laravel-boost.mdcCursor rule
- configure-nightwatchSkill
- configuring-horizonSkill
- inertia-vue-developmentSkill
- infer-conventionsSkill
- laravel-best-practicesSkill
- pulse-developmentSkill
- socialite-developmentSkill
- tailwindcss-developmentSkill
- testing-best-practicesSkill
- wayfinder-developmentSkill
- configure-nightwatchSkill
- configuring-horizonSkill
- inertia-vue-developmentSkill
- infer-conventionsSkill
- laravel-best-practicesSkill
- pulse-developmentSkill
- socialite-developmentSkill
- tailwindcss-developmentSkill
- testing-best-practicesSkill
- wayfinder-developmentSkill
- configure-nightwatchSkill
- configuring-horizonSkill
- inertia-vue-developmentSkill
- infer-conventionsSkill
- pulse-developmentSkill
- socialite-developmentSkill
- tailwindcss-developmentSkill
- testing-best-practicesSkill
- wayfinder-developmentSkill
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.

