Skip to content
Deployment
Skill

/laravel-best-practices

Apply this skill whenever writing, reviewing, or refactoring Laravel PHP code. This includes creating or modifying controllers, models, migrations, form requests, policies, jobs, scheduled commands, service classes, and Eloquent queries. Triggers for N+1 and query performance

From plugin
coolify
66k10 skills1 MCP

Claude Code

$ npx -y skills add coollabsio/coolify --skill laravel-best-practices --agent claude-code

SKILL.md

laravel-best-practices.SKILL.md
name: laravel-best-practices
description: "Apply this skill whenever writing, reviewing, or refactoring Laravel PHP code. This includes creating or modifying controllers, models, migrations, form requests, policies, jobs, scheduled commands, service classes, and Eloquent queries. Triggers for N+1 and query performance issues, caching strategies, authorization and security patterns, validation, error handling, queue and job configuration, route definitions, and architectural decisions. Also use for Laravel code reviews and refactoring existing Laravel code to follow best practices. Covers any task involving Laravel backend PHP code patterns."
license: MIT
metadata:
  author: laravel

Laravel Best Practices

Best practices for Laravel, organized as an index of rule files. Each rule file teaches what to do and why. For exact API syntax, verify with `search-docs`.

Consistency First

Before applying any rule, check what the application already does. Laravel offers multiple valid approaches, and the best choice is the one the codebase already uses, even if another pattern would be theoretically better. Inconsistency is worse than a suboptimal pattern.

Check sibling files, related controllers, models, or tests for established patterns. If one exists, follow it. Don't introduce a second way. These rules are defaults for when no pattern exists yet, not overrides.

How to Apply

1. Check the changed files, nearby code, project configuration, and relevant tests for established patterns. Deviate only for a correctness or security defect, and call the deviation out. 2. Map every affected concern to the rule index below. Read each mapped rule file before editing. Skip unrelated rule files. 3. Make the smallest coherent change. Keep the application's architecture and naming instead of introducing a second pattern for the same job. 4. Verify version-sensitive Laravel APIs for the installed version with `search-docs`, or inspect the installed framework when it is unavailable. 5. Run the narrowest relevant tests first, then the project's formatting and static-analysis checks when the change warrants them. 6. Re-read the diff against every mapped rule before finishing.

Rule Index

Cross-cutting changes often need more than one rule file.

| Concern | Read | | --- | --- | | Query count, eager loading, indexes, large datasets | [`rules/db-performance.md`](rules/db-performance.md) | | Subqueries, aggregates, complex ordering and query plans | [`rules/advanced-queries.md`](rules/advanced-queries.md) | | Models, relationships, scopes, casts | [`rules/eloquent.md`](rules/eloquent.md) | | Authentication, authorization, input safety, secrets, uploads | [`rules/security.md`](rules/security.md) | | Form Requests and validation rules | [`rules/validation.md`](rules/validation.md) | | Controllers, route binding, resources, middleware | [`rules/routing.md`](rules/routing.md) | | Schema changes, columns, foreign keys, indexes | [`rules/migrations.md`](rules/migrations.md) | | Jobs, retries, uniqueness, batches, Horizon | [`rules/queue-jobs.md`](rules/queue-jobs.md) | | Cache lifetime, invalidation, locks, memoization | [`rules/caching.md`](rules/caching.md) | | Outbound requests, retries, timeouts, fakes | [`rules/http-client.md`](rules/http-client.md) | | Exceptions, reporting, rendering, log context | [`rules/error-handling.md`](rules/error-handling.md) | | Events and notifications | [`rules/events-notifications.md`](rules/events-notifications.md) | | Mailables and mail assertions | [`rules/mail.md`](rules/mail.md) | | Scheduled tasks and overlap protection | [`rules/scheduling.md`](rules/scheduling.md) | | Collections, lazy iteration, bulk operations | [`rules/collections.md`](rules/collections.md) | | Blade components, attributes, composers | [`rules/blade-views.md`](rules/blade-views.md) | | Environment values and application configuration | [`rules/config.md`](rules/config.md) | | Tests: coverage, factories, fakes, and assertions | the `testing-best-practices` skill | | Naming, helpers, file boundaries, PHP style | [`rules/style.md`](rules/style.md) | | Actions, services, dependencies, application structure | [`rules/architecture.md`](rules/architecture.md) |

Decision Rules

  • Prefer framework features and existing application abstractions over new helpers or dependencies.
  • Avoid speculative abstractions. Extract code when it creates a clear domain boundary, removes meaningful duplication, or makes behavior independently testable.
  • Keep database access out of Blade views and prevent hidden N+1 queries across controllers, resources, jobs, and serialization.
Read more
@coollabsio
Ships withcoolify

An open-source platform to deploy applications, databases, and services on your own servers. Open source & free forever, backed by our philosophy. ![Latest Release Version]( )

66k10 skills1 MCP
Get the whole plugin

Stars on GitHub

Momentum

stars in total
65.5k
Star history of coollabsio/coolify on GitHub, a chart by star-history.com

Other skills on coolify.

configuring-horizon

configuring-horizon

Use this skill whenever the user mentions Horizon by name in a Laravel context. Covers the full Horizon lifecycle: installing…

@coollabsio@coollabsioInstall Skill
fortify-development

fortify-development

ACTIVATE when the user works on authentication in Laravel. This includes login, registration, password reset, email verification,…

@coollabsio@coollabsioInstall Skill
infer-conventions

infer-conventions

Use this skill to analyze how a Laravel application is actually written and record its conventions as shared rules. Trigger when…

@coollabsio@coollabsioInstall Skill
laravel-actions

laravel-actions

Build, refactor, and troubleshoot Laravel Actions using lorisleiva/laravel-actions. Use when implementing reusable action classes…

@coollabsio@coollabsioInstall Skill
livewire-development

livewire-development

Use for any task or question involving Livewire. Activate if user mentions Livewire, wire: directives, or Livewire-specific…

@coollabsio@coollabsioInstall Skill
mcp-development

mcp-development

Use this skill for Laravel MCP development. Trigger when creating or editing MCP tools, resources, prompts, servers, or UI apps…

@coollabsio@coollabsioInstall Skill

More skills from other plugins.

vercel-cli

vercel-cli

Guides deployment, configuration, and troubleshooting with the Vercel CLI. Use when operating Vercel projects or resources…

vercel11d16k
@vercel@vercelInstall Skill
skypilot

skypilot

Use when launching cloud VMs, Kubernetes pods, or Slurm jobs for GPU/TPU/CPU workloads, training or fine-tuning models on cloud…

@skypilot-org@skypilot-orgInstall Skill
pinme

pinme

Use this skill when the user mentions "pinme", or needs to upload files, store to IPFS, create/publish/deploy websites or…

pinme8w3.8k
@glitternetwork@glitternetworkInstall Skill
mlx-serve

mlx-serve

Hook an app, game or script up to the local mlx-serve server for LLM chat, embeddings, image, speech, music, sound effect, video…

mlx-serve11d2.2k
@ddalcu@ddalcuInstall Skill

Questions about laravel-best-practices.

Which coding agents can use laravel-best-practices?
laravel-best-practices installs in Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, OpenCode and Windsurf with the skills CLI, using each agent's flag shown on this page. Flowy's auto-invocation, which fires a skill when your prompt matches, runs in Claude Code only.