PHP · Laravel
Laravel rules for Cursor
Eloquent, validation and app structure rules for current Laravel apps.
The rule
Save as .cursor/rules/laravel.mdc. Cursor picks it up on the next request.
.cursor/rules/laravel.mdc
--- description: Laravel application conventions globs: app/**/*.php, routes/**/*.php, database/**/*.php, resources/views/**/*.blade.php, config/**/*.php, tests/**/*.php alwaysApply: false --- - Generate files with php artisan make:* so they land in the right place with the right namespace. - Validate with Form Request classes or $request->validate(); only use validated() data for writes. - Protect against mass assignment with $fillable on every model; never pass $request->all() to create() or update(). - Eager load relations with with() to avoid N+1 queries. - Authorize with policies and Gate, not ad hoc role checks in controllers. - Read settings with config(), never env(), outside the config folder. - Register middleware, exceptions and routing in bootstrap/app.php; there is no HTTP Kernel in current Laravel. - Change the schema only with new migrations; never edit a migration that has already run. - Push slow work (email, external APIs) to queued jobs. - Write Pest or PHPUnit feature tests and run php artisan test before finishing.
How Cursor loads this rule
Read from the frontmatter above, per Cursor's rules documentation.
alwaysApply: falsewithglobs: app/**/*.php, routes/**/*.php, database/**/*.php, resources/views/**/*.blade.php, config/**/*.php, tests/**/*.php: attached automatically when a matching file is in context.- Keep the
.mdcextension. A plain.mdfile in .cursor/rules is ignored by the rules system. - Prefer to generate your own? Type
/create-rulein Agent and describe what you want; Cursor saves the file to .cursor/rules. - Team Rules come first, then Project Rules like this one, then User Rules. Earlier sources win when guidance conflicts.
Cursor rules setup guideCursor Team RulesLet Cursor run commands without asking
Laravel rules for Claude Code, Copilot, Kiro and other agents
The same instructions work as plain Markdown in AGENTS.md, which Codex, Gemini CLI, GitHub Copilot and most other coding agents read.
AGENTS.md (section)
## Laravel - Generate files with php artisan make:* so they land in the right place with the right namespace. - Validate with Form Request classes or $request->validate(); only use validated() data for writes. - Protect against mass assignment with $fillable on every model; never pass $request->all() to create() or update(). - Eager load relations with with() to avoid N+1 queries. - Authorize with policies and Gate, not ad hoc role checks in controllers. - Read settings with config(), never env(), outside the config folder. - Register middleware, exceptions and routing in bootstrap/app.php; there is no HTTP Kernel in current Laravel. - Change the schema only with new migrations; never edit a migration that has already run. - Push slow work (email, external APIs) to queued jobs. - Write Pest or PHPUnit feature tests and run php artisan test before finishing.
Laravel rules for Claude Code.claude/rules/laravel.md
.claude/rules/laravel.md
--- paths: - "app/**/*.php" - "routes/**/*.php" - "database/**/*.php" - "resources/views/**/*.blade.php" - "config/**/*.php" - "tests/**/*.php" --- - Generate files with php artisan make:* so they land in the right place with the right namespace. - Validate with Form Request classes or $request->validate(); only use validated() data for writes. - Protect against mass assignment with $fillable on every model; never pass $request->all() to create() or update(). - Eager load relations with with() to avoid N+1 queries. - Authorize with policies and Gate, not ad hoc role checks in controllers. - Read settings with config(), never env(), outside the config folder. - Register middleware, exceptions and routing in bootstrap/app.php; there is no HTTP Kernel in current Laravel. - Change the schema only with new migrations; never edit a migration that has already run. - Push slow work (email, external APIs) to queued jobs. - Write Pest or PHPUnit feature tests and run php artisan test before finishing.
Laravel rules for GitHub Copilot.github/instructions/laravel.instructions.md
.github/instructions/laravel.instructions.md
--- applyTo: "app/**/*.php,routes/**/*.php,database/**/*.php,resources/views/**/*.blade.php,config/**/*.php,tests/**/*.php" --- - Generate files with php artisan make:* so they land in the right place with the right namespace. - Validate with Form Request classes or $request->validate(); only use validated() data for writes. - Protect against mass assignment with $fillable on every model; never pass $request->all() to create() or update(). - Eager load relations with with() to avoid N+1 queries. - Authorize with policies and Gate, not ad hoc role checks in controllers. - Read settings with config(), never env(), outside the config folder. - Register middleware, exceptions and routing in bootstrap/app.php; there is no HTTP Kernel in current Laravel. - Change the schema only with new migrations; never edit a migration that has already run. - Push slow work (email, external APIs) to queued jobs. - Write Pest or PHPUnit feature tests and run php artisan test before finishing.
Laravel rules for Kiro.kiro/steering/laravel.md
.kiro/steering/laravel.md
--- inclusion: fileMatch fileMatchPattern: ["app/**/*.php", "routes/**/*.php", "database/**/*.php", "resources/views/**/*.blade.php", "config/**/*.php", "tests/**/*.php"] --- - Generate files with php artisan make:* so they land in the right place with the right namespace. - Validate with Form Request classes or $request->validate(); only use validated() data for writes. - Protect against mass assignment with $fillable on every model; never pass $request->all() to create() or update(). - Eager load relations with with() to avoid N+1 queries. - Authorize with policies and Gate, not ad hoc role checks in controllers. - Read settings with config(), never env(), outside the config folder. - Register middleware, exceptions and routing in bootstrap/app.php; there is no HTTP Kernel in current Laravel. - Change the schema only with new migrations; never edit a migration that has already run. - Push slow work (email, external APIs) to queued jobs. - Write Pest or PHPUnit feature tests and run php artisan test before finishing.
Laravel rules for Antigravity.agents/rules/laravel.md
.agents/rules/laravel.md
--- trigger: glob globs: "app/**/*.php, routes/**/*.php, database/**/*.php, resources/views/**/*.blade.php, config/**/*.php, tests/**/*.php" --- - Generate files with php artisan make:* so they land in the right place with the right namespace. - Validate with Form Request classes or $request->validate(); only use validated() data for writes. - Protect against mass assignment with $fillable on every model; never pass $request->all() to create() or update(). - Eager load relations with with() to avoid N+1 queries. - Authorize with policies and Gate, not ad hoc role checks in controllers. - Read settings with config(), never env(), outside the config folder. - Register middleware, exceptions and routing in bootstrap/app.php; there is no HTTP Kernel in current Laravel. - Change the schema only with new migrations; never edit a migration that has already run. - Push slow work (email, external APIs) to queued jobs. - Write Pest or PHPUnit feature tests and run php artisan test before finishing.
Laravel rules for Devin Desktop (Windsurf).devin/rules/laravel.md
.devin/rules/laravel.md
--- trigger: glob globs: app/**/*.php, routes/**/*.php, database/**/*.php, resources/views/**/*.blade.php, config/**/*.php, tests/**/*.php --- - Generate files with php artisan make:* so they land in the right place with the right namespace. - Validate with Form Request classes or $request->validate(); only use validated() data for writes. - Protect against mass assignment with $fillable on every model; never pass $request->all() to create() or update(). - Eager load relations with with() to avoid N+1 queries. - Authorize with policies and Gate, not ad hoc role checks in controllers. - Read settings with config(), never env(), outside the config folder. - Register middleware, exceptions and routing in bootstrap/app.php; there is no HTTP Kernel in current Laravel. - Change the schema only with new migrations; never edit a migration that has already run. - Push slow work (email, external APIs) to queued jobs. - Write Pest or PHPUnit feature tests and run php artisan test before finishing.
Laravel rules for Cline.clinerules/laravel.md
.clinerules/laravel.md
--- paths: - "app/**/*.php" - "routes/**/*.php" - "database/**/*.php" - "resources/views/**/*.blade.php" - "config/**/*.php" - "tests/**/*.php" --- - Generate files with php artisan make:* so they land in the right place with the right namespace. - Validate with Form Request classes or $request->validate(); only use validated() data for writes. - Protect against mass assignment with $fillable on every model; never pass $request->all() to create() or update(). - Eager load relations with with() to avoid N+1 queries. - Authorize with policies and Gate, not ad hoc role checks in controllers. - Read settings with config(), never env(), outside the config folder. - Register middleware, exceptions and routing in bootstrap/app.php; there is no HTTP Kernel in current Laravel. - Change the schema only with new migrations; never edit a migration that has already run. - Push slow work (email, external APIs) to queued jobs. - Write Pest or PHPUnit feature tests and run php artisan test before finishing.
Laravel rules for Continue.continue/rules/laravel.md
.continue/rules/laravel.md
--- name: "laravel" globs: ["app/**/*.php", "routes/**/*.php", "database/**/*.php", "resources/views/**/*.blade.php", "config/**/*.php", "tests/**/*.php"] --- - Generate files with php artisan make:* so they land in the right place with the right namespace. - Validate with Form Request classes or $request->validate(); only use validated() data for writes. - Protect against mass assignment with $fillable on every model; never pass $request->all() to create() or update(). - Eager load relations with with() to avoid N+1 queries. - Authorize with policies and Gate, not ad hoc role checks in controllers. - Read settings with config(), never env(), outside the config folder. - Register middleware, exceptions and routing in bootstrap/app.php; there is no HTTP Kernel in current Laravel. - Change the schema only with new migrations; never edit a migration that has already run. - Push slow work (email, external APIs) to queued jobs. - Write Pest or PHPUnit feature tests and run php artisan test before finishing.
More templates
Get Cursor rules and settings changes by email
When Cursor changes how rules, run modes or settings work, we update these templates from the docs and send a short note. One email a week at most.
Reviewed Oct 20, 2026. Written by AgentAtlas. Adapt it to your codebase before relying on it.