laravel-best-practices

Applies Laravel PHP best-practice rules when writing, reviewing, or refactoring backend code.

Updated Aug 14, 2026
One-click install
npx skills add https://github.com/bill80362/laravel-thread-admin --skill laravel-best-practices-bill80362
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: laravel-best-practices
Source: https://github.com/bill80362/laravel-thread-admin/tree/main/.junie/skills/laravel-best-practices
Command: npx skills add https://github.com/bill80362/laravel-thread-admin --skill laravel-best-practices-bill80362

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Laravel offers multiple valid ways to solve the same problem, which leads to inconsistent patterns, N+1 query bugs, security gaps, and unmaintainable controllers. This Skill provides an indexed rulebook of Laravel best practices so code is written and reviewed against consistent, proven conventions. ## Core Features & Use Cases - Indexed Rule Files: Twenty topic-specific rule files covering Eloquent, migrations, validation, routing, queues, caching, security, testing, Blade, scheduling, and architecture. - Consistency-First Guidance: Instructs checking existing codebase patterns before applying any rule, avoiding the introduction of competing conventions. - Code Review Support: Maps concerns like N+1 queries, mass assignment, missing authorization, and queue misconfiguration to concrete incorrect/correct code examples. - Use Case: When refactoring a controller that loads posts with their authors, the Skill directs you to the db-performance rules to add eager loading with with() and prevent lazy loading violations. ## Quick Start Ask the AI to review your Laravel controller, model, or migration for best-practice violations and apply the recommended fixes.

Frequently Asked Questions about laravel-best-practices

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I fix N+1 query problems in Laravel?

Use eager loading with `with()` to load relationships upfront instead of lazy loading inside loops. You can also enable `Model::preventLazyLoading()` in development to throw exceptions when a relationship is accessed without being eager-loaded.

What are Laravel best practices for form validation?

Extract validation into dedicated Form Request classes and type-hint them in controller methods so validation runs automatically. Always use `$request->validated()` for mass operations instead of `$request->all()`.

Does this skill work with my Laravel version?

The rules cover modern Laravel conventions, but version-sensitive APIs should be verified against your installed framework. The skill instructs checking the installed framework or documentation when an API may differ between versions.

How should I configure Laravel queue jobs to avoid duplicate execution?

Set `retry_after` greater than the job's `timeout` so workers do not re-dispatch running jobs. Implement `ShouldBeUnique` for idempotency, use exponential backoff for retries, and always implement a `failed()` handler.

When should I not apply these Laravel rules?

Do not apply a rule when the codebase already follows a different established pattern. Consistency with existing conventions takes priority unless the current pattern has a correctness or security defect.