/laravel-skill:laravel-patternsfrom laravel-skill
Provides placement rules for domain-driven Laravel applications: when to create an Action, Service, Repository, Query Class, or Value Object vs. using Eloquent directly. Use when writing, reviewing, or refactoring Laravel code touching application structure, data access, or class placement.
Ships in laravel-skill. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Placement rules for domain-driven Laravel applications: Action, Service, Repository, Query Class, Value Object. 63 rules across 9 sections.
Core philosophy: practicality over purity. Never take a greedy decision.
Builder.Reference these rules when:
app/Domain/app/ into bounded contextsRun the Decision Gate before writing any class: references/decision-gate.md.
Default answer: keep it in the Action, use Eloquent directly.
Q1. Single end-to-end use case? → ACTION
Q2. Called by 2+ Actions, or worth isolating? → SERVICE
Q3. Used in only one Action? → KEEP IT IN THE ACTION
Q4. Single-record CRUD (find / create /
update / delete)? → ELOQUENT DIRECTLY
(from an Action or Repository)
Q5. Backend may swap, OR the query earns a
name and its own tests? → REPOSITORY (+ Query Classes)
Q6. Two real implementations, a concrete
backend swap, or a host extension point? → INTERFACE
(otherwise one concrete class)
Q7. Callers pick one by a config or
request key? → FACTORY / REGISTRY
Ambiguous between Q4 and Q5? Choose Q4 — except for a list endpoint, which is always Q5.
These are the mistakes that survive review because each one looks locally reasonable:
Repositories/.laravel-rest-api skill.| About to write | Read |
|---|---|
Any new class under app/Domain/ | gate-run-decision-gate-first |
| An index / list / search endpoint | gate-reads-go-through-a-named-query, query-whitelist-sortable-columns |
| A create, update or delete use case | gate-action-for-use-case, action-one-use-case-end-to-end |
| An Action that only calls one thing | action-not-a-pass-through |
| A Repository interface | gate-repository-earns-its-name, repo-ship-implementation-and-binding |
| A query with filters, sorting or eager loads | query-owns-all-query-construction, query-single-handle-method |
| Logic a second Action now needs | gate-service-only-when-reused |
| A method with more than four parameters | vo-more-than-four-params, vo-group-related-parameters |
| Code that touches another domain | domain-no-cross-domain-models, domain-events-for-reactions |
| A notification, report or export class | layout-shared-module-owns-mechanism |
| An interface, factory, registry or base class | gate-earn-extension-seam |
| Behavior only some implementations need | gate-opt-in-capability-contract |
| A driver, provider or class chosen per deployment | config-select-deployable-variation |
| Anything reading configuration | config-never-env-outside-config |
| A sort or filter arriving as a string | vo-named-constructor-parses-input |
| A file you cannot place | layout-scope-based-co-location |
A vertical slice lands in this order — each step exists only if the step above it earned it:
Contracts/<X>RepositoryInterface.php — the Q5 trigger named in the docblockQueries/<BusinessQuestion>Query.php — one handle(), all clausesRepositories/Eloquent<X>Repository.php — implements the interfaceDomainServiceProvider — same change, never laterActions/<Verb><Noun>Action.php — only when state changeslaravel-rest-api)laravel-testing)^12.0 || ^13.0 and PHP ^8.3. If you need something these rules do not name, check the docs — never infer an API from its name.composer.json first; on Laravel 12 use the fallback the rule gives.rules/{slug}.md before adapting it to a case the example does not show.| # | Section | Impact | Prefix |
|---|---|---|---|
| 1 | The Decision Gate | CRITICAL | gate- |
| 2 | Actions | HIGH | action- |
| 3 | Services | HIGH | service- |
| 4 | Repositories | HIGH | repo- |
| 5 | Query Classes | HIGH | query- |
| 6 | Value Objects and Parameter Isolation | MEDIUM-HIGH | vo- |
| 7 | Directory and Namespace Layout | MEDIUM | layout- |
| 8 | Inter-Domain Communication | HIGH | domain- |
| 9 | Configuration and Environments | MEDIUM | config- |
gate-run-decision-gate-first — Name the trigger before creating any classgate-action-for-use-case — One use case means one Actiongate-service-only-when-reused — Extract a Service only when two Actions need itgate-eloquent-directly-by-default — Use Eloquent directly by defaultgate-repository-earns-its-name — A Repository must name its triggergate-query-class-and-repository-together — Query Classes and Repositories arrive togethergate-reads-go-through-a-named-query — A list endpoint is a named querygate-earn-extension-seam — Earn interfaces and factories from real variationgate-opt-in-capability-contract — Optional behavior is a second contract, not a wider oneaction-one-use-case-end-to-end — An Action orchestrates one use case end to endaction-keep-single-use-logic-inline — Keep single-use logic inside the Actionaction-naming-verb-noun — Name Actions <Verb><Noun>Actionaction-maps-request-to-value-objects — Map HTTP input to domain types at the edgeaction-not-a-pass-through — Never create an Action that only forwardsservice-two-or-more-actions — A Service serves two or more Actionsservice-stateless-and-focused — Services are stateless and context-agnosticservice-never-imports-query-classes — A Service never imports a Query Classservice-not-a-disguised-repository — A Service whose body is a query is a mislabeled Repositoryservice-naming-business-decision — Name Services after the business decisionrepo-interface-in-domain-contracts — Interface in Contracts/, implementation in Repositories/repo-domain-intent-methods — Repository methods express intent, not CRUDrepo-never-returns-builder — A Repository interface never returns a Builderrepo-never-accepts-request — A Repository never accepts a Requestrepo-no-base-repository — No generic BaseRepositoryrepo-small-focused-interface — Keep Repository interfaces under ~6 methodsrepo-bind-in-service-provider — Bind the interface in a service providerrepo-ship-implementation-and-binding — Interface, implementation and binding in one changerepo-inline-simple-delegate-complex — Inline simple queries, delegate complex onesquery-single-handle-method — Exactly one public method, handle()query-internal-to-repositories — Query Classes are internal to Repositoriesquery-name-the-business-question — Name the business question, not the DB operationquery-final-readonly-no-base-class — Plain final readonly, no abstract basequery-can-write — A Query Class may writequery-return-builder-or-execute — Return a Builder or execute, one per queryquery-compose-query-classes — Compose instead of duplicating clausesquery-whitelist-sortable-columns — Whitelist sortable columns in the Query Classquery-owns-all-query-construction — All query construction lives herevo-group-related-parameters — Group contextually related parametersvo-more-than-four-params — More than four parameters must be groupedvo-never-touches-builder — A Value Object never touches a Buildervo-no-single-scalar-wrapper — Never wrap a single unrelated scalarvo-pass-domain-objects-directly — Pass essential domain objects directlyvo-date-range-and-presets — Express named date ranges through an interfacevo-parameterized-presets — Parameterize presets instead of copying classesvo-composite-filter-per-query — Collapse a query's inputs into one composite filtervo-named-constructor-parses-input — Parse the wire format in a named constructorlayout-domain-first-structure — Organize by domain, not by layerlayout-scope-based-co-location — Scope decides placementlayout-no-top-level-service-repository-query — No top-level layer folderslayout-optional-folders-are-deliberate — A missing folder is a decisionlayout-contracts-vs-support — Contracts/ holds interfaces, Support/ holds implementationslayout-shared-module-owns-mechanism — A shared module owns the mechanism, not other domains' messagesdomain-public-vs-private-surface — A domain has a public surface and a private onedomain-no-cross-domain-models — Never import another domain's Models, Repositories or Queriesdomain-events-for-reactions — Use Domain Events for cross-domain reactionsdomain-open-host-service-for-sync — Use an Open Host Service for synchronous readsdomain-shared-kernel-concepts-only — The Shared Kernel holds concepts, never callsdomain-anti-corruption-layer — Wrap external upstreams in an Anti-Corruption Layerconfig-secrets-in-env-structure-in-config — Secrets in .env, structure in config/config-select-deployable-variation — Use config for deploy-time implementation choicesconfig-never-env-outside-config — Never call env() outside config/config-per-environment-overrides — Override per environment, not per branchconfig-cache-in-production — Cache config, routes and events in productionRead on demand — do not load all of these at once:
references/decision-gate.md — the gate, layer definitions, who may call whatreferences/directory-layout.md — full tree, folder meanings, CI guardsreferences/inter-domain-decision-guide.md — picking Event vs Open Host Service vs Shared Kernel vs ACLreferences/anti-patterns.md — 18 forbidden patterns with their grep signalsreferences/pre-completion-checklist.md — 31-question self-check before declaring doneexamples/orders-domain/ — one worked vertical slice with every layer in placeLoad in this order and stop when the answer is clear:
rules/gate-eloquent-directly-by-default.md
rules/query-internal-to-repositories.md
references/ file only when a rule points at one.AGENTS.md is every rule compiled into one document (~22k tokens), for agents that read the AGENTS.md convention. Do not load it when the individual rule files are reachable.
laravel-engineering — context tracing, reuse discipline and critical-path verificationlaravel-eloquent — what goes inside a Query Class: casts, scopes, N+1, pagination, transactions, raw SQLlaravel-rest-api — the edge: routing, binding, form requests, resources, authorization, error mappinglaravel-async — events, queued jobs, caching and schedulinglaravel-testing — how to test each layer defined hereAGENTS.md (opens in a new tab)README.md (opens in a new tab)examples/orders-domain/Actions/PlaceOrderAction.php (opens in a new tab)examples/orders-domain/Contracts/OrderRepositoryInterface.php (opens in a new tab)examples/orders-domain/Filters/OrderQueryFilter.php (opens in a new tab)examples/orders-domain/Http/OrderIndexController.php (opens in a new tab)examples/orders-domain/Http/SearchOrdersRequest.php (opens in a new tab)examples/orders-domain/Http/StoreOrderRequest.php (opens in a new tab)examples/orders-domain/Queries/ExpireAbandonedOrdersQuery.php (opens in a new tab)examples/orders-domain/Queries/SearchOrdersQuery.php (opens in a new tab)examples/orders-domain/README.md (opens in a new tab)examples/orders-domain/Repositories/EloquentOrderRepository.php (opens in a new tab)examples/orders-domain/Support/DateRange.php (opens in a new tab)examples/orders-domain/Support/Direction.php (opens in a new tab)examples/orders-domain/Support/Sorting.php (opens in a new tab)metadata.json (opens in a new tab)references/anti-patterns.md (opens in a new tab)references/decision-gate.md (opens in a new tab)references/directory-layout.md (opens in a new tab)references/inter-domain-decision-guide.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
6 skills in this plugin
/laravel-asyncAsynchronous and caching rules for Laravel — idempotent queued jobs with retries and backoff, domain events for side effects, queue separation and failure handling, deterministic cache keys with event-driven invalidation, and scheduled tasks that queue rather than block. Use when writing or reviewing jobs, events, listeners, queue configuration, caching or scheduled tasks, or when work is duplicated, lost, or blocking a request./laravel-eloquentEloquent and query-layer engineering rules for Laravel — eliminating N+1, choosing a pagination strategy, short atomic transactions, casts and scopes on the model, where raw SQL is allowed, and how migrations declare the schema those queries depend on. Use when writing or reviewing Eloquent models, migrations, query classes, repositories, exports or reporting queries, or when a Laravel endpoint is slow, leaking memory, or returning wrongly-typed columns./laravel-engineeringnpx claudepluginhub foysal50x/skills --plugin laravel-skillOther plugins' skills for the same job