laravel-best-practices

Audit Laravel codebases and refactor controllers, models, migrations, and services to align with best practices.

Updated Mar 26, 2026
One-click install
npx skills add https://github.com/yunusemrgrl/filament-storybook --skill laravel-best-practices-yunusemrgrl
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: laravel-best-practices
Source: https://github.com/yunusemrgrl/filament-storybook/tree/main/.agents/skills/laravel-best-practices
Command: npx skills add https://github.com/yunusemrgrl/filament-storybook --skill laravel-best-practices-yunusemrgrl

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Laravel projects often drift from conventions, leading to inconsistent code, harder maintenance, and longer onboarding. This guide helps teams establish and follow best practices across controllers, models, migrations, services, and routing to maintain quality at scale.

Core Features & Use Cases

  • Consistency First: enforce project-wide Laravel coding standards and patterns to reduce bugs and confusion.
  • Architectural Guidance: promote proper use of Action classes, services, Eloquent patterns, validation, and routing to improve maintainability.
  • Testing & Security Focus: encourage local scopes, casts, policy-based authorization, and robust testing practices to improve reliability.

Quick Start

Audit your Laravel codebase against these guidelines and refactor core areas such as controllers, models, and migrations to align with the documented patterns.

Frequently Asked Questions about laravel-best-practices

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

FAQPage Schema
How do I refactor Laravel controllers to follow best practices for maintainability?

Refactoring Laravel controllers involves moving business logic into dedicated action classes and services, ensuring controllers only handle HTTP requests. This architectural guidance promotes proper validation and routing patterns to improve maintainability and reduce bugs.

What are Eloquent best practices for keeping Laravel model code consistent?

Eloquent best practices include using local scopes for query constraints and defining proper casts for attributes. Enforcing these patterns across your models ensures consistency, reduces bugs, and aligns with standardized Laravel conventions for easier maintenance.

How do I audit a Laravel codebase for architecture and consistency problems?

Auditing a Laravel codebase involves checking controllers, models, migrations, and services against standardized guidelines. This identifies consistency and architecture problems, guiding refactors to align with conventions, Eloquent patterns, validation, and routing practices.

Does this Laravel best practices guide cover testing and security implementation?

Yes, this Laravel best practices guide encourages robust testing architectures and security focus. It enforces specific requirements including policy-based authorization and tested architectures to improve reliability and protect your application.

When do I need to use local scopes and casts in Laravel Eloquent models?

You need local scopes and casts in Laravel Eloquent models when enforcing project-wide consistency. Proper casts manage attribute types, while local scopes encapsulate query constraints, aligning with best practices to reduce bugs and confusion.