|
| 1 | +<laravel-boost-guidelines> |
| 2 | +=== foundation rules === |
| 3 | + |
| 4 | +# Laravel Boost Guidelines |
| 5 | + |
| 6 | +The Laravel Boost guidelines are specifically curated by Laravel maintainers for this application. These guidelines should be followed closely to enhance the user's satisfaction building Laravel applications. |
| 7 | + |
| 8 | +## Foundational Context |
| 9 | +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. |
| 10 | + |
| 11 | +- php - 8.2.29 |
| 12 | + |
| 13 | + |
| 14 | +## Conventions |
| 15 | +- 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, naming. |
| 16 | +- Use descriptive names for variables and methods. For example, `isRegisteredForDiscounts`, not `discount()`. |
| 17 | +- Check for existing components to reuse before writing a new one. |
| 18 | + |
| 19 | +## Verification Scripts |
| 20 | +- Do not create verification scripts or tinker when tests cover that functionality and prove it works. Unit and feature tests are more important. |
| 21 | + |
| 22 | +## Application Structure & Architecture |
| 23 | +- Stick to existing directory structure - don't create new base folders without approval. |
| 24 | +- Do not change the application's dependencies without approval. |
| 25 | + |
| 26 | +## Frontend Bundling |
| 27 | +- If the user doesn't see a frontend change reflected in the UI, it could mean they need to run `npm run build`, `npm run dev`, or `composer run dev`. Ask them. |
| 28 | + |
| 29 | +## Replies |
| 30 | +- Be concise in your explanations - focus on what's important rather than explaining obvious details. |
| 31 | + |
| 32 | +## Documentation Files |
| 33 | +- You must only create documentation files if explicitly requested by the user. |
| 34 | + |
| 35 | + |
| 36 | +=== boost rules === |
| 37 | + |
| 38 | +## Laravel Boost |
| 39 | +- Laravel Boost is an MCP server that comes with powerful tools designed specifically for this application. Use them. |
| 40 | + |
| 41 | +## Artisan |
| 42 | +- Use the `list-artisan-commands` tool when you need to call an Artisan command to double check the available parameters. |
| 43 | + |
| 44 | +## URLs |
| 45 | +- 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. |
| 46 | + |
| 47 | +## Tinker / Debugging |
| 48 | +- You should use the `tinker` tool when you need to execute PHP to debug code or query Eloquent models directly. |
| 49 | +- Use the `database-query` tool when you only need to read from the database. |
| 50 | + |
| 51 | +## Reading Browser Logs With the `browser-logs` Tool |
| 52 | +- You can read browser logs, errors, and exceptions using the `browser-logs` tool from Boost. |
| 53 | +- Only recent browser logs will be useful - ignore old logs. |
| 54 | + |
| 55 | +## Searching Documentation (Critically Important) |
| 56 | +- Boost comes with a powerful `search-docs` tool you should use before any other approaches. This tool automatically passes a list of installed packages and their versions to the remote Boost API, so it returns only version-specific documentation specific for the user's circumstance. You should pass an array of packages to filter on if you know you need docs for particular packages. |
| 57 | +- The 'search-docs' tool is perfect for all Laravel related packages, including Laravel, Inertia, Livewire, Filament, Tailwind, Pest, Nova, Nightwatch, etc. |
| 58 | +- You must use this tool to search for Laravel-ecosystem documentation before falling back to other approaches. |
| 59 | +- Search the documentation before making code changes to ensure we are taking the correct approach. |
| 60 | +- Use multiple, broad, simple, topic based queries to start. For example: `['rate limiting', 'routing rate limiting', 'routing']`. |
| 61 | +- Do not add package names to queries - package information is already shared. For example, use `test resource table`, not `filament 4 test resource table`. |
| 62 | + |
| 63 | +### Available Search Syntax |
| 64 | +- You can and should pass multiple queries at once. The most relevant results will be returned first. |
| 65 | + |
| 66 | +1. Simple Word Searches with auto-stemming - query=authentication - finds 'authenticate' and 'auth' |
| 67 | +2. Multiple Words (AND Logic) - query=rate limit - finds knowledge containing both "rate" AND "limit" |
| 68 | +3. Quoted Phrases (Exact Position) - query="infinite scroll" - Words must be adjacent and in that order |
| 69 | +4. Mixed Queries - query=middleware "rate limit" - "middleware" AND exact phrase "rate limit" |
| 70 | +5. Multiple Queries - queries=["authentication", "middleware"] - ANY of these terms |
| 71 | + |
| 72 | + |
| 73 | +=== php rules === |
| 74 | + |
| 75 | +## PHP |
| 76 | + |
| 77 | +- Always use curly braces for control structures, even if it has one line. |
| 78 | + |
| 79 | +### Constructors |
| 80 | +- Use PHP 8 constructor property promotion in `__construct()`. |
| 81 | + - <code-snippet>public function __construct(public GitHub $github) { }</code-snippet> |
| 82 | +- Do not allow empty `__construct()` methods with zero parameters. |
| 83 | + |
| 84 | +### Type Declarations |
| 85 | +- Always use explicit return type declarations for methods and functions. |
| 86 | +- Use appropriate PHP type hints for method parameters. |
| 87 | + |
| 88 | +<code-snippet name="Explicit Return Types and Method Params" lang="php"> |
| 89 | +protected function isAccessible(User $user, ?string $path = null): bool |
| 90 | +{ |
| 91 | + ... |
| 92 | +} |
| 93 | +</code-snippet> |
| 94 | + |
| 95 | +## Comments |
| 96 | +- Prefer PHPDoc blocks over comments. Never use comments within the code itself unless there is something _very_ complex going on. |
| 97 | + |
| 98 | +## PHPDoc Blocks |
| 99 | +- Add useful array shape type definitions for arrays when appropriate. |
| 100 | + |
| 101 | +## Enums |
| 102 | +- Typically, keys in an Enum should be TitleCase. For example: `FavoritePerson`, `BestLake`, `Monthly`. |
| 103 | + |
| 104 | + |
| 105 | +=== .ai/documentation rules === |
| 106 | + |
| 107 | +# Documentation conventions |
| 108 | +</laravel-boost-guidelines> |
0 commit comments