mcpField
L
laravel-best-practices

laravel-best-practices

github.com/laravelDevelopment3.7k2.2k installsUpdated 1d ago
Repository

About laravel-best-practices

A rule-based skill for applying Laravel development practices, aimed at contributors changing Laravel applications. It emphasizes matching existing codebase conventions and checking focused rules before making and verifying changes.

Key features

  1. 01Rule index for Laravel concerns
  2. 02Prioritize existing code patterns
  3. 03Guidance for minimal changes
  4. 04Version-aware API verification
  5. 05Focused testing and diff review

Use cases

  1. 01Reviewing a Laravel change before editing
  2. 02Choosing rules for database or routing work
  3. 03Checking tests and code style after a change

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/laravel/boost --skill laravel-best-practices

After installing, type/laravel-best-practicesin Claude Code to confirm it loaded.

Bundled files

References and scripts installed along with SKILL.md.

rules/
advanced-queries.md
architecture.md
blade-views.md
caching.md
collections.md
config.blade.php
db-performance.md
eloquent.md
error-handling.md
events-notifications.blade.php
http-client.md
mail.blade.php
migrations.blade.php
queue-jobs.md
routing.md
scheduling.blade.php
security.blade.php
style.md
validation.md

Details

From the project README

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 several valid approaches. The best choice is the one the codebase already uses, even if another pattern would be better in theory. Inconsistency is worse than a suboptimal pattern.

Check sibling files and 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

  1. 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.
  2. Map every affected concern to the rule index below. Read each mapped rule file before editing. Skip unrelated rule files.
  3. Make the smallest coherent change. Keep the application's architecture and naming instead of introducing a second pattern for the same job.
  4. Verify version-sensitive Laravel APIs for the installed version with search-docs, or inspect the installed framework when search-docs is unavailable.
  5. Run the narrowest relevant tests first, then the project's formatting and static-analysis checks when the change warrants them.
  6. Re-read the diff against every mapped rule before finishing.

Rule index

Cross-cutting changes often need more than one rule file.

ConcernRead
Query count, eager loading, indexes, large datasetsrules/db-performance.md
Subqueries, aggregates, complex ordering and query plansrules/advanced-queries.md
Models, relationships, scopes, castsrules/eloquent.md
Authentication, authorization, input safety, secrets, uploadsrules/security.md
Form Requests and validation rulesrules/validation.md
Controllers, route binding, resources, middlewarerules/routing.md
Schema changes, columns, foreign keys, indexesrules/migrations.md
Jobs, retries, uniqueness, batches, Horizonrules/queue-jobs.md
Cache lifetime, invalidation, locks, memoizationrules/caching.md
Outbound requests, retries, timeouts, fakesrules/http-client.md
Exceptions, reporting, rendering, log contextrules/error-handling.md
Events and notificationsrules/events-notifications.md
Mailables and mail assertionsrules/mail.md
Scheduled tasks and overlap protectionrules/scheduling.md
Collections, lazy iteration, bulk operationsrules/collections.md
Blade components, attributes, composersrules/blade-views.md
Environment values and application configurationrules/config.md
Tests: coverage, factories, fakes, and assertionsthe testing-best-practices skill
Naming, helpers, file boundaries, PHP stylerules/style.md
Actions, services, dependencies, application structurerules/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.

Comments

Markdown supported