0015-laravel-best-practices

Review Laravel backend code against prioritized best-practice rules.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

It solves the risk of performance regressions, security vulnerabilities, inconsistent patterns, and brittle behavior when writing or refactoring Laravel backend code.

Core Features & Use Cases

It provides a prioritized checklist of Laravel engineering practices across database performance, query construction, caching, validation, security, routing/controllers, architecture patterns, queues/jobs, HTTP client usage, error handling, scheduling, collections, Blade/view guidance, and testing strategies. It is intended for tasks like preventing N+1 queries and unsafe lazy loading, improving query efficiency with eager-loading discipline and advanced query patterns, enforcing mass-assignment protection and authorization, using Form Requests and validated() correctly, applying correct caching and concurrency primitives, and structuring controllers/actions to keep code maintainable. It also supports production readiness by covering pitfalls like retry/timeout mismatches in jobs, safe scheduling behavior in multi-server environments, and correct mail/event/notification dispatch timing around transactions.

Quick Start

Apply the 0015-laravel-best-practices skill to your Laravel change by addressing the relevant rule sections for controllers, models/queries, validation, security, performance, and queue/HTTP concerns.

Frequently Asked Questions about 0015-laravel-best-practices

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

FAQPage Schema
How do I prevent N+1 queries and unsafe lazy loading in Laravel?

To prevent N+1 queries in Laravel, apply eager-loading discipline and follow prioritized rules for query construction. This enforces safe database access patterns and improves backend performance by avoiding lazy loading pitfalls.

What is the best way to enforce mass-assignment protection and authorization in Laravel?

The best way to enforce mass-assignment protection in Laravel is by applying consistent best-practice patterns using Form Requests and policies. This ensures validated inputs and safeguards against security vulnerabilities during controller refactoring.

How do I handle caching and concurrency correctly in Laravel applications?

Handling caching and concurrency in Laravel requires choosing safe caching primitives and following correct transaction structuring. This prevents race conditions and ensures deterministic error handling for backend operations.

Does this Laravel refactoring approach cover queue job mismatches and multi-server scheduling?

Yes, this Laravel refactoring approach covers queue job mismatches and multi-server scheduling. It addresses retry and timeout configurations in jobs and ensures safe scheduling behavior across multiple server environments.

Why should I use Form Requests and validated() in Laravel controllers?

You should use Form Requests and validated() in Laravel controllers to ensure only validated inputs reach your business logic. This enforces consistent validation patterns and hardens backend code against unexpected or malicious data.