/laravel-skill:laravel-testingfrom laravel-skill
Test strategy for layered Laravel apps: maps each layer (Action, Service, Repository, Query Class, Value Object, Controller) to its fitting test style. Hand-written fakes over mocks, real-database tests for queries, pure tests for value objects. Use when writing or reviewing Laravel tests, deciding what to fake, or diagnosing a flaky/slow suite.
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.
Test strategy for a layered Laravel application: 20 rules across 5 sections. Examples use Pest; every rule applies equally to PHPUnit.
The organizing idea: each layer has one test style that fits it. Testing an Action against a real database, or a Query Class against a mock, produces a slow suite that breaks on refactors and misses real bugs.
laravel-patterns skill| Layer | Style | Database | What it proves |
|---|---|---|---|
| Action | Unit, fake repository | No | The use case orchestrates correctly |
| Service | Unit, fakes | No | The business decision is right |
| Repository | Integration, factories | Yes | Methods return the right domain types |
| Query Class | Integration, factories | Yes | Which rows are in, out, and in what order |
| Value Object | Pure unit | No | Predicates and transformations |
| Controller / route | Feature test | Usually | Status, payload, authorization |
| Job / Listener | Unit handler, faked dispatch | Depends | Idempotency and effects |
| About to write | Read |
|---|---|
| A test for anything at all | strategy-layer-to-test-type, strategy-test-your-rules-not-the-framework |
| A test that needs a Repository | fake-repository-anonymous-class, fake-never-mock-eloquent |
| A test for a Query Class | db-refresh-database-and-factories, db-assert-inclusion-and-exclusion |
| A test for ordering or defaults | db-test-ordering-and-defaults |
| A test for an endpoint | http-assert-payload-shape, http-assert-authorization |
| A test that a job or event fired | http-assert-side-effects-dispatched, fake-framework-facades |
| A test involving dates or randomness | fake-time-and-randomness |
| A test for a Value Object | vo-test-predicates-directly, vo-never-hand-a-builder |
| A test for code that calls an API | fake-http-prevent-stray-requests |
| A test for queued mail or notifications | fake-assert-queued-not-sent |
| A test that feels pointless to write | strategy-if-testing-feels-silly |
^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 | Strategy by Layer | HIGH | strategy- |
| 2 | Fakes and Doubles | HIGH | fake- |
| 3 | Database Tests | HIGH | db- |
| 4 | Feature Tests | MEDIUM-HIGH | http- |
| 5 | Value Object Tests | MEDIUM | vo- |
strategy-layer-to-test-type — Match the test style to the layerstrategy-test-your-rules-not-the-framework — Test your rules, not Eloquentstrategy-if-testing-feels-silly — A pointless test means a pointless classstrategy-pest-and-suite-speed — Keep the suite fast enough to run on every savefake-repository-anonymous-class — Fake a Repository with an anonymous classfake-framework-facades — Queue::fake(), Event::fake(), Http::fake() and friendsfake-never-mock-eloquent — Never mock Eloquent or the query builderfake-time-and-randomness — Freeze time, seed randomnessfake-http-prevent-stray-requests — Fake the HTTP client and forbid stray requestsfake-assert-queued-not-sent — assertQueued() for anything ShouldQueuedb-refresh-database-and-factories — RefreshDatabase plus factories, never shared fixturesdb-assert-inclusion-and-exclusion — Assert what is excluded, not only what is includeddb-test-ordering-and-defaults — Cover ordering, defaults and the sort allow-listdb-test-eager-loading — Lock the N+1 fix in placedb-test-transactions-and-idempotency — Prove rollback and repeat-safetyhttp-assert-authorization — Unauthenticated, unpermitted, and another tenant's recordhttp-assert-payload-shape — Pin the contract, including keys that must not appearhttp-assert-side-effects-dispatched — Assert the jobs and events an endpoint queuesvo-test-predicates-directly — Construct, call, assert — no database, no containervo-never-hand-a-builder — A test needing a Builder means the boundary is broken// tests/Pest.php
uses(Tests\TestCase::class, RefreshDatabase::class)->in('Feature', 'Integration');
uses(Tests\TestCase::class)->in('Unit'); // no database
<!-- phpunit.xml -->
<env name="DB_CONNECTION" value="sqlite"/>
<env name="DB_DATABASE" value=":memory:"/>
<env name="QUEUE_CONNECTION" value="sync"/>
<env name="CACHE_STORE" value="array"/>
<env name="MAIL_MAILER" value="array"/>
// AppServiceProvider::boot() — makes N+1 and typos fail the suite
Model::shouldBeStrict(! $this->app->isProduction());
SQLite differs from MySQL and Postgres on JSON operators, full-text search, locking and strict-mode errors. Run the integration suite against the production engine in CI even when local runs use SQLite.
references/test-templates.md — copy-paste starting points for each layerreferences/checklist.md — pre-merge self-check for test coverageLoad in this order and stop when the answer is clear:
rules/fake-repository-anonymous-class.md
rules/db-assert-inclusion-and-exclusion.md
references/ file only when a rule points at one.AGENTS.md is every rule compiled into one document (~8k tokens), for agents that read the AGENTS.md convention. Do not load it when the individual rule files are reachable.
laravel-engineering — decide which changed boundary needs proof and keep docs currentlaravel-patterns — the layers these tests are organized aroundlaravel-eloquent — the query rules the database tests assertlaravel-rest-api — the endpoints the feature tests coverlaravel-async — testing idempotency, batches and cache invalidationAGENTS.md (opens in a new tab)README.md (opens in a new tab)metadata.json (opens in a new tab)references/checklist.md (opens in a new tab)references/test-templates.md (opens in a new tab)rules/_sections.md (opens in a new tab)rules/_template.md (opens in a new tab)rules/db-assert-inclusion-and-exclusion.md (opens in a new tab)rules/db-refresh-database-and-factories.md (opens in a new tab)rules/db-test-eager-loading.md (opens in a new tab)rules/db-test-ordering-and-defaults.md (opens in a new tab)rules/db-test-transactions-and-idempotency.md (opens in a new tab)rules/fake-assert-queued-not-sent.md (opens in a new tab)rules/fake-framework-facades.md (opens in a new tab)rules/fake-http-prevent-stray-requests.md (opens in a new tab)rules/fake-never-mock-eloquent.md (opens in a new tab)rules/fake-repository-anonymous-class.md (opens in a new tab)rules/fake-time-and-randomness.md (opens in a new tab)rules/http-assert-authorization.md (opens in a new tab)rules/http-assert-payload-shape.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