CLAUDE.md template for Laravel applications
A ready-to-fill CLAUDE.md for Laravel projects that gives Claude Code the commands, conventions and guardrails it needs: tests with Pest or PHPUnit, Pint, migrations, Form Requests, policies, queues and config caching rules.
File in Engineering by AISkillHub Library
What it does
Claude Code reads `CLAUDE.md` at the start of every session in a repository. A good one saves you from repeating the same corrections: which test command to run, where validation lives, that `env()` must not be called outside config files. This template covers the conventions most Laravel teams already follow, written as direct instructions.
**What it covers** - Exact commands for tests, formatting (Laravel Pint), static analysis (Larastan, if installed), frontend builds and queues. - Code conventions: Form Requests for validation, policies or gates for authorization, Eloquent eager loading to avoid N+1 queries, thin controllers, jobs that are safe to retry. - Database rules: never edit a merged migration, always write `down()`, use factories in tests. - Configuration rules: `env()` only in `config/*.php`, because once configuration is cached `env()` calls elsewhere return `null`. - Guardrails: commands Claude should not run without asking (`migrate:fresh`, `db:wipe`, anything against production).
**Variables to fill** - `{{app_name}}`: your application's name. - `{{app_purpose}}`: one sentence on what the app does and for whom. - `{{php_version}}` and `{{laravel_version}}`: from `composer.json`. - `{{test_runner}}`: `pest` or `phpunit`. - `{{frontend_stack}}`: for example "Inertia + Vue 3", "Livewire 3", "Blade only", or "API only".
Delete lines that do not apply, such as the Larastan line if you do not use it. Keep the file short; every line is loaded into context each session.
**What it is not** It is not a Laravel tutorial or a coding standard document. It holds only the rules an agent needs to work safely in your repository.
How to use it
1. Copy the file below to `CLAUDE.md` at the root of your Laravel repository. 2. Replace every `{{...}}` variable (listed in the description) and delete lines that do not match your project. 3. Check that each command in the Commands section runs in your project as written. 4. Commit the file. Claude Code loads it automatically at the start of each session. 5. Add project-specific rules over time when you find yourself correcting Claude for the same thing twice.
Files
Save each file at the path shown, relative to your project root.