laravel-best-practices

Identify Laravel best-practice fixes for performance, security, and architecture.

3|Updated Jan 26, 2025
One-click install
npx skills add https://github.com/michaelnabil230/laravel-starter-kit --skill laravel-best-practices-michaelnabil230
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: laravel-best-practices
Source: https://github.com/michaelnabil230/laravel-starter-kit/tree/main/.agents/skills/laravel-best-practices
Command: npx skills add https://github.com/michaelnabil230/laravel-starter-kit --skill laravel-best-practices-michaelnabil230

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps Laravel developers make better backend decisions by turning scattered framework conventions into clear, actionable guidance for coding, reviewing, and refactoring.

Core Features & Use Cases

  • Performance Guidance: Reduce N+1 queries, improve eager loading, and choose efficient query patterns for large datasets.
  • Security and Validation: Apply mass-assignment protection, authorization, input validation, file upload checks, and safe output escaping.
  • Architecture and Maintainability: Keep controllers thin, extract actions and services, use proper Eloquent patterns, and follow consistent Laravel conventions.
  • Testing and Reliability: Improve test structure, use factories and model assertions, and align queue, mail, events, and scheduling behavior with best practices.
  • Use Case: A Laravel team can use this Skill while reviewing a feature branch to catch query inefficiencies, insecure mass updates, and controller logic that should be extracted into reusable classes.

Quick Start

Ask the Skill to review your Laravel code or design for best-practice issues and recommend concrete improvements.

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 Eloquent?

Fix N+1 query problems in Laravel Eloquent by applying eager loading with the `with()` method, selecting only required columns, and avoiding lazy loading within loops to optimize query performance for large datasets.

What's the best way to secure mass assignment and input validation in Laravel?

Secure mass assignment in Laravel by defining `$fillable` properties on Eloquent models, applying authorization policies, and using form requests for robust input validation and file upload checks.

How do I keep Laravel controllers thin and maintainable?

Keep Laravel controllers thin by extracting complex logic into dedicated action classes and services, following consistent conventions, and ensuring maintainable application structure through proper Eloquent patterns.

Does this Laravel best practices guidance align with existing project conventions?

This Laravel best practices guidance aligns with existing project conventions while enforcing safe Eloquent usage, query optimization, and maintainable architecture across controllers, models, migrations, and jobs.

How do I improve testing and reliability for Laravel queue and event workflows?

Improve Laravel testing and reliability by using factories and model assertions, structuring tests properly, and aligning queue, mail, events, and scheduling behavior with established best practices.

Why does my Laravel code review miss security and performance issues?

Laravel code reviews often miss security and performance issues like query inefficiencies, insecure mass updates, and validation gaps when reviewers lack actionable guidance on framework conventions and safe Eloquent patterns.