Index of every page on this site: llms.txt
All skills
Run it yourself

Use when writing or reviewing ANY PHP code in a Labrodev Laravel project (Laravel 13+, PHP 8.5): creating a class of any kind, deciding which folder/namespace code belongs in, checking dependency direction between App/Layer and Core, applying final/readonly rules, or auditing code for architectural anti-patterns. This is the always-on foundation every other labrodev-* skill assumes.

  • 1 file
  • 8.8 KB
  • MIT
  • Updated 2 months ago
  • GitHub
Use this Skill: https://skilld.dev/gh/labrodev/laravel-playbook/labrodev-core

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

SKILL.md

≈100 tokens for metadata: the name and description. ≈2.1k when used: this file.

Description uses 5.0% of example budget

Before choosing a Skill, your Agent reads its name and description. All available Skills share that space.

  • A shorter description leaves more room for other Skills. This entry exceeds our 1% size suggestion.

In our Claude Code example, all Skill names and descriptions share 8,000 characters. This Skill uses ≈401 characters, or 5.0%.

The 1% threshold is a size suggestion. Longer descriptions can still fit.

Your model, settings, and other Skills decide how much text your Agent can read.

Example settings and source

The example uses a 200k-token context and default Claude Code settings. The count includes the name, description, separators, and when_to_use when present. Codex also counts local file paths.

Skit's source and limits: Codex 0.160.1, Claude Code 2.1.292.

Labrodev Core — structure, boundaries, headers, dependency injection, immutability

Part of the Labrodev playbook. The law for this skill lives in the always-on labrodev-core guideline (philosophy, structure, dependency law, golden paths, global code rules, anti-patterns, legacy zones) — this skill holds the craft: structure detail, canonical header templates, and edge cases. Per-file checks are folded into each component's rule file under rules/.

Project structure (canonical)

Logical layout. Physically, Core often lives in a separate Composer package checked out next to the app (e.g. ../core/src/Domain/...) — check composer.json. All rules apply to the logical module regardless of physical location.

src/Core/
├── Domain/{Domain}/            business logic, one bounded context per domain
│   ├── Actions/  Casts/  Collections/  Data/  Enums/  Events/  Exceptions/ (→ labrodev-exception skill)
│   ├── Factories/  Jobs/  Models/  Observers/  Payloads/
│   ├── Pipelines/  Policies/  Queries/  Rules/  Services/
│   └── Traits/  Utilities/
├── Feature/{FeatureName}/      isolated cross-domain workflows; promote to a Domain when stable
├── Infrastructure/{Integration}/  external adapters (payment, email, ERP, APIs); technical, not business → see the labrodev-infrastructure skill
├── Shared/                     generic base abstractions (base models, concerns, traits); no domain nouns
└── Support/                    technical helpers/utilities only; no business logic, no domain language

app/Layer/{Layer}/{Domain}/     delivery surfaces, e.g. Dashboard (Inertia UI), Api (JSON)
├── Controllers/                invokable HTTP endpoints, thin dispatchers
├── JsonControllers/            invokable JSON endpoints for in-page interactions
├── IndexQueries/               read-side listings/filters/pagination; never mutate
├── ViewModels/                 presentation-ready props; no business rules
├── Resources/                  explicit field allowlists for Inertia/JSON output; never mutate
└── Exports/                    CSV/Excel/PDF output; may use IndexQueries/ViewModels; never mutate
  • App/Layer/Dashboard/Booking/* and App/Layer/Api/Booking/* are two interfaces to the same Core/Domain/Booking module. Layers mirror domain names exactly but never duplicate domain behavior; route files mirror the same split (routes/dashboard/booking.php → labrodev-controller skill).
  • Every subfolder above names a playbook class-type concept — nothing else may appear (no domain-local Support/; such classes are Utilities/).
  • Core/Domain/User/ holds the mirror User model — Core's own model on the users table — because Core never imports App\ classes, App\Models\User included (→ labrodev-core guideline dependency law).
  • There is exactly one Request-less input boundary: controllers map raw input into Spatie Data objects (→ see the labrodev-data skill).

File header contract (canonical templates)

Naming pattern: namespace mirrors the folder path; class name states intent (→ labrodev-naming guideline).

Core class header — worked example, Booking domain (Core/Domain/Booking/Actions/BookingCreate.php):

<?php

declare(strict_types=1);

namespace Core\Domain\Booking\Actions;

use Core\Domain\Booking\Data\BookingData;
use Core\Domain\Booking\Models\Booking;

final readonly class BookingCreate
{
    public function __invoke(BookingData $bookingData): Booking
    {
        // full Action anatomy → see the labrodev-action skill
    }
}

Layer class header — worked example (app/Layer/Dashboard/Booking/ViewModels/BookingIndexViewModel.php):

<?php

declare(strict_types=1);

namespace App\Layer\Dashboard\Booking\ViewModels;

use Spatie\ViewModels\ViewModel;

final class BookingIndexViewModel extends ViewModel
{
    // full ViewModel anatomy → see the labrodev-viewmodel-resource skill
}

The root namespace prefix may differ when Core is a separate package (e.g. Vendor\Core\Domain\Booking\...) — the segment structure after the root is fixed.

Dependency injection — constructor, never resolve()

The law (no service location where the container can inject) is in the labrodev-core guideline. What it looks like:

Wrong — the Action is container-built, yet it locates its Query mid-body:

final readonly class BookingStatusUpdate
{
    public function __invoke(Booking $booking, BookingStatus $bookingStatus): Booking
    {
        return DB::transaction(function () use ($booking, $bookingStatus): Booking {
            resolve(BookingQuery::class)->byId($booking->id)->lockForUpdate()->firstOrFail();

            $booking->refresh();
            $booking->status = $bookingStatus;
            $booking->save();

            return $booking;
        });
    }
}

Right — the dependency is declared in the constructor and used through $this:

final readonly class BookingStatusUpdate
{
    public function __construct(
        private BookingQuery $bookingQuery,
    ) {}

    public function __invoke(Booking $booking, BookingStatus $bookingStatus): Booking
    {
        return DB::transaction(function () use ($booking, $bookingStatus): Booking {
            $this->bookingQuery->byId($booking->id)->lockForUpdate()->firstOrFail();

            $booking->refresh();
            $booking->status = $bookingStatus;
            $booking->save();

            return $booking;
        });
    }
}

Why: the constructor is the class's honest dependency list — readable at a glance, swappable in tests, and checked by PHPStan. A resolve() buried in a closure hides a dependency, defeats the puzzle-piece contract, and makes the class lie about what it needs. The parameter name mirrors the class short name (BookingQuery $bookingQuery) → labrodev-naming.

Where resolve() stays legitimate — because no constructor injection exists there:

  • public static methods: {Model}Rule gates, Utilities (resolve(BookingQuery::class) in BookingRule::periodIsAvailable() → labrodev-action).
  • Objects built with new outside the container: ViewModels (new BookingIndexViewModel(items: $bookings) → labrodev-viewmodel-resource), Spatie Data casters (→ labrodev-data).
  • Runtime resolvers picking an implementation by value (match ($channelType) { ChannelType::Slack => resolve(SlackNotifier::class), ... } → labrodev-infrastructure).
  • Tests (app(BookingCreate::class) → labrodev-testing).

If none of these applies, it goes in the constructor.

Immutability — why the exclusions exist

The law (final readonly where stateless; no readonly on Data subclasses, framework-extending classes, static-only classes) is in the labrodev-core guideline. The reasons:

  • Spatie's base Data class is not readonly, and PHP forbids a readonly class extending a non-readonly one — hence final class BookingData extends Data.
  • Models, Controllers, ViewModels, Resources, and IndexQueries extend non-readonly framework bases — same PHP constraint.
  • A static-only class (e.g. a Rule exposing only static methods) has no instance properties, so readonly is meaningless — write final class BookingRule.
  • Mutability and inheritance are intentional decisions, never defaults: if a class is not final or not readonly where it could be, there must be a stated reason.

Edge cases

  • Logical vs physical paths: Core/... references are logical modules. Physical homes vary (src/Core/..., packages/*/src/..., ../core/src/...). Verify via composer.json; apply rules to the logical module either way.
  • Cross-domain needs: one workflow spanning multiple domains with no natural home goes in Core/Feature/{FeatureName} with a small explicit API. When it stabilizes into a business concept, promote it to a proper Domain.
  • Abstract bases: an abstract class in Core/Shared (e.g. BaseModel) is the sanctioned exception to final. Concrete subclasses are still final.
  • Utilities drift: a domain Utility reused across domains with no domain terminology moves to Core/Support.
  • Infrastructure creep: the moment an Infrastructure adapter makes a business decision, that logic moves to a Domain Service.
  • Legacy zones: the exemption boundary (app/Http, app/Models, app/Actions/Fortify) is law → labrodev-core guideline. When a legacy-zone concept needs real behavior, build it in Core and delegate.

Source: SKILL.md on GitHub

No rule matched.

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No third-party reports yet.

Signed by skilld at 4e3053b. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub last month.

Steadyupdated 2 months ago
metadata
{
  "author": "labrodev"
}

README badge

README badge for labrodev/laravel-playbook/labrodev-core