This document provides comprehensive guidelines for AI agents and developers working on the Cachet Core repository. Adhere to these rules to maintain code quality, consistency, and stability.
Cachet Core is a Laravel package that provides the core functionality for Cachet (Status Page system). It leverages the Laravel ecosystem extensively, including Filament for the admin panel.
- Framework: Laravel (Package development via Orchestra Testbench)
- Language: PHP 8.2+
- Admin UI: Filament v4
- Frontend: Blade, Alpine.js, Tailwind CSS
- Testing: Pest PHP
- Static Analysis: Larastan (Level 5), Pint
- PHP:
composer install - JS:
npm install - Do not add new dependencies without explicit approval.
- Frontend Build:
npm run build(Required for CSS/JS changes) - Frontend Dev:
npm run dev(Watch mode) - Package Discovery:
composer prepare(Runspackage:discover)
- The project uses
orchestra/testbenchwith aworkbenchdirectory. - Serve App:
composer startorcomposer dev - Clear Cache:
composer clear
Always run tests before and after changes.
- Run All Units:
composer test:unit(orcomposer test) - Run Single Test (Filter):
vendor/bin/pest --filter 'UserCanLoginTest' - Run Single File:
vendor/bin/pest tests/Feature/AuthenticationTest.php
- Parallel Testing:
composer test:unitis configured for parallel execution.
- Check PHP Style:
composer test:lint(Runs Pint) - Fix PHP Style:
vendor/bin/pint - Static Analysis:
vendor/bin/phpstan analyse(Configured inphpstan.neon.dist) - JS/Blade Formatting:
npm run fix:prettier
Note: Do not create ad-hoc verification scripts. Use existing tests or write new Pest tests.
- Strict Types: Use
declare(strict_types=1);where appropriate, though check sibling files for consistency. - Naming:
- Use descriptive names.
- Boolean methods:
isRegistered(),hasPermission(), notregistered()orcheck(). - Variables:
$user,$statusPage, not$u,$sp.
- Controllers: Keep thin. Push logic to Actions, Services, or Models.
- Models: Use
FillableorGuardedexplicitly. - Imports: Sort alphabetically. Remove unused imports.
- Follow Filament v4 conventions for Resources, Pages, and Widgets.
- Use Filament's form components and table columns.
- Blade: Use components (
<x-cachet::...>) where available. - Alpine.js: Use
x-datafor component state. Avoid inline scripts where possible. - Tailwind: Use utility classes. Avoid custom CSS unless necessary.
Stick to the existing structure. Do not invent new top-level directories.
src/: Core package code (Models, Http, ServiceProviders).tests/: Pest tests (Feature, Unit).resources/views/: Blade templates.database/: Migrations, Factories, Seeders.workbench/: Testbench application skeleton.
-
Laravel Boost Guidelines:
- This project uses "Laravel Boost" rules.
- Focus on existing code conventions.
- No Verification Scripts: Trust unit/feature tests.
- Conciseness: Be concise in explanations.
- Documentation: Do not create
.mdfiles unless requested.
-
Debugging:
- Use
vendor/bin/testbench tinkerfor interactive debugging. - Use
browser-logstool if available for frontend issues.
- Use
- Plan: Identify necessary Models, Controllers, and Filament resources.
- Test: Create a Pest test in
tests/Feature.it('can create a status', function () { $user = User::factory()->create(); // ... });
- Implement: Write code in
src/. - Verify: Run
vendor/bin/pintandcomposer test:unit.
- "Class not found": Run
composer dump-autoload. - Frontend not updating: Run
npm run build. - Database issues: Check
workbench/databaseor run migrations in the test environment.
- Use Laravel's exception handling.
- Throw specific exceptions (e.g.,
ModelNotFoundException) rather than generic ones. - Log errors using
Log::error()with context.
- Type hint all method arguments and return types.
- Use Docblocks (
/** ... */) for:- Complex logic explanations.
phpstantype definitions (e.g.,/** @var array<string, int> $items */).- Deprecation notices.
Generated for AI Agents interacting with Cachet Core.
===
=== foundation rules ===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.
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.
- php - 8.3.30
- 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.
- Use descriptive names for variables and methods. For example,
isRegisteredForDiscounts, notdiscount(). - Check for existing components to reuse before writing a new one.
- Do not create verification scripts or tinker when tests cover that functionality and prove they work. Unit and feature tests are more important.
- Stick to existing directory structure; don't create new base folders without approval.
- Do not change the application's dependencies without approval.
- 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, orcomposer run dev. Ask them.
- You must only create documentation files if explicitly requested by the user.
- Be concise in your explanations - focus on what's important rather than explaining obvious details.
=== boost rules ===
- Laravel Boost is an MCP server that comes with powerful tools designed specifically for this application. Use them.
- Use the
list-artisan-commandstool when you need to call an Artisan command to double-check the available parameters.
- Whenever you share a project URL with the user, you should use the
get-absolute-urltool to ensure you're using the correct scheme, domain/IP, and port.
- Because Cachet is a Laravel package, developed with Testbench, you should run Tinker with
vendor/bin/testbench tinker. - You should use the
tinkertool when you need to execute PHP to debug code or query Eloquent models directly. - Use the
database-querytool when you only need to read from the database. - Use the
database-schematool to inspect table structure before writing migrations or models.
- You can read browser logs, errors, and exceptions using the
browser-logstool from Boost. - Only recent browser logs will be useful - ignore old logs.
- Boost comes with a powerful
search-docstool 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. - Search the documentation before making code changes to ensure we are taking the correct approach.
- 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. - Do not add package names to queries; package information is already shared. For example, use
test resource table, notfilament 4 test resource table.
- Simple Word Searches with auto-stemming - query=authentication - finds 'authenticate' and 'auth'.
- Multiple Words (AND Logic) - query=rate limit - finds knowledge containing both "rate" AND "limit".
- Quoted Phrases (Exact Position) - query="infinite scroll" - words must be adjacent and in that order.
- Mixed Queries - query=middleware "rate limit" - "middleware" AND exact phrase "rate limit".
- Multiple Queries - queries=["authentication", "middleware"] - ANY of these terms.
=== php rules ===
- Always use curly braces for control structures, even for single-line bodies.
- Use PHP 8 constructor property promotion in
__construct().public function __construct(public GitHub $github) { }
- Do not allow empty
__construct()methods with zero parameters unless the constructor is private.
- Always use explicit return type declarations for methods and functions.
- Use appropriate PHP type hints for method parameters.
protected function isAccessible(User $user, ?string $path = null): bool
{
...
}- Typically, keys in an Enum should be TitleCase. For example:
FavoritePerson,BestLake,Monthly.
- Prefer PHPDoc blocks over inline comments. Never use comments within the code itself unless the logic is exceptionally complex.
- Add useful array shape type definitions when appropriate.