mcpField
L
laravel-best-practices

laravel-best-practices

github.com/paulofelipemDevelopment1440 installsUpdated 30w ago
Repository

About laravel-best-practices

A Laravel guidance skill for developers and coding agents, with 40 prioritized rules spanning architecture, security, performance, testing, and deployment. Individual rule files provide explanations and code examples for targeted implementation or review.

Key features

  1. 0140 prioritized Laravel rules
  2. 0210 rule categories
  3. 03Rule-specific code examples
  4. 04Laravel Boost compatibility guidance

Use cases

  1. 01Reviewing Laravel architecture and security
  2. 02Refactoring controllers, services, or models
  3. 03Improving database and query performance

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/paulofelipem/agent-laravel-skills --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.

.gitignore
metadata.json
README.md
AGENTS.md
rules/
_template.md
api-versioning.md
api-use-dto-serialization.md
api-use-interceptors.md
api-use-pipes.md
devops-graceful-shutdown.md
arch-use-repository-pattern.md
arch-avoid-circular-deps.md
arch-single-responsibility.md
db-use-migrations.md
devops-use-config-module.md
arch-use-events.md
db-use-transactions.md
arch-feature-modules.md
db-avoid-n-plus-one.md
devops-use-logging.md
di-avoid-service-locator.md
di-interface-segregation.md
error-handle-queue-errors.md
di-prefer-constructor-injection.md
di-use-interfaces-tokens.md
error-use-exception-handler.md
di-liskov-substitution.md
di-scope-awareness.md
error-throw-http-exceptions.md
micro-use-queues.md

Details

From the project README

Laravel Best Practices

Comprehensive best practices guide for Laravel applications. Contains 40 rules across 10 categories, prioritized by impact to guide automated refactoring and code generation.

When to Apply

Reference these guidelines when:

  • Writing new Laravel controllers, services, or models
  • Implementing authentication and authorization
  • Reviewing code for architecture and security issues
  • Refactoring existing Laravel codebases
  • Optimizing performance or database queries
  • Building microservices or queue-based architectures

Rule Categories by Priority

PriorityCategoryImpactPrefix
1ArchitectureCRITICALarch-
2Dependency InjectionCRITICALdi-
3Error HandlingHIGHerror-
4SecurityHIGHsecurity-
5PerformanceHIGHperf-
6TestingMEDIUM-HIGHtest-
7Database & ORMMEDIUM-HIGHdb-
8API DesignMEDIUMapi-
9MicroservicesMEDIUMmicro-
10DevOps & DeploymentLOW-MEDIUMdevops-

Quick Reference

1. Architecture (CRITICAL)
  • arch-avoid-circular-deps - Avoid circular service provider dependencies
  • arch-feature-modules - Organize by domain/feature, not technical layer
  • arch-single-responsibility - Focused services over "god services"
  • arch-use-repository-pattern - Abstract database logic for testability
  • arch-use-events - Event-driven architecture for decoupling
2. Dependency Injection (CRITICAL)
  • di-avoid-service-locator - Avoid app() helper as service locator
  • di-interface-segregation - Interface Segregation Principle (ISP)
  • di-liskov-substitution - Liskov Substitution Principle (LSP)
  • di-prefer-constructor-injection - Constructor over facade/helper injection
  • di-scope-awareness - Understand singleton/bind/scoped bindings
  • di-use-interfaces-tokens - Bind interfaces to implementations
3. Error Handling (HIGH)
  • error-use-exception-handler - Centralized exception handling
  • error-throw-http-exceptions - Use proper HTTP exceptions
  • error-handle-queue-errors - Handle queue and job errors properly
4. Security (HIGH)
  • security-auth-jwt - Secure authentication with Sanctum/Passport
  • security-validate-all-input - Validate with Form Requests
  • security-use-guards - Authentication guards, gates, and policies
  • security-sanitize-output - Prevent XSS attacks
  • security-rate-limiting - Implement rate limiting
5. Performance (HIGH)
  • perf-service-provider-lifecycle - Proper service provider boot/register lifecycle
  • perf-use-caching - Implement caching strategies
  • perf-optimize-database - Optimize database queries
  • perf-lazy-loading - Lazy collections and route caching
6. Testing (MEDIUM-HIGH)
  • test-use-testcase-refresh-database - Use Laravel TestCase and RefreshDatabase
  • test-e2e-http - HTTP/feature testing with Laravel
  • test-mock-external-services - Mock external dependencies with facades
7. Database & ORM (MEDIUM-HIGH)
  • db-use-transactions - Transaction management
  • db-avoid-n-plus-one - Avoid N+1 query problems with eager loading
  • db-use-migrations - Use migrations for schema changes
8. API Design (MEDIUM)
  • api-use-dto-serialization - API Resources and serialization
  • api-use-interceptors - Middleware for cross-cutting concerns
  • api-versioning - API versioning strategies
  • api-use-pipes - Form Requests for input transformation
9. Microservices (MEDIUM)
  • micro-use-patterns - Message and event patterns
  • micro-use-health-checks - Health checks for orchestration
  • micro-use-queues - Background job processing with queues
10. DevOps & Deployment (LOW-MEDIUM)
  • devops-use-config-module - Environment configuration with config()
  • devops-use-logging - Structured logging with channels
  • devops-graceful-shutdown - Zero-downtime deployments

How to Use

Read individual rule files for detailed explanations and code examples:

rules/arch-avoid-circular-deps.md
rules/security-validate-all-input.md

Each rule file contains:

  • Brief explanation of why it matters
  • Incorrect code example with explanation
  • Correct code example with explanation
  • Additional context and references

Only read AGENTS.md or individual rules/*.md files when you need full implementation detail for a specific rule. Do not load them proactively.

Full Compiled Document

For the complete guide with all rules expanded: AGENTS.md

Laravel Boost Compatibility

If Laravel Boost is installed, the following rules are already covered by its core guidelines and can be skipped:

security-validate-all-input, security-auth-jwt, db-avoid-n-plus-one, db-use-migrations, perf-use-caching, test-use-testcase-refresh-database, devops-use-logging, api-versioning

Comments

Markdown supported