Skip to content

Commit d6c8f11

Browse files
Added .junie/guidelines.md file
1 parent 51dc7b3 commit d6c8f11

File tree

3 files changed

+362
-3
lines changed

3 files changed

+362
-3
lines changed

.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
.cursor/
33
.vscode/
44

5-
!.junie/guidelines.md
6-
.junie/
7-
85
_site/
96
build/
107
node_modules/

.junie/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
*
2+
!.gitignore
3+
!guidelines.md

.junie/guidelines.md

Lines changed: 359 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,359 @@
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.4.11
12+
- laravel/framework (LARAVEL) - v12
13+
- laravel/prompts (PROMPTS) - v0
14+
- laravel/pint (PINT) - v1
15+
- pestphp/pest (PEST) - v4
16+
- phpunit/phpunit (PHPUNIT) - v12
17+
18+
19+
## Conventions
20+
- 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.
21+
- Use descriptive names for variables and methods. For example, `isRegisteredForDiscounts`, not `discount()`.
22+
- Check for existing components to reuse before writing a new one.
23+
24+
## Verification Scripts
25+
- Do not create verification scripts or tinker when tests cover that functionality and prove it works. Unit and feature tests are more important.
26+
27+
## Application Structure & Architecture
28+
- Stick to existing directory structure - don't create new base folders without approval.
29+
- Do not change the application's dependencies without approval.
30+
31+
## Frontend Bundling
32+
- 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.
33+
34+
## Replies
35+
- Be concise in your explanations - focus on what's important rather than explaining obvious details.
36+
37+
## Documentation Files
38+
- You must only create documentation files if explicitly requested by the user.
39+
40+
41+
=== boost rules ===
42+
43+
## Laravel Boost
44+
- Laravel Boost is an MCP server that comes with powerful tools designed specifically for this application. Use them.
45+
46+
## Artisan
47+
- Use the `list-artisan-commands` tool when you need to call an Artisan command to double check the available parameters.
48+
49+
## URLs
50+
- 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.
51+
52+
## Tinker / Debugging
53+
- You should use the `tinker` tool when you need to execute PHP to debug code or query Eloquent models directly.
54+
- Use the `database-query` tool when you only need to read from the database.
55+
56+
## Reading Browser Logs With the `browser-logs` Tool
57+
- You can read browser logs, errors, and exceptions using the `browser-logs` tool from Boost.
58+
- Only recent browser logs will be useful - ignore old logs.
59+
60+
## Searching Documentation (Critically Important)
61+
- 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.
62+
- The 'search-docs' tool is perfect for all Laravel related packages, including Laravel, Inertia, Livewire, Filament, Tailwind, Pest, Nova, Nightwatch, etc.
63+
- You must use this tool to search for Laravel-ecosystem documentation before falling back to other approaches.
64+
- Search the documentation before making code changes to ensure we are taking the correct approach.
65+
- Use multiple, broad, simple, topic based queries to start. For example: `['rate limiting', 'routing rate limiting', 'routing']`.
66+
- Do not add package names to queries - package information is already shared. For example, use `test resource table`, not `filament 4 test resource table`.
67+
68+
### Available Search Syntax
69+
- You can and should pass multiple queries at once. The most relevant results will be returned first.
70+
71+
1. Simple Word Searches with auto-stemming - query=authentication - finds 'authenticate' and 'auth'
72+
2. Multiple Words (AND Logic) - query=rate limit - finds knowledge containing both "rate" AND "limit"
73+
3. Quoted Phrases (Exact Position) - query="infinite scroll" - Words must be adjacent and in that order
74+
4. Mixed Queries - query=middleware "rate limit" - "middleware" AND exact phrase "rate limit"
75+
5. Multiple Queries - queries=["authentication", "middleware"] - ANY of these terms
76+
77+
78+
=== php rules ===
79+
80+
## PHP
81+
82+
- Always use curly braces for control structures, even if it has one line.
83+
84+
### Constructors
85+
- Use PHP 8 constructor property promotion in `__construct()`.
86+
- <code-snippet>public function __construct(public GitHub $github) { }</code-snippet>
87+
- Do not allow empty `__construct()` methods with zero parameters.
88+
89+
### Type Declarations
90+
- Always use explicit return type declarations for methods and functions.
91+
- Use appropriate PHP type hints for method parameters.
92+
93+
<code-snippet name="Explicit Return Types and Method Params" lang="php">
94+
protected function isAccessible(User $user, ?string $path = null): bool
95+
{
96+
...
97+
}
98+
</code-snippet>
99+
100+
## Comments
101+
- Prefer PHPDoc blocks over comments. Never use comments within the code itself unless there is something _very_ complex going on.
102+
103+
## PHPDoc Blocks
104+
- Add useful array shape type definitions for arrays when appropriate.
105+
106+
## Enums
107+
- Typically, keys in an Enum should be TitleCase. For example: `FavoritePerson`, `BestLake`, `Monthly`.
108+
109+
110+
=== laravel/core rules ===
111+
112+
## Do Things the Laravel Way
113+
114+
- 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.
115+
- If you're creating a generic PHP class, use `artisan make:class`.
116+
- 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.
117+
118+
### Database
119+
- Always use proper Eloquent relationship methods with return type hints. Prefer relationship methods over raw queries or manual joins.
120+
- Use Eloquent models and relationships before suggesting raw database queries
121+
- Avoid `DB::`; prefer `Model::query()`. Generate code that leverages Laravel's ORM capabilities rather than bypassing them.
122+
- Generate code that prevents N+1 query problems by using eager loading.
123+
- Use Laravel's query builder for very complex database operations.
124+
125+
### Model Creation
126+
- 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`.
127+
128+
### APIs & Eloquent Resources
129+
- For APIs, default to using Eloquent API Resources and API versioning unless existing API routes do not, then you should follow existing application convention.
130+
131+
### Controllers & Validation
132+
- Always create Form Request classes for validation rather than inline validation in controllers. Include both validation rules and custom error messages.
133+
- Check sibling Form Requests to see if the application uses array or string based validation rules.
134+
135+
### Queues
136+
- Use queued jobs for time-consuming operations with the `ShouldQueue` interface.
137+
138+
### Authentication & Authorization
139+
- Use Laravel's built-in authentication and authorization features (gates, policies, Sanctum, etc.).
140+
141+
### URL Generation
142+
- When generating links to other pages, prefer named routes and the `route()` function.
143+
144+
### Configuration
145+
- 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')`.
146+
147+
### Testing
148+
- 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.
149+
- Faker: Use methods such as `$this->faker->word()` or `fake()->randomDigit()`. Follow existing conventions whether to use `$this->faker` or `fake()`.
150+
- 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.
151+
152+
### Vite Error
153+
- If you receive an "Illuminate\Foundation\ViteException: Unable to locate file in Vite manifest" error, you can run `npm run build` or ask the user to run `npm run dev` or `composer run dev`.
154+
155+
156+
=== laravel/v12 rules ===
157+
158+
## Laravel 12
159+
160+
- Use the `search-docs` tool to get version specific documentation.
161+
- Since Laravel 11, Laravel has a new streamlined file structure which this project uses.
162+
163+
### Laravel 12 Structure
164+
- No middleware files in `app/Http/Middleware/`.
165+
- `bootstrap/app.php` is the file to register middleware, exceptions, and routing files.
166+
- `bootstrap/providers.php` contains application specific service providers.
167+
- **No app\Console\Kernel.php** - use `bootstrap/app.php` or `routes/console.php` for console configuration.
168+
- **Commands auto-register** - files in `app/Console/Commands/` are automatically available and do not require manual registration.
169+
170+
### Database
171+
- 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.
172+
- Laravel 11 allows limiting eagerly loaded records natively, without external packages: `$query->latest()->limit(10);`.
173+
174+
### Models
175+
- 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.
176+
177+
178+
=== pint/core rules ===
179+
180+
## Laravel Pint Code Formatter
181+
182+
- You must run `vendor/bin/pint --dirty` before finalizing changes to ensure your code matches the project's expected style.
183+
- Do not run `vendor/bin/pint --test`, simply run `vendor/bin/pint` to fix any formatting issues.
184+
185+
186+
=== pest/core rules ===
187+
188+
## Pest
189+
190+
### Testing
191+
- If you need to verify a feature is working, write or update a Unit / Feature test.
192+
193+
### Pest Tests
194+
- All tests must be written using Pest. Use `php artisan make:test --pest <name>`.
195+
- 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.
196+
- Tests should test all of the happy paths, failure paths, and weird paths.
197+
- Tests live in the `tests/Feature` and `tests/Unit` directories.
198+
- Pest tests look and behave like this:
199+
<code-snippet name="Basic Pest Test Example" lang="php">
200+
it('is true', function () {
201+
expect(true)->toBeTrue();
202+
});
203+
</code-snippet>
204+
205+
### Running Tests
206+
207+
After you have made all changes to the code, be sure to perform the following steps in the order shown:
208+
209+
1. Delete the file `vendor/orchestra/testbench-core/laravel/storage/logs/laravel.log`.
210+
2. Run the console command `php vendor/bin/pest`.
211+
3. Run the console command `composer style:snippets`.
212+
4. Run the console command `composer reset:snippets`.
213+
214+
If the tests fail, carefully review the output log as well as the contents of the created file `vendor/orchestra/testbench-core/laravel/storage/logs/laravel.log`.
215+
216+
Once you understand the problem, fix it.
217+
- Run the minimal number of tests using an appropriate filter before finalizing code edits.
218+
- To run all tests: `php vendor/bin/pest`.
219+
- To run all tests in a file: `php vendor/bin/pest tests/Feature/ExampleTest.php`.
220+
- To filter on a particular test name: `php vendor/bin/pest --filter=testName` (recommended after making a change to a related file).
221+
- When the tests relating to your changes are passing, ask the user if they would like to run the entire test suite to ensure everything is still passing.
222+
223+
### Pest Assertions
224+
- When asserting status codes on a response, use the specific method like `assertForbidden` and `assertNotFound` instead of using `assertStatus(403)` or similar, e.g.:
225+
<code-snippet name="Pest Example Asserting postJson Response" lang="php">
226+
it('returns all', function () {
227+
$response = $this->postJson('/api/docs', []);
228+
229+
$response->assertSuccessful();
230+
});
231+
</code-snippet>
232+
233+
### Mocking
234+
- Mocking can be very helpful when appropriate.
235+
- When mocking, you can use the `Pest\Laravel\mock` Pest function, but always import it via `use function Pest\Laravel\mock;` before using it. Alternatively, you can use `$this->mock()` if existing tests do.
236+
- You can also create partial mocks using the same import or self method.
237+
238+
### Datasets
239+
- Use datasets in Pest to simplify tests which have a lot of duplicated data. This is often the case when testing validation rules, so consider going with this solution when writing tests for validation rules.
240+
241+
<code-snippet name="Pest Dataset Example" lang="php">
242+
it('has emails', function (string $email) {
243+
expect($email)->not->toBeEmpty();
244+
})->with([
245+
'james' => '[email protected]',
246+
'taylor' => '[email protected]',
247+
]);
248+
</code-snippet>
249+
250+
251+
=== pest/v4 rules ===
252+
253+
## Pest 4
254+
255+
- Pest v4 is a huge upgrade to Pest and offers: browser testing, smoke testing, visual regression testing, test sharding, and faster type coverage.
256+
- Browser testing is incredibly powerful and useful for this project.
257+
- Browser tests should live in `tests/Browser/`.
258+
- Use the `search-docs` tool for detailed guidance on utilizing these features.
259+
260+
### Browser Testing
261+
- You can use Laravel features like `Event::fake()`, `assertAuthenticated()`, and model factories within Pest v4 browser tests, as well as `RefreshDatabase` (when needed) to ensure a clean state for each test.
262+
- Interact with the page (click, type, scroll, select, submit, drag-and-drop, touch gestures, etc.) when appropriate to complete the test.
263+
- If requested, test on multiple browsers (Chrome, Firefox, Safari).
264+
- If requested, test on different devices and viewports (like iPhone 14 Pro, tablets, or custom breakpoints).
265+
- Switch color schemes (light/dark mode) when appropriate.
266+
- Take screenshots or pause tests for debugging when appropriate.
267+
268+
### Example Tests
269+
270+
<code-snippet name="Pest Browser Test Example" lang="php">
271+
it('may reset the password', function () {
272+
Notification::fake();
273+
274+
$this->actingAs(User::factory()->create());
275+
276+
$page = visit('/sign-in'); // Visit on a real browser...
277+
278+
$page->assertSee('Sign In')
279+
->assertNoJavascriptErrors() // or ->assertNoConsoleLogs()
280+
->click('Forgot Password?')
281+
->fill('email', '[email protected]')
282+
->click('Send Reset Link')
283+
->assertSee('We have emailed your password reset link!')
284+
285+
Notification::assertSent(ResetPassword::class);
286+
});
287+
</code-snippet>
288+
289+
<code-snippet name="Pest Smoke Testing Example" lang="php">
290+
$pages = visit(['/', '/about', '/contact']);
291+
292+
$pages->assertNoJavascriptErrors()->assertNoConsoleLogs();
293+
</code-snippet>
294+
295+
296+
=== .ai/core rules ===
297+
298+
## Pest
299+
300+
### Testing
301+
- If you need to verify a feature is working, write or update a Unit / Feature test.
302+
303+
### Pest Tests
304+
- All tests must be written using Pest. Use `php artisan make:test --pest <name>`.
305+
- 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.
306+
- Tests should test all of the happy paths, failure paths, and weird paths.
307+
- Tests live in the `tests/Feature` and `tests/Unit` directories.
308+
- Pest tests look and behave like this:
309+
<code-snippet name="Basic Pest Test Example" lang="php">
310+
it('is true', function () {
311+
expect(true)->toBeTrue();
312+
});
313+
</code-snippet>
314+
315+
### Running Tests
316+
317+
After you have made all changes to the code, be sure to perform the following steps in the order shown:
318+
319+
1. Delete the file `vendor/orchestra/testbench-core/laravel/storage/logs/laravel.log`.
320+
2. Run the console command `php vendor/bin/pest`.
321+
3. Run the console command `composer style:snippets`.
322+
4. Run the console command `composer reset:snippets`.
323+
324+
If the tests fail, carefully review the output log as well as the contents of the created file `vendor/orchestra/testbench-core/laravel/storage/logs/laravel.log`.
325+
326+
Once you understand the problem, fix it.
327+
- Run the minimal number of tests using an appropriate filter before finalizing code edits.
328+
- To run all tests: `php vendor/bin/pest`.
329+
- To run all tests in a file: `php vendor/bin/pest tests/Feature/ExampleTest.php`.
330+
- To filter on a particular test name: `php vendor/bin/pest --filter=testName` (recommended after making a change to a related file).
331+
- When the tests relating to your changes are passing, ask the user if they would like to run the entire test suite to ensure everything is still passing.
332+
333+
### Pest Assertions
334+
- When asserting status codes on a response, use the specific method like `assertForbidden` and `assertNotFound` instead of using `assertStatus(403)` or similar, e.g.:
335+
<code-snippet name="Pest Example Asserting postJson Response" lang="php">
336+
it('returns all', function () {
337+
$response = $this->postJson('/api/docs', []);
338+
339+
$response->assertSuccessful();
340+
});
341+
</code-snippet>
342+
343+
### Mocking
344+
- Mocking can be very helpful when appropriate.
345+
- When mocking, you can use the `Pest\Laravel\mock` Pest function, but always import it via `use function Pest\Laravel\mock;` before using it. Alternatively, you can use `$this->mock()` if existing tests do.
346+
- You can also create partial mocks using the same import or self method.
347+
348+
### Datasets
349+
- Use datasets in Pest to simplify tests which have a lot of duplicated data. This is often the case when testing validation rules, so consider going with this solution when writing tests for validation rules.
350+
351+
<code-snippet name="Pest Dataset Example" lang="php">
352+
it('has emails', function (string $email) {
353+
expect($email)->not->toBeEmpty();
354+
})->with([
355+
'james' => '[email protected]',
356+
'taylor' => '[email protected]',
357+
]);
358+
</code-snippet>
359+
</laravel-boost-guidelines>

0 commit comments

Comments
 (0)