|
| 1 | +--- |
| 2 | +alwaysApply: true |
| 3 | +--- |
| 4 | +<laravel-boost-guidelines> |
| 5 | +=== foundation rules === |
| 6 | + |
| 7 | +# Laravel Boost Guidelines |
| 8 | + |
| 9 | +The Laravel Boost guidelines are specifically curated by Laravel maintainers for this application. These guidelines should be followed closely to ensure the best experience when building Laravel applications. |
| 10 | + |
| 11 | +## Foundational Context |
| 12 | + |
| 13 | +This application is a Laravel application and its main Laravel ecosystems package & versions are below. You are an expert with them all. Ensure you abide by these specific packages & versions. |
| 14 | + |
| 15 | +- php - 8.4.17 |
| 16 | +- inertiajs/inertia-laravel (INERTIA) - v3 |
| 17 | +- laravel/framework (LARAVEL) - v13 |
| 18 | +- laravel/prompts (PROMPTS) - v0 |
| 19 | +- laravel/reverb (REVERB) - v1 |
| 20 | +- laravel/sanctum (SANCTUM) - v4 |
| 21 | +- laravel/wayfinder (WAYFINDER) - v0 |
| 22 | +- larastan/larastan (LARASTAN) - v3 |
| 23 | +- laravel/mcp (MCP) - v0 |
| 24 | +- laravel/pint (PINT) - v1 |
| 25 | +- laravel/sail (SAIL) - v1 |
| 26 | +- phpunit/phpunit (PHPUNIT) - v12 |
| 27 | +- @inertiajs/vue3 (INERTIA) - v3 |
| 28 | +- laravel-echo (ECHO) - v2 |
| 29 | +- vue (VUE) - v3 |
| 30 | +- @laravel/vite-plugin-wayfinder (WAYFINDER) - v0 |
| 31 | +- tailwindcss (TAILWINDCSS) - v4 |
| 32 | + |
| 33 | +## Skills Activation |
| 34 | + |
| 35 | +This project has domain-specific skills available. You MUST activate the relevant skill whenever you work in that domain—don't wait until you're stuck. |
| 36 | + |
| 37 | +- `wayfinder-development` — Activates whenever referencing backend routes in frontend components. Use when importing from @/actions or @/routes, calling Laravel routes from TypeScript, or working with Wayfinder route functions. |
| 38 | +- `inertia-vue-development` — Develops Inertia.js v3 Vue client-side applications. Activates when creating Vue pages, forms, or navigation; using <Link>, <Form>, useForm, or router; working with deferred props, prefetching, or polling; or when user mentions Vue with Inertia, Vue pages, Vue forms, or Vue navigation. |
| 39 | +- `tailwindcss-development` — Styles applications using Tailwind CSS v4 utilities. Activates when adding styles, restyling components, working with gradients, spacing, layout, flex, grid, responsive design, dark mode, colors, typography, or borders; or when the user mentions CSS, styling, classes, Tailwind, restyle, hero section, cards, buttons, or any visual/UI changes. |
| 40 | + |
| 41 | +## Conventions |
| 42 | + |
| 43 | +- You must follow all existing code conventions used in this application. When creating or editing a file, check sibling files for the correct structure, approach, and naming. |
| 44 | +- Use descriptive names for variables and methods. For example, `isRegisteredForDiscounts`, not `discount()`. |
| 45 | +- Check for existing components to reuse before writing a new one. |
| 46 | + |
| 47 | +## Verification Scripts |
| 48 | + |
| 49 | +- Do not create verification scripts or tinker when tests cover that functionality and prove they work. Unit and feature tests are more important. |
| 50 | + |
| 51 | +## Application Structure & Architecture |
| 52 | + |
| 53 | +- Stick to existing directory structure; don't create new base folders without approval. |
| 54 | +- Do not change the application's dependencies without approval. |
| 55 | + |
| 56 | +## Frontend Bundling |
| 57 | + |
| 58 | +- If the user doesn't see a frontend change reflected in the UI, it could mean they need to run `pnpm run build`, `pnpm run dev`, or `composer run dev`. Ask them. |
| 59 | + |
| 60 | +## Documentation Files |
| 61 | + |
| 62 | +- You must only create documentation files if explicitly requested by the user. |
| 63 | + |
| 64 | +## Replies |
| 65 | + |
| 66 | +- Be concise in your explanations - focus on what's important rather than explaining obvious details. |
| 67 | + |
| 68 | +=== boost rules === |
| 69 | + |
| 70 | +# Laravel Boost |
| 71 | + |
| 72 | +- Laravel Boost is an MCP server that comes with powerful tools designed specifically for this application. Use them. |
| 73 | + |
| 74 | +## Artisan |
| 75 | + |
| 76 | +- Use the `list-artisan-commands` tool when you need to call an Artisan command to double-check the available parameters. |
| 77 | + |
| 78 | +## URLs |
| 79 | + |
| 80 | +- Whenever you share a project URL with the user, you should use the `get-absolute-url` tool to ensure you're using the correct scheme, domain/IP, and port. |
| 81 | + |
| 82 | +## Tinker / Debugging |
| 83 | + |
| 84 | +- You should use the `tinker` tool when you need to execute PHP to debug code or query Eloquent models directly. |
| 85 | +- Use the `database-query` tool when you only need to read from the database. |
| 86 | + |
| 87 | +## Reading Browser Logs With the `browser-logs` Tool |
| 88 | + |
| 89 | +- You can read browser logs, errors, and exceptions using the `browser-logs` tool from Boost. |
| 90 | +- Only recent browser logs will be useful - ignore old logs. |
| 91 | + |
| 92 | +## Searching Documentation (Critically Important) |
| 93 | + |
| 94 | +- Boost comes with a powerful `search-docs` tool you should use before trying other approaches when working with Laravel or Laravel ecosystem packages. This tool automatically passes a list of installed packages and their versions to the remote Boost API, so it returns only version-specific documentation for the user's circumstance. You should pass an array of packages to filter on if you know you need docs for particular packages. |
| 95 | +- Search the documentation before making code changes to ensure we are taking the correct approach. |
| 96 | +- Use multiple, broad, simple, topic-based queries at once. For example: `['rate limiting', 'routing rate limiting', 'routing']`. The most relevant results will be returned first. |
| 97 | +- Do not add package names to queries; package information is already shared. For example, use `test resource table`, not `filament 4 test resource table`. |
| 98 | + |
| 99 | +### Available Search Syntax |
| 100 | + |
| 101 | +1. Simple Word Searches with auto-stemming - query=authentication - finds 'authenticate' and 'auth'. |
| 102 | +2. Multiple Words (AND Logic) - query=rate limit - finds knowledge containing both "rate" AND "limit". |
| 103 | +3. Quoted Phrases (Exact Position) - query="infinite scroll" - words must be adjacent and in that order. |
| 104 | +4. Mixed Queries - query=middleware "rate limit" - "middleware" AND exact phrase "rate limit". |
| 105 | +5. Multiple Queries - queries=["authentication", "middleware"] - ANY of these terms. |
| 106 | + |
| 107 | +=== php rules === |
| 108 | + |
| 109 | +# PHP |
| 110 | + |
| 111 | +- Always use strict typing at the head of a `.php` file: `declare(strict_types=1);`. |
| 112 | +- Always use curly braces for control structures, even for single-line bodies. |
| 113 | + |
| 114 | +## Constructors |
| 115 | + |
| 116 | +- Use PHP 8 constructor property promotion in `__construct()`. |
| 117 | + - <code-snippet>public function __construct(public GitHub $github) { }</code-snippet> |
| 118 | +- Do not allow empty `__construct()` methods with zero parameters unless the constructor is private. |
| 119 | + |
| 120 | +## Type Declarations |
| 121 | + |
| 122 | +- Always use explicit return type declarations for methods and functions. |
| 123 | +- Use appropriate PHP type hints for method parameters. |
| 124 | + |
| 125 | +<code-snippet name="Explicit Return Types and Method Params" lang="php"> |
| 126 | +protected function isAccessible(User $user, ?string $path = null): bool |
| 127 | +{ |
| 128 | + ... |
| 129 | +} |
| 130 | +</code-snippet> |
| 131 | + |
| 132 | +## Enums |
| 133 | + |
| 134 | +- Typically, keys in an Enum should be TitleCase. For example: `FavoritePerson`, `BestLake`, `Monthly`. |
| 135 | + |
| 136 | +## Comments |
| 137 | + |
| 138 | +- Prefer PHPDoc blocks over inline comments. Never use comments within the code itself unless the logic is exceptionally complex. |
| 139 | + |
| 140 | +## PHPDoc Blocks |
| 141 | + |
| 142 | +- Add useful array shape type definitions when appropriate. |
| 143 | + |
| 144 | +=== herd rules === |
| 145 | + |
| 146 | +# Laravel Herd |
| 147 | + |
| 148 | +- The application is served by Laravel Herd and will be available at: `https?://[kebab-case-project-dir].test`. Use the `get-absolute-url` tool to generate valid URLs for the user. |
| 149 | +- You must not run any commands to make the site available via HTTP(S). It is always available through Laravel Herd. |
| 150 | + |
| 151 | +=== inertia-laravel/core rules === |
| 152 | + |
| 153 | +# Inertia |
| 154 | + |
| 155 | +- Inertia creates fully client-side rendered SPAs without modern SPA complexity, leveraging existing server-side patterns. |
| 156 | +- Components live in `resources/js/Pages` (unless specified in `vite.config.js`). Use `Inertia::render()` for server-side routing instead of Blade views. |
| 157 | +- ALWAYS use `search-docs` tool for version-specific Inertia documentation and updated code examples. |
| 158 | +- IMPORTANT: Activate `inertia-vue-development` when working with Inertia Vue client-side patterns. |
| 159 | + |
| 160 | +=== inertia-laravel/v3 rules === |
| 161 | + |
| 162 | +# Inertia v3 |
| 163 | + |
| 164 | +- Use all Inertia features from prior versions. Check the documentation before making changes to ensure the correct approach. |
| 165 | +- New features: deferred props, infinite scrolling (merging props + `WhenVisible`), lazy loading on scroll, polling, prefetching. |
| 166 | +- When using deferred props, add an empty state with a pulsing or animated skeleton. |
| 167 | + |
| 168 | +=== laravel/core rules === |
| 169 | + |
| 170 | +# Do Things the Laravel Way |
| 171 | + |
| 172 | +- Use `php artisan make:` commands to create new files (i.e. migrations, controllers, models, etc.). You can list available Artisan commands using the `list-artisan-commands` tool. |
| 173 | +- If you're creating a generic PHP class, use `php artisan make:class`. |
| 174 | +- Pass `--no-interaction` to all Artisan commands to ensure they work without user input. You should also pass the correct `--options` to ensure correct behavior. |
| 175 | + |
| 176 | +## Database |
| 177 | + |
| 178 | +- Always use proper Eloquent relationship methods with return type hints. Prefer relationship methods over raw queries or manual joins. |
| 179 | +- Use Eloquent models and relationships before suggesting raw database queries. |
| 180 | +- Avoid `DB::`; prefer `Model::query()`. Generate code that leverages Laravel's ORM capabilities rather than bypassing them. |
| 181 | +- Generate code that prevents N+1 query problems by using eager loading. |
| 182 | +- Use Laravel's query builder for very complex database operations. |
| 183 | + |
| 184 | +### Model Creation |
| 185 | + |
| 186 | +- When creating new models, create useful factories and seeders for them too. Ask the user if they need any other things, using `list-artisan-commands` to check the available options to `php artisan make:model`. |
| 187 | + |
| 188 | +### APIs & Eloquent Resources |
| 189 | + |
| 190 | +- For APIs, default to using Eloquent API Resources and API versioning unless existing API routes do not, then you should follow existing application convention. |
| 191 | + |
| 192 | +## Controllers & Validation |
| 193 | + |
| 194 | +- Always create Form Request classes for validation rather than inline validation in controllers. Include both validation rules and custom error messages. |
| 195 | +- Check sibling Form Requests to see if the application uses array or string based validation rules. |
| 196 | + |
| 197 | +## Authentication & Authorization |
| 198 | + |
| 199 | +- Use Laravel's built-in authentication and authorization features (gates, policies, Sanctum, etc.). |
| 200 | + |
| 201 | +## URL Generation |
| 202 | + |
| 203 | +- When generating links to other pages, prefer named routes and the `route()` function. |
| 204 | + |
| 205 | +## Queues |
| 206 | + |
| 207 | +- Use queued jobs for time-consuming operations with the `ShouldQueue` interface. |
| 208 | + |
| 209 | +## Configuration |
| 210 | + |
| 211 | +- Use environment variables only in configuration files - never use the `env()` function directly outside of config files. Always use `config('app.name')`, not `env('APP_NAME')`. |
| 212 | + |
| 213 | +## Testing |
| 214 | + |
| 215 | +- When creating models for tests, use the factories for the models. Check if the factory has custom states that can be used before manually setting up the model. |
| 216 | +- Faker: Use methods such as `$this->faker->word()` or `fake()->randomDigit()`. Follow existing conventions whether to use `$this->faker` or `fake()`. |
| 217 | +- When creating tests, make use of `php artisan make:test [options] {name}` to create a feature test, and pass `--unit` to create a unit test. Most tests should be feature tests. |
| 218 | + |
| 219 | +## Vite Error |
| 220 | + |
| 221 | +- If you receive an "Illuminate\Foundation\ViteException: Unable to locate file in Vite manifest" error, you can run `pnpm run build` or ask the user to run `pnpm run dev` or `composer run dev`. |
| 222 | + |
| 223 | +=== laravel/v13 rules === |
| 224 | + |
| 225 | +# Laravel 13 |
| 226 | + |
| 227 | +- CRITICAL: ALWAYS use `search-docs` tool for version-specific Laravel documentation and updated code examples. |
| 228 | +- Since Laravel 11, Laravel has a new streamlined file structure which this project uses. |
| 229 | + |
| 230 | +## Laravel 13 Structure |
| 231 | + |
| 232 | +- In Laravel 13, middleware are no longer registered in `app/Http/Kernel.php`. |
| 233 | +- Middleware are configured declaratively in `bootstrap/app.php` using `Application::configure()->withMiddleware()`. |
| 234 | +- `bootstrap/app.php` is the file to register middleware, exceptions, and routing files. |
| 235 | +- `bootstrap/providers.php` contains application specific service providers. |
| 236 | +- The `app\Console\Kernel.php` file no longer exists; use `bootstrap/app.php` or `routes/console.php` for console configuration. |
| 237 | +- Console commands in `app/Console/Commands/` are automatically available and do not require manual registration. |
| 238 | + |
| 239 | +## Database |
| 240 | + |
| 241 | +- When modifying a column, the migration must include all of the attributes that were previously defined on the column. Otherwise, they will be dropped and lost. |
| 242 | +- Laravel allows limiting eagerly loaded records natively, without external packages: `$query->latest()->limit(10);`. |
| 243 | + |
| 244 | +### Models |
| 245 | + |
| 246 | +- Casts can and likely should be set in a `casts()` method on a model rather than the `$casts` property. Follow existing conventions from other models. |
| 247 | + |
| 248 | +=== wayfinder/core rules === |
| 249 | + |
| 250 | +# Laravel Wayfinder |
| 251 | + |
| 252 | +Wayfinder generates TypeScript functions for Laravel routes. Import from `@/actions/` (controllers) or `@/routes/` (named routes). |
| 253 | + |
| 254 | +- IMPORTANT: Activate `wayfinder-development` skill whenever referencing backend routes in frontend components. |
| 255 | +- Invokable Controllers: `import StorePost from '@/actions/.../StorePostController'; StorePost()`. |
| 256 | +- Parameter Binding: Detects route keys (`{post:slug}`) — `show({ slug: "my-post" })`. |
| 257 | +- Query Merging: `show(1, { mergeQuery: { page: 2, sort: null } })` merges with current URL, `null` removes params. |
| 258 | +- Inertia: Use `.form()` with `<Form>` component or `form.submit(store())` with useForm. |
| 259 | + |
| 260 | +=== pint/core rules === |
| 261 | + |
| 262 | +# Laravel Pint Code Formatter |
| 263 | + |
| 264 | +- You must run `vendor/bin/pint --dirty` before finalizing changes to ensure your code matches the project's expected style. |
| 265 | +- Do not run `vendor/bin/pint --test`, simply run `vendor/bin/pint` to fix any formatting issues. |
| 266 | + |
| 267 | +=== phpunit/core rules === |
| 268 | + |
| 269 | +# PHPUnit |
| 270 | + |
| 271 | +- This application uses PHPUnit for testing. All tests must be written as PHPUnit classes. Use `php artisan make:test --phpunit {name}` to create a new test. |
| 272 | +- If you see a test using "Pest", convert it to PHPUnit. |
| 273 | +- Every time a test has been updated, run that singular test. |
| 274 | +- When the tests relating to your feature are passing, ask the user if they would like to also run the entire test suite to make sure everything is still passing. |
| 275 | +- Tests should cover all happy paths, failure paths, and edge cases. |
| 276 | +- You must not remove any tests or test files from the tests directory without approval. These are not temporary or helper files; these are core to the application. |
| 277 | + |
| 278 | +## Running Tests |
| 279 | + |
| 280 | +- Run the minimal number of tests, using an appropriate filter, before finalizing. |
| 281 | +- To run all tests: `php artisan test --compact`. |
| 282 | +- To run all tests in a file: `php artisan test --compact tests/Feature/ExampleTest.php`. |
| 283 | +- To filter on a particular test name: `php artisan test --compact --filter=testName` (recommended after making a change to a related file). |
| 284 | + |
| 285 | +=== inertia-vue/core rules === |
| 286 | + |
| 287 | +# Inertia + Vue |
| 288 | + |
| 289 | +Vue components must have a single root element. |
| 290 | +- IMPORTANT: Activate `inertia-vue-development` when working with Inertia Vue client-side patterns. |
| 291 | + |
| 292 | +=== tailwindcss/core rules === |
| 293 | + |
| 294 | +# Tailwind CSS |
| 295 | + |
| 296 | +- Always use existing Tailwind conventions; check project patterns before adding new ones. |
| 297 | +- IMPORTANT: Always use `search-docs` tool for version-specific Tailwind CSS documentation and updated code examples. Never rely on training data. |
| 298 | +- IMPORTANT: Activate `tailwindcss-development` every time you're working with a Tailwind CSS or styling-related task. |
| 299 | +</laravel-boost-guidelines> |
0 commit comments