Laravel Boost Guidelines for Claude Code
Expert Laravel development guidelines specifically curated for Laravel applications using modern ecosystem packages including Inertia v2, Fortify, and Laravel 12.
Package Versions
You are an expert with these specific packages and versions:
PHP 8.5.1Laravel Framework v12Inertia Laravel v2Laravel Fortify v1Laravel Prompts v0Ziggy v2Laravel MCP v0PHPUnit v11Core Principles
Code Conventions
1. Follow all existing code conventions in the application
2. Check sibling files for correct structure, approach, and naming before creating new files
3. Use descriptive names: `isRegisteredForDiscounts()` not `discount()`
4. Reuse existing components before writing new ones
5. Be concise in explanations - focus on what's important
Application Structure
1. Stick to existing directory structure - don't create new base folders without approval
2. Do not change dependencies without approval
3. Only create documentation files if explicitly requested
Testing Requirements
1. Every change must be programmatically tested
2. Write new tests or update existing tests, then run them to verify
3. Run minimum number of tests using `php artisan test` with filename or filter
4. Never remove tests without approval
PHP Best Practices
Type Safety
Always use explicit return type declarations for methods and functionsUse PHP type hints for method parametersUse PHP 8 constructor property promotion```php
public function __construct(public GitHub $github) { }
protected function isAccessible(User $user, ?string $path = null): bool
{
// implementation
}
```
Control Structures
Always use curly braces for control structures, even single-lineDo not allow empty `__construct()` methods with zero parametersDocumentation
Prefer PHPDoc blocks over inline commentsAdd array shape type definitions when appropriateNever use comments within code unless very complexEnums
Use TitleCase for enum keys: `FavoritePerson`, `BestLake`, `Monthly`Laravel Best Practices
File Creation
Use `php artisan make:*` commands to create new files (migrations, controllers, models, etc.)Pass `--no-interaction` to all Artisan commandsFor generic PHP classes, use `php artisan make:class`Database & Eloquent
Always use proper Eloquent relationship methods with return type hintsPrefer relationship methods over raw queries or manual joinsAvoid `DB::`; prefer `Model::query()`Use eager loading to prevent N+1 query problemsUse Laravel's query builder for complex operationsModel Creation
When creating models, also create factories and seedersAsk user if they need additional scaffolding (use `list-artisan-commands` to check options)APIs
Default to Eloquent API Resources with API versioningFollow existing application conventions if they differValidation
Always create Form Request classes instead of inline validationInclude both validation rules and custom error messagesCheck sibling Form Requests for array vs string rule conventionsQueues
Use queued jobs with `ShouldQueue` interface for time-consuming operationsAuthentication & Authorization
Use Laravel's built-in features (gates, policies, Sanctum)URL Generation
Prefer named routes and the `route()` functionConfiguration
Use environment variables only in config filesNever use `env()` directly outside config filesAlways use `config('app.name')` not `env('APP_NAME')`Testing
Use model factories, including custom states when availableUse `$this->faker->word()` or `fake()->randomDigit()` following existing conventionsUse `php artisan make:test {name}` for feature tests, `--unit` for unit testsMost tests should be feature testsLaravel 12 Specifics
Structure Changes
No middleware files in `app/Http/Middleware/`Use `bootstrap/app.php` to register middleware, exceptions, and routing`bootstrap/providers.php` contains application service providersNo `app/Console/Kernel.php` - use `bootstrap/app.php` or `routes/console.php`Commands in `app/Console/Commands/` auto-registerDatabase
When modifying columns, include all previously defined attributes to avoid lossLaravel 11+ allows native eager load limiting: `$query->latest()->limit(10)`Models
Casts can be set in `casts()` method rather than `$casts` property (follow conventions)Inertia v2
Structure
Components in `resources/js/Pages` (unless vite.config.js specifies differently)Use `Inertia::render()` for server-side routing instead of Blade views```php
Route::get('/users', function () {
return Inertia::render('Users/Index', [
'users' => User::all()
]);
});
```
Features
Utilize polling, prefetching, deferred props, infinite scrolling, lazy loadingWhen using deferred props, add skeleton/pulsing empty statesBuild forms using `useForm` helperLaravel Fortify
Configuration
Check `config/fortify.php` for enabled featuresEnable features in `'features' => []` array: `Features::registration()`, `Features::resetPasswords()`, etc.Set `'views' => false` if handling views yourselfCustomization
Customize views in `FortifyServiceProvider` boot method: `Fortify::loginView()`, etc.Customize authentication: `Fortify::authenticateUsing()`Modify actions in `app/Actions/Fortify/` for business logicAvailable Features
`Features::registration()` - user registration`Features::emailVerification()` - email verification`Features::twoFactorAuthentication()` - 2FA with QR codes`Features::updateProfileInformation()` - profile updates`Features::updatePasswords()` - password changes`Features::resetPasswords()` - password reset via emailPHPUnit Testing
Core Rules
All tests must be PHPUnit classesUse `php artisan make:test --phpunit {name}` for new testsConvert any Pest tests to PHPUnitRun updated tests after changesTest happy paths, failure paths, and edge casesRunning Tests
```bash
All tests
php artisan test
Specific file
php artisan test tests/Feature/ExampleTest.php
Filter by name (recommended after changes)
php artisan test --filter=testName
```
Common Issues
Vite Manifest Error
If you see "Unable to locate file in Vite manifest", run `yarn run build` or ask user to run `yarn run dev` or `composer run dev`.
Frontend Changes Not Reflecting
User may need to run `yarn run build`, `yarn run dev`, or `composer run dev`.
Workflow
1. Understand the task and check existing conventions
2. Use `php artisan make:*` commands to scaffold files
3. Follow existing patterns in sibling files
4. Write or update tests
5. Run minimum required tests to verify
6. Be concise in explanations