From 3516c5912f30bf8f98e6afdf6f254142fb5fd8d8 Mon Sep 17 00:00:00 2001 From: Sebastian Fix Date: Fri, 27 Feb 2026 22:45:40 +0100 Subject: [PATCH 1/9] Package transfomrer --- LICENSE.md | 21 + README.md | 92 ++- composer.json | 41 ++ guidelines.mdc | 15 +- resources/boost/skills/actions/SKILL.md | 95 +++ resources/boost/skills/blade/SKILL.md | 74 +++ resources/boost/skills/commands/SKILL.md | 78 +++ resources/boost/skills/controllers/SKILL.md | 83 +++ resources/boost/skills/dto/SKILL.md | 63 ++ resources/boost/skills/dusk/SKILL.md | 100 +++ resources/boost/skills/enums/SKILL.md | 76 +++ resources/boost/skills/events/SKILL.md | 102 +++ resources/boost/skills/exceptions/SKILL.md | 90 +++ resources/boost/skills/formrequests/SKILL.md | 91 +++ resources/boost/skills/general/SKILL.md | 75 +++ .../boost/skills/helperfunctions/SKILL.md | 96 +++ resources/boost/skills/helpers/SKILL.md | 70 +++ resources/boost/skills/interfaces/SKILL.md | 94 +++ resources/boost/skills/jobs/SKILL.md | 85 +++ resources/boost/skills/livewire/SKILL.md | 117 ++++ resources/boost/skills/middleware/SKILL.md | 90 +++ resources/boost/skills/migrations/SKILL.md | 77 +++ resources/boost/skills/models/SKILL.md | 92 +++ resources/boost/skills/observers/SKILL.md | 87 +++ resources/boost/skills/pesttesting/SKILL.md | 120 ++++ resources/boost/skills/php/SKILL.md | 101 +++ resources/boost/skills/phpstan/SKILL.md | 86 +++ resources/boost/skills/phpunit/SKILL.md | 94 +++ resources/boost/skills/policies/SKILL.md | 90 +++ resources/boost/skills/requests/SKILL.md | 81 +++ resources/boost/skills/resources/SKILL.md | 75 +++ resources/boost/skills/routing/SKILL.md | 68 ++ resources/boost/skills/saloon/SKILL.md | 130 ++++ resources/boost/skills/services/SKILL.md | 95 +++ resources/boost/skills/traits/SKILL.md | 97 +++ src/CodingGuidelinesServiceProvider.php | 27 + vendor/autoload.php | 22 + vendor/composer/ClassLoader.php | 579 ++++++++++++++++++ vendor/composer/LICENSE | 21 + vendor/composer/autoload_classmap.php | 10 + vendor/composer/autoload_namespaces.php | 9 + vendor/composer/autoload_psr4.php | 10 + vendor/composer/autoload_real.php | 38 ++ vendor/composer/autoload_static.php | 36 ++ vendor/composer/platform_check.php | 25 + 45 files changed, 3686 insertions(+), 32 deletions(-) create mode 100644 LICENSE.md create mode 100644 composer.json create mode 100644 resources/boost/skills/actions/SKILL.md create mode 100644 resources/boost/skills/blade/SKILL.md create mode 100644 resources/boost/skills/commands/SKILL.md create mode 100644 resources/boost/skills/controllers/SKILL.md create mode 100644 resources/boost/skills/dto/SKILL.md create mode 100644 resources/boost/skills/dusk/SKILL.md create mode 100644 resources/boost/skills/enums/SKILL.md create mode 100644 resources/boost/skills/events/SKILL.md create mode 100644 resources/boost/skills/exceptions/SKILL.md create mode 100644 resources/boost/skills/formrequests/SKILL.md create mode 100644 resources/boost/skills/general/SKILL.md create mode 100644 resources/boost/skills/helperfunctions/SKILL.md create mode 100644 resources/boost/skills/helpers/SKILL.md create mode 100644 resources/boost/skills/interfaces/SKILL.md create mode 100644 resources/boost/skills/jobs/SKILL.md create mode 100644 resources/boost/skills/livewire/SKILL.md create mode 100644 resources/boost/skills/middleware/SKILL.md create mode 100644 resources/boost/skills/migrations/SKILL.md create mode 100644 resources/boost/skills/models/SKILL.md create mode 100644 resources/boost/skills/observers/SKILL.md create mode 100644 resources/boost/skills/pesttesting/SKILL.md create mode 100644 resources/boost/skills/php/SKILL.md create mode 100644 resources/boost/skills/phpstan/SKILL.md create mode 100644 resources/boost/skills/phpunit/SKILL.md create mode 100644 resources/boost/skills/policies/SKILL.md create mode 100644 resources/boost/skills/requests/SKILL.md create mode 100644 resources/boost/skills/resources/SKILL.md create mode 100644 resources/boost/skills/routing/SKILL.md create mode 100644 resources/boost/skills/saloon/SKILL.md create mode 100644 resources/boost/skills/services/SKILL.md create mode 100644 resources/boost/skills/traits/SKILL.md create mode 100644 src/CodingGuidelinesServiceProvider.php create mode 100644 vendor/autoload.php create mode 100644 vendor/composer/ClassLoader.php create mode 100644 vendor/composer/LICENSE create mode 100644 vendor/composer/autoload_classmap.php create mode 100644 vendor/composer/autoload_namespaces.php create mode 100644 vendor/composer/autoload_psr4.php create mode 100644 vendor/composer/autoload_real.php create mode 100644 vendor/composer/autoload_static.php create mode 100644 vendor/composer/platform_check.php diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..a5267d1 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,21 @@ +# The MIT License (MIT) + +Copyright (c) codebar-ag + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/README.md b/README.md index af0bfae..0a05777 100644 --- a/README.md +++ b/README.md @@ -1,19 +1,33 @@ # Coding Guidelines -Shared Cursor AI rules and skills for codebar-ag Laravel projects. The AI uses these to follow consistent conventions for PHP, Laravel, testing, frontend, and services. +Shared Laravel AI coding guidelines and skills for codebar-ag projects. A Boost-first Composer package that ships 30+ skills for consistent conventions across PHP, Laravel, testing, frontend, and services. **Rule index:** See [RULES.md](RULES.md) for the full rule structure and file reference. --- -## Prerequisites +## Skills Summary -- A Laravel project where you want to use these guidelines -- [Laravel Boost](https://github.com/laravel/boost) (for syncing rules/skills into your project) +| Category | Skills | Description | +|----------|--------|-------------| +| **Laravel** | General, HelperFunctions, Models, Controllers, Migrations, Routing, FormRequests | Framework conventions, config/logging, Eloquent, routes, validation | +| **Backend** | Actions, Commands, DTO, Enums, Events, Exceptions, Helpers, Interfaces, Jobs, Middleware, Observers, Policies, Requests, Resources, Services, Traits | PHP architecture, single-purpose classes, API resources, queue jobs | +| **Frontend** | Blade, Livewire | Templates, components, reactive UI | +| **Testing** | PHPUnit, PestTesting, PHPStan, Dusk | Unit/feature tests, static analysis, browser tests | +| **Services** | Saloon | External API integrations (Saloon pattern) | + +**Total: 30 skills.** Each skill includes Rules, Examples, Anti-Patterns, and References. --- -## 1. Install Laravel Boost (if not already) +## Implementation Guide + +### Prerequisites + +- A Laravel project where you want to use these guidelines +- [Laravel Boost](https://github.com/laravel/boost) (required for skill discovery) + +### Step 1: Install Laravel Boost In your Laravel project: @@ -22,34 +36,70 @@ composer require laravel/boost --dev php artisan boost:install ``` ---- +### Step 2: Add this package + +**Option A — Composer (recommended for version pinning):** + +```bash +composer require codebar-ag/coding-guidelines --dev +``` -## 2. Activate the MCP server +**Option B — GitHub via Boost:** -If your editor supports MCP (Model Context Protocol), configure it to use the Boost MCP server so the AI has full context. See the [Laravel Boost documentation](https://github.com/laravel/boost) for your editor’s setup. +```bash +php artisan boost:add-skill codebar-ag/coding-guidelines +``` ---- +### Step 3: Sync skills -## 3. Add and sync the guidelines +```bash +php artisan boost:update +``` -Choose one of the following depending on how you work with this repo. +Boost automatically discovers skills from `vendor/codebar-ag/coding-guidelines/resources/boost/skills/` when the package is installed. -### When you are **not** pulling from `main` +### Step 4: Activate MCP (optional) -1. Copy the **`skills`** folder from this repo into your AI config folder (e.g. `.cursor/skills` or your editor’s equivalent). -2. In your Laravel project, run: +If your editor supports MCP (Model Context Protocol), configure it to use the Boost MCP server for full context. See the [Laravel Boost documentation](https://laravel.com/docs/boost) for your editor’s setup. - ```bash - php artisan boost:update - ``` +### Step 5: Override skills locally (optional) -### When you **are** pulling from the `main` branch (recommended) +To customize a skill for your project, create a file at `.ai/skills/{skill-name}/SKILL.md`. Your local version takes precedence over the package default. -In your Laravel project, add this repo as a Boost skill source and update: +Example: override the Models skill: + +``` +your-project/ +├── .ai/ +│ └── skills/ +│ └── models/ +│ └── SKILL.md ← Your custom version +``` + +--- + +## How It Works + +This package places skills in `resources/boost/skills/{skill-name}/SKILL.md`. Laravel Boost v2.2+ automatically discovers skills from vendor packages when you run `boost:update`. No custom sync commands — Boost handles everything. + +| Source | Path | +|--------|------| +| This package | `vendor/codebar-ag/coding-guidelines/resources/boost/skills/` | +| Project overrides | `.ai/skills/{skill-name}/SKILL.md` | + +--- + +## Updating + +When using Composer: ```bash -php artisan boost:add-skill codebar-ag/coding-guidelines +composer update codebar-ag/coding-guidelines php artisan boost:update ``` -After this, the AI in your project will automatically use the rules and skills from this repository. +When using `boost:add-skill`: + +```bash +php artisan boost:update +``` diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..08904c1 --- /dev/null +++ b/composer.json @@ -0,0 +1,41 @@ +{ + "name": "codebar-ag/coding-guidelines", + "description": "Shared Laravel AI coding guidelines and skills for codebar-ag projects. Boost-first Composer package.", + "keywords": [ + "laravel", + "boost", + "ai", + "cursor", + "coding-guidelines", + "skills" + ], + "license": "MIT", + "require": { + "php": "^8.2" + }, + "suggest": { + "laravel/boost": "Required for skill discovery. Install in your Laravel project." + }, + "autoload": { + "psr-4": { + "CodebarAg\\CodingGuidelines\\": "src/" + } + }, + "autoload-dev": { + "psr-4": { + "CodebarAg\\CodingGuidelines\\Tests\\": "tests/" + } + }, + "extra": { + "laravel": { + "providers": [ + "CodebarAg\\CodingGuidelines\\CodingGuidelinesServiceProvider" + ] + } + }, + "config": { + "sort-packages": true + }, + "minimum-stability": "dev", + "prefer-stable": true +} diff --git a/guidelines.mdc b/guidelines.mdc index 174d3ae..5f1c519 100644 --- a/guidelines.mdc +++ b/guidelines.mdc @@ -1,19 +1,12 @@ --- -description: References shared coding guidelines in the guidelines/ directory +description: References codebar-ag coding guidelines (installed via Laravel Boost) alwaysApply: true --- # Shared Coding Guidelines -This project has shared coding guidelines in the `guidelines/` directory -(synced from the codebar-ag/coding-guidelines repo). +This project uses **codebar-ag/coding-guidelines** — Laravel AI skills installed via [Laravel Boost](https://laravel.com/docs/boost). -Before making any code change, read and follow the relevant rule files: +Before making any code change, follow the relevant skills (PHP, Models, Actions, Livewire, etc.) that Boost has installed. Run `php artisan boost:update` to sync the latest skills. -- `guidelines/rules/testing/` -- PHPUnit, PHPStan conventions -- `guidelines/rules/frontend/` -- Blade, Livewire, Tailwind conventions -- `guidelines/rules/backend/` -- PHP typing, enums, DTOs, jobs conventions -- `guidelines/rules/laravel/` -- Models, controllers, migrations, routing conventions -- `guidelines/rules/services/` -- Saloon, DocuWare, Albatros API conventions - -See `guidelines/RULES.md` for the full structure and index. +See the [README](https://github.com/codebar-ag/coding-guidelines) for the full skills index. diff --git a/resources/boost/skills/actions/SKILL.md b/resources/boost/skills/actions/SKILL.md new file mode 100644 index 0000000..ab4ce2a --- /dev/null +++ b/resources/boost/skills/actions/SKILL.md @@ -0,0 +1,95 @@ +--- +name: actions +description: Single-purpose business logic classes that encapsulate one well-defined business operation. Actions are the primary location for business logic in Laravel applications, invoked from controllers, commands, or jobs. +--- + +**Name:** Actions +**Description:** Single-purpose business logic classes that encapsulate one well-defined business operation. Actions are the primary location for business logic in Laravel applications, invoked from controllers, commands, or jobs. +**Compatible Agents:** general-purpose, backend +**Tags:** app/Actions/**/*.php, laravel, php, backend, business-logic, action + +## Rules + +- Action classes live in `app/Actions/` +- Each action represents **one single business operation** — if you can't describe it in a single sentence, split it up +- Use a clear verb-noun naming pattern: `CreateInvoice`, `SendPasswordResetEmail`, `ArchiveExpiredSubscriptions` +- Never use vague names like `InvoiceAction` or `UserHandler` +- Actions expose a single public `execute()` method +- Keep the constructor for dependency injection only +- Actions are resolved via the service container +- Never include HTTP concerns (request, response, redirects) in an action +- Never put multi-domain orchestration in an action — use a Service instead +- Never put reusable formatting or utility logic in an action — use a Helper + +## Examples + +```php +namespace App\Actions; + +use App\Models\Invoice; +use App\Models\Order; +use App\Notifications\InvoiceCreatedNotification; + +class CreateInvoice +{ + public function __construct( + private readonly GenerateInvoicePdf $generatePdf, + ) {} + + public function execute(Order $order): Invoice + { + $invoice = Invoice::create([ + 'order_id' => $order->id, + 'amount' => $order->total, + 'due_date' => now()->addDays(30), + ]); + + $this->generatePdf->execute($invoice); + + $order->user->notify(new InvoiceCreatedNotification($invoice)); + + return $invoice; + } +} +``` + +```php +// Controller usage +class InvoiceController extends Controller +{ + public function store(StoreInvoiceRequest $request, CreateInvoice $action): JsonResponse + { + $order = Order::findOrFail($request->validated('order_id')); + $invoice = $action->execute($order); + + return new JsonResponse(new InvoiceResource($invoice), 201); + } +} + +// Command usage +class GenerateInvoicesCommand extends Command +{ + public function handle(CreateInvoice $action): int + { + Order::pending()->each(fn ($order) => $action->execute($order)); + + return self::SUCCESS; + } +} +``` + +## Anti-Patterns + +- Putting HTTP concerns (`Request`, `Response`, redirects) inside an action +- Creating multi-step orchestration across domains in a single action (use a Service) +- Naming an action vaguely: `InvoiceAction`, `UserHandler`, `DataProcessor` +- Adding multiple `execute()` methods or public methods beyond the single operation +- Adding business logic in a constructor — use `execute()` for that +- Performing database queries unrelated to the action's single responsibility + +## References + +- [Laravel Service Container](https://laravel.com/docs/container) +- Related: `Services/SKILL.md` — for multi-domain orchestration +- Related: `Jobs/SKILL.md` — for deferring actions to the queue +- Related: `Controllers/SKILL.md` — for how controllers delegate to actions diff --git a/resources/boost/skills/blade/SKILL.md b/resources/boost/skills/blade/SKILL.md new file mode 100644 index 0000000..8b8e0f1 --- /dev/null +++ b/resources/boost/skills/blade/SKILL.md @@ -0,0 +1,74 @@ +--- +name: blade +description: Laravel Blade template conventions covering components, output escaping, security, structure, and formatting. +--- + +**Name:** Blade Templates +**Description:** Laravel Blade template conventions covering components, output escaping, security, structure, and formatting. +**Compatible Agents:** general-purpose, frontend +**Tags:** resources/views/**/*.blade.php, laravel, php, frontend, blade, template, html + +## Rules + +- Use Blade components (``) for reusable UI pieces +- Prefer anonymous components for simple, presentation-only elements +- Use class-based components when logic is needed +- Use `{{ }}` for escaped output (default) — never output raw user input unescaped +- Use `{!! !!}` only when the content is explicitly safe (e.g., pre-sanitized HTML) +- No inline `