Home › Laravel › Laravel 13 rules

Laravel 13 rules

Cursor rules for Laravel 13 apps on PHP 8.3+: Eloquent, Form Requests, policies, queues, Pest tests, and Pint.

CursorLaravel

How to use

Save this as .cursor/rules/laravel.mdc in your repository root, commit it, and your agent will pick it up automatically. Edit the commands to match your project.

Note: Review and test before use. Provided as is, without warranty. See Terms.

.cursor/rules/laravel.mdcDownload  
---
description: Laravel 13 conventions
globs: ["app/**/*.php","routes/**/*.php","database/**/*.php","resources/views/**/*.blade.php"]
alwaysApply: false
---

# Laravel 13

- Generate with Artisan (`php artisan make:model Order -mfsc --policy`, `make:request`, `make:job`) so files land in the right place.
- Controllers stay thin: validate with Form Requests (`authorize()` + `rules()`), authorize with policies (`Gate::authorize('update', $order)` or the `can` middleware), then call an action/service class in `app/Actions` or `app/Services`.
- Responses for APIs via API Resources (`OrderResource`), never raw models.
- Eloquent: define `$fillable` (or guarded) explicitly, casts via the `casts()` method, relationships with return types. Turn on `Model::preventLazyLoading(! app()->isProduction())` and eager load with `with()`.
- Migrations for every schema change; never edit a migration that has run in production.
- Slow work (mail, webhooks, exports) in queued jobs implementing `ShouldQueue`, dispatched `afterCommit()`.
- Config values through `config()`; `env()` only inside `config/*.php`.
- Use typed properties, return types, enums, and readonly classes; strict types where the project uses them.
- Blade escapes by default (`{{ }}`); use `{!! !!}` only for trusted HTML.

## Done when
`./vendor/bin/pint --test`, `./vendor/bin/phpstan analyse` (Larastan, if present), and `php artisan test` (Pest/PHPUnit) pass.

More: all Laravel rules · all Cursor rules

Related rules

Laravel Copilot instructions

GitHub Copilot instructions for Laravel 11+ apps with Eloquent, Pest, and Form Requests.

GitHub CopilotLaravel

Laravel Livewire AGENTS.md

AGENTS.md for Livewire 3+ components in Laravel: properties, validation attributes, computed data, and Alpine.

AGENTS.mdLaravel

Cloudflare Agents SDK rules

Cursor rules for stateful AI agents on Cloudflare (agents package): Durable Object state, SQL, scheduling, and WebSockets.

CursorCloudflare Workers / Hono

Django Ninja API rules

Cursor rules for Django Ninja APIs on Django 5.2: routers, Pydantic schemas, auth, async views, and tests.

CursorDjango

Django REST Framework rules

Cursor rules for Django 5 + Django REST Framework APIs: serializers, viewsets, permissions, and query performance.

CursorDjango

Fastify 5 API rules

Cursor rules for Fastify 5 APIs in TypeScript: plugins and encapsulation, JSON schema validation, hooks, and inject tests.

CursorNode.js / TypeScript

Get new rules weekly

One email a week: fresh rule files, agent tips, and what's changing in Cursor, Claude Code and Copilot. Free, unsubscribe anytime.

Opens the Rulestack Newsletter on beehiiv in a new tab. Or subscribe directly on beehiiv.