[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7D185K00ZKA6A9VCGA86WPR":3,"skill-same:01M7D185K00ZKA6A9VCGA86WPR":229},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":16,"sourceHtmlUrl":17,"categories":18,"keywords":19,"publishedAt":20,"linkOnly":21,"markdownContent":22,"markdownBody":23,"frontMatter":24,"refName":29,"commitSha":30,"skillDirectory":31,"forksCount":14,"repositoryHtmlUrl":32,"repositoryHomepageUrl":6,"ownerHtmlUrl":33,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":34,"install":35,"resources":48},"01M7D185K00ZKA6A9VCGA86WPR","api-skill",null,"Provides opinionated best practices and patterns for building production-ready REST APIs using Laravel. Use this skill when designing API endpoints, implementing resource controllers, or structuring JSON responses in a Laravel environment.","itsmejay18\u002FAI-Skills-for-My-Development-Stack","itsmejay18","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F167779943?v=4","01M7CZRFC6DDZA5V2CX8WDSZED","Jay Jemino Ababon ","01M7CZRFCVRNW1SFHSQXEJ3CQN",0,"MIT","https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F05-Backend-API-Development\u002Fapi-skill\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F05-Backend-API-Development\u002Fapi-skill\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: api-skill\ndescription: \"Provides opinionated best practices and patterns for building production-ready REST APIs using Laravel. Use this skill when designing API endpoints, implementing resource controllers, or structuring JSON responses in a Laravel environment.\"\ncompatibility: \"Requires Laravel 13+ and PHP 8.5+.\"\nlicense: MIT\nmetadata:\n  author: \"juststeveking\"\n  version: \"2.0\"\n---\n\n# API Skill for Laravel Developers\n\nThis skill defines the exact patterns and rules for building scalable, reliable, and modern REST APIs in Laravel. All guidance here is prescriptive. When in doubt, follow the rule.\n\n---\n\n## 1. Route Organisation\n\nStandalone APIs have **no `api` prefix** on any route. Routes live under `routes\u002Fapi\u002F` as follows:\n\n```\nroutes\u002F\n  api\u002F\n    routes.php       ← entry point, requires all resource files\n    auth.php\n    posts.php        ← one file per resource\n    users.php\n```\n\n`routes\u002Fapi\u002Froutes.php` loads in each resource using a prefix and naming:\n\n```php\n\u003C?php\n\ndeclare(strict_types=1);\n\nuse Illuminate\\Support\\Facades\\Route;\n\nRoute::as('auth:')->group(base_path(\n    path: 'routes\u002Fapi\u002Fauth.php',\n));\n\nRoute::as('posts:')->group(base_path(\n    path: 'routes\u002Fapi\u002Fposts.php',\n));\n```\n\nEach resource file owns its own version prefix. This keeps versioning explicit and debuggable per resource:\n\n```php\n\u003C?php\n\ndeclare(strict_types=1);\n\nuse App\\Http\\Controllers\\Posts;\nuse Illuminate\\Support\\Facades\\Route;\n\nRoute::prefix('v1\u002Fposts')->middleware(['auth:sanctum', 'throttle:api'])->group(function (): void {\n    Route::get('\u002F', Posts\\V1\\IndexController::class)->name('v1:index');\n    Route::post('\u002F', Posts\\V1\\StoreController::class)->name('v1:store');\n    Route::get('\u002F{post}', Posts\\V1\\ShowController::class)->name('v1:show');\n    Route::put('\u002F{post}', Posts\\V1\\UpdateController::class)->name('v1:update');\n    Route::delete('\u002F{post}', Posts\\V1\\DestroyController::class)->name('v1:destroy');\n});\n```\n\n- Always version from day one.\n- Always use named routes, namespaced to their version (e.g. `posts:v1:index` and `posts:v1:store`).\n- The `throttle:api` middleware must always be present.\n\n---\n\n## 2. Single-Action Invokable Controllers\n\nEvery controller is a `final` single-action invokable class. No resourceful controllers. No multiple methods per class. Just an invokable action and a constructor for any dependency injection.\n\nControllers live under `app\u002FHttp\u002FControllers\u002F{Resource}\u002F{Version}\u002F`:\n\n```\napp\u002FHttp\u002FControllers\u002FPosts\u002FV1\u002F\n  IndexController.php\n  ShowController.php\n  StoreController.php\n  UpdateController.php\n  DestroyController.php\n```\n\nDependencies are always injected via the constructor. Never use Facades, `app()`, or `resolve()` inside a controller. The `__invoke` method handles the request and returns a response:\n\n```php\n\u003C?php\n\ndeclare(strict_types=1);\n\nnamespace App\\Http\\Controllers\\Posts\\V1;\n\nuse App\\Actions\\Posts\\StorePostAction;\nuse App\\Http\\Requests\\Posts\\V1\\StoreRequest;\nuse App\\Http\\Resources\\PostResource;\nuse Illuminate\\Http\\JsonResponse;\nuse Symfony\\Component\\HttpFoundation\\Response;\n\nfinal class StoreController\n{\n    public function __construct(\n        private readonly StorePostAction $action,\n    ) {}\n\n    public function __invoke(StoreRequest $request): JsonResponse\n    {\n        $post = $this->action->handle(\n            payload: $request->payload(),\n        );\n\n        return new JsonResponse(\n            data: new PostResource($post),\n            status: Response::HTTP_CREATED,\n        );\n    }\n}\n```\n\n---\n\n## 3. Form Requests and Payloads (DTOs)\n\nEvery state-mutating endpoint uses a **Form Request**. Form Requests live under `app\u002FHttp\u002FRequests\u002F{Resource}\u002F{Version}\u002F`.\n\nThe Form Request **must** expose a `payload()` method that returns a typed DTO from `app\u002FHttp\u002FPayloads\u002F`. This keeps controllers free of array handling and makes the data contract explicit:\n\n```php\n\u003C?php\n\ndeclare(strict_types=1);\n\nnamespace App\\Http\\Requests\\Posts\\V1;\n\nuse App\\Http\\Payloads\\Posts\\StorePayload;\nuse Illuminate\\Foundation\\Http\\FormRequest;\n\nfinal class StoreRequest extends FormRequest\n{\n    public function authorize(): bool\n    {\n        return true;\n    }\n\n    public function rules(): array\n    {\n        return [\n            'title'   => ['required', 'string', 'max:255'],\n            'content' => ['required', 'string'],\n        ];\n    }\n\n    public function payload(): StorePayload\n    {\n        return new StorePayload(\n            title:   $this->string('title')->toString(),\n            content: $this->string('content')->toString(),\n            userId:  $this->user()->id,\n        );\n    }\n}\n```\n\n**Payloads (DTOs)** are plain PHP objects. They have a typed constructor and a `toArray()` method that returns what Eloquent expects. They live in `app\u002FHttp\u002FPayloads\u002F`:\n\n```php\n\u003C?php\n\ndeclare(strict_types=1);\n\nnamespace App\\Http\\Payloads\\Posts;\n\nfinal class StorePayload\n{\n    public function __construct(\n        public readonly string $title,\n        public readonly string $content,\n        public readonly string $userId,\n    ) {}\n\n    public function toArray(): array\n    {\n        return [\n            'title'   => $this->title,\n            'content' => $this->content,\n            'user_id' => $this->userId,\n        ];\n    }\n}\n```\n\n---\n\n## 4. API Resources\n\nAlways use Laravel's Eloquent API Resources to transform model data. Generate them with the `--json-api` CLI flag:\n\n```bash\nphp artisan make:resource PostResource --json-api\n```\n\nResources live under `app\u002FHttp\u002FResources\u002F`. They define the contract for what consumers receive. Never return raw models or plain arrays from a controller.\n\nCall `JsonResource::withoutWrapping()` in `AppServiceProvider::boot()` to disable the automatic `data` envelope globally. This ensures resources serialise consistently whether returned directly from a controller or encoded inside a `JsonResponse`:\n\n```php\nuse Illuminate\\Http\\Resources\\Json\\JsonResource;\n\npublic function boot(): void\n{\n    JsonResource::withoutWrapping();\n}\n```\n\n---\n\n## 5. HTTP Status Codes\n\nAlways use Symfony's `Response::HTTP_*` constants. Never use bare integers. This makes intent readable at a glance:\n\n| Scenario | Constant |\n|---|---|\n| Successful read | `Response::HTTP_OK` |\n| Resource created | `Response::HTTP_CREATED` |\n| Accepted for background processing | `Response::HTTP_ACCEPTED` |\n| Successful delete (no body) | `Response::HTTP_NO_CONTENT` |\n| Validation failed | `Response::HTTP_UNPROCESSABLE_ENTITY` |\n| Unauthenticated | `Response::HTTP_UNAUTHORIZED` |\n| Forbidden | `Response::HTTP_FORBIDDEN` |\n| Not found | `Response::HTTP_NOT_FOUND` |\n| Server error | `Response::HTTP_INTERNAL_SERVER_ERROR` |\n\nImport: `use Symfony\\Component\\HttpFoundation\\Response;`\n\n---\n\n## 6. Error Handling — RFC 9457 Problem Details\n\nAll error responses follow [RFC 9457 Problem Details](https:\u002F\u002Fwww.rfc-editor.org\u002Frfc\u002Frfc9457). The response shape is:\n\n```json\n{\n    \"type\": \"https:\u002F\u002Fexample.com\u002Fproblems\u002Fvalidation-error\",\n    \"title\": \"Validation Error\",\n    \"status\": 422,\n    \"detail\": \"The given data was invalid.\",\n    \"errors\": {\n        \"title\": [\"The title field is required.\"]\n    }\n}\n```\n\nRFC 9457 also requires responses to be served with `Content-Type: application\u002Fproblem+json`, not `application\u002Fjson`. Enforce both the shape and the header through a single `ProblemResponse` class that implements Laravel's `Responsable` interface, living at `app\u002FHttp\u002FResponses\u002FProblemResponse.php`. Every exception handler closure returns a `ProblemResponse` — no raw arrays, no ad-hoc `JsonResponse` construction:\n\n```php\nreturn new ProblemResponse(\n    type:   'https:\u002F\u002Fexample.com\u002Fproblems\u002Fnot-found',\n    title:  'Not Found',\n    status: Response::HTTP_NOT_FOUND,\n    detail: 'The requested resource could not be found.',\n);\n```\n\nThe exception handler in `bootstrap\u002Fapp.php` is responsible for rendering **all** exceptions. No exception should ever produce an HTML response on an API route. At minimum, the following must be handled explicitly:\n\n| Exception | Status | Problem type slug |\n|---|---|---|\n| `ValidationException` | `422` | `validation-error` |\n| `AuthenticationException` | `401` | `unauthenticated` |\n| `AuthorizationException` | `403` | `forbidden` |\n| `ModelNotFoundException` | `404` | `not-found` |\n| `Throwable` (catch-all) | `500` | `server-error` |\n\nThe catch-all ensures nothing falls through to Laravel's default HTML error page. See [references\u002FCONVENTIONS.md](references\u002FCONVENTIONS.md) for the full `ProblemResponse` implementation and handler.\n\n---\n\n## 7. Authentication — Laravel Sanctum (Stateless Tokens)\n\nAll API routes are protected with Laravel Sanctum using stateless API tokens. Never use session-based authentication for API routes.\n\n- Middleware: `auth:sanctum`\n- Token abilities\u002Fscopes are used to restrict what a token can do\n- Registration and login flows are synchronous — token issuance must complete in the same request\n\n```php\n\u002F\u002F Protecting routes\nRoute::middleware(['auth:sanctum', 'throttle:api'])->group(function (): void {\n    \u002F\u002F ...\n});\n\n\u002F\u002F Checking abilities in a controller\u002Faction\n$request->user()->tokenCan('posts:create');\n```\n\n---\n\n## 8. Authorization — Policies\n\nAuthentication (section 7) confirms who the user is. Authorization confirms what they can do. Use **Laravel Policies** for resource-level access control.\n\nAuthorization belongs in the Form Request's `authorize()` method — not in the controller, not in the Action:\n\n```php\npublic function authorize(): bool\n{\n    return $this->user()->can('update', $this->route('post'));\n}\n```\n\nPolicies live in `app\u002FPolicies\u002F`. A failed authorization throws an `AuthorizationException`, which the exception handler (section 6) renders as a `403 Forbidden` Problem Details response.\n\nActions operate on data that has already been validated and authorized. Never put policy checks inside an Action.\n\n---\n\n## 9. The Action Pattern\n\nAll business logic lives in **Action classes** under `app\u002FActions\u002F{Resource}\u002F`. Controllers orchestrate, Actions execute. One action per operation.\n\nActions are injected into controllers via the constructor. They receive a DTO and return a model or value:\n\n```php\n\u003C?php\n\ndeclare(strict_types=1);\n\nnamespace App\\Actions\\Posts;\n\nuse App\\Http\\Payloads\\Posts\\StorePayload;\nuse App\\Models\\Post;\nuse Illuminate\\Database\\DatabaseManager;\n\nfinal class StorePostAction\n{\n    public function __construct(\n        private readonly DatabaseManager $database,\n    ) {}\n\n    public function handle(StorePayload $payload): Post\n    {\n        return $this->database->transaction(\n            callback: fn (): Post => Post::query()->create(\n                attributes: $payload->toArray(),\n            ),\n        );\n    }\n}\n```\n\nEvery action that writes to the database **must** be wrapped in `$this->database->transaction()` using the injected `DatabaseManager`.\n\n---\n\n## 10. Background Jobs — Non-Blocking Requests\n\nPrefer non-blocking API responses. When an operation can be deferred, dispatch a job and return `202 Accepted`:\n\n```php\n\u003C?php\n\ndeclare(strict_types=1);\n\nnamespace App\\Actions\\Posts;\n\nuse App\\Http\\Payloads\\Posts\\StorePayload;\nuse App\\Jobs\\Posts\\StorePostJob;\n\nfinal class StorePostAction\n{\n    public function handle(StorePayload $payload): void\n    {\n        dispatch(new StorePostJob($payload));\n    }\n}\n```\n\n```php\n\u002F\u002F Controller\nreturn new JsonResponse(status: Response::HTTP_ACCEPTED);\n```\n\nWhen a job receives an Eloquent model, use the `SerializesModels` trait alongside `Queueable`. This stores the model's class and key on the queue rather than the full serialized object, and re-fetches it fresh when the job runs. Because the trait restores model properties via `__wakeup()`, model constructor properties must not be `readonly`:\n\n```php\nuse Illuminate\\Contracts\\Queue\\ShouldQueue;\nuse Illuminate\\Foundation\\Queue\\Queueable;\nuse Illuminate\\Queue\\SerializesModels;\n\nfinal class DestroyPostJob implements ShouldQueue\n{\n    use Queueable;\n    use SerializesModels;\n\n    public function __construct(\n        private Post $post, \u002F\u002F not readonly — SerializesModels rehydrates via __wakeup()\n    ) {}\n}\n```\n\n**Exceptions to non-blocking:**\n- User registration — the user needs a token immediately.\n- Login \u002F token issuance — must be synchronous.\n- Any operation where the response body is needed by the client to proceed.\n\nUse judgement. If the client cannot function without the result, make it synchronous.\n\n---\n\n## 11. Dependency Injection\n\nAlways inject dependencies via the constructor. Never use:\n\n- `Facades` (unless there is no alternative.)\n- `app()` helper\n- `resolve()` helper\n\nIf you know you need a class, declare it in the constructor. Laravel's container will resolve it automatically.\n\n```php\n\u002F\u002F Correct\nfinal class StoreController\n{\n    public function __construct(\n        private readonly StorePostAction $action,\n    ) {}\n}\n\n\u002F\u002F Wrong — never do this inside a method\npublic function __invoke(): JsonResponse\n{\n    $action = app(StorePostAction::class); \u002F\u002F ❌\n}\n```\n\n---\n\n## 12. Pagination\n\nAlways use `simplePaginate()`. It avoids the expensive `COUNT(*)` query of `paginate()` and keeps the response lean:\n\n```php\nPost::query()->simplePaginate(perPage: 15);\n```\n\nNever use `paginate()` on API endpoints.\n\n---\n\n## 13. Rate Limiting\n\nEvery API route group must have `throttle:api` middleware. No endpoint is ever unthrottled. Define rate limiters in `App\\Providers\\AppServiceProvider` (or a dedicated `RateLimitServiceProvider`):\n\n```php\nRateLimiter::for('api', function (Request $request): Limit {\n    return Limit::perMinute(60)->by($request->user()?->id ?: $request->ip());\n});\n```\n\n---\n\n## 14. Query Filtering — Spatie Laravel Query Builder\n\nUse [Spatie Laravel Query Builder](https:\u002F\u002Fgithub.com\u002Fspatie\u002Flaravel-query-builder) for all filterable list endpoints. Never build raw query strings manually:\n\n```php\n\u003C?php\n\ndeclare(strict_types=1);\n\nnamespace App\\Http\\Controllers\\Posts\\V1;\n\nuse App\\Http\\Resources\\PostResource;\nuse App\\Models\\Post;\nuse Illuminate\\Http\\Resources\\Json\\AnonymousResourceCollection;\nuse Spatie\\QueryBuilder\\AllowedFilter;\nuse Spatie\\QueryBuilder\\QueryBuilder;\n\nfinal class IndexController\n{\n    public function __invoke(): AnonymousResourceCollection\n    {\n        $posts = QueryBuilder::for(Post::class)\n            ->allowedFilters([\n                AllowedFilter::exact('status'),\n                AllowedFilter::partial('title'),\n            ])\n            ->allowedSorts(['created_at', 'title'])\n            ->simplePaginate(perPage: 15);\n\n        return PostResource::collection($posts);\n    }\n}\n```\n\n---\n\n## 15. Testing\n\nTest from the **outside in**. Drive tests through HTTP — assert on the response, not on internals. Cover both the happy path and the unhappy paths.\n\n```php\nit('creates a post and returns 201', function (): void {\n    $user = User::factory()->create();\n\n    $this->actingAs($user)->postJson('\u002Fv1\u002Fposts', [\n        'title'   => 'Hello World',\n        'content' => 'This is the content.',\n    ])->assertStatus(\n        Response::HTTP_CREATED,\n    )->assertJsonPath('title', 'Hello World');\n});\n\nit('returns 422 when title is missing', function (): void {\n    $user = User::factory()->create();\n\n    $this->actingAs($user)->postJson('\u002Fv1\u002Fposts', [\n        'content' => 'Missing title.',\n    ])->assertStatus(\n        Response::HTTP_UNPROCESSABLE_ENTITY,\n    )->assertJsonPath('status', 422)->assertJsonPath('title', 'Validation Error');\n});\n```\n\n---\n\n## 16. API Versioning — Sunset Middleware\n\nWhen a versioned endpoint is scheduled for removal, signal this to consumers using the `Sunset` HTTP header ([RFC 8594](https:\u002F\u002Fwww.rfc-editor.org\u002Frfc\u002Frfc8594)). This gives clients advance warning to migrate before the endpoint disappears.\n\nCreate a `Sunset` middleware at `app\u002FHttp\u002FMiddleware\u002FSunset.php`:\n\n```php\n\u003C?php\n\ndeclare(strict_types=1);\n\nnamespace App\\Http\\Middleware;\n\nuse Closure;\nuse DateTimeImmutable;\nuse DateTimeInterface;\nuse Illuminate\\Http\\Request;\nuse Symfony\\Component\\HttpFoundation\\Response;\n\nfinal class Sunset\n{\n    public function handle(Request $request, Closure $next, string $date): Response\n    {\n        $response = $next($request);\n\n        $response->headers->set(\n            'Sunset',\n            (new DateTimeImmutable($date))->format(DateTimeInterface::RFC7231),\n        );\n\n        return $response;\n    }\n}\n```\n\nApply it per route group in the resource file when v1 has a known deprecation date:\n\n```php\nRoute::prefix('v1\u002Fposts')\n    ->middleware(['auth:sanctum', 'throttle:api', 'sunset:2026-12-31'])\n    ->group(function (): void {\n        \u002F\u002F v1 routes — sunset date is communicated on every response\n    });\n```\n\nThe v2 routes live in the same resource file without the middleware:\n\n```php\nRoute::prefix('v2\u002Fposts')\n    ->middleware(['auth:sanctum', 'throttle:api'])\n    ->group(function (): void {\n        \u002F\u002F v2 routes\n    });\n```\n\nRegister the middleware alias in `bootstrap\u002Fapp.php`:\n\n```php\n->withMiddleware(function (Middleware $middleware): void {\n    $middleware->alias([\n        'sunset' => \\App\\Http\\Middleware\\Sunset::class,\n    ]);\n})\n```\n\n---\n\n## 17. Forcing JSON Responses\n\nLaravel's exception handler only returns JSON when `$request->expectsJson()` is true — which checks for the `Accept: application\u002Fjson` header. If a client omits it, some exceptions (particularly those thrown before the handler fires, such as middleware failures) can still return HTML.\n\nFix this with a `ForceJsonResponse` middleware at `app\u002FHttp\u002FMiddleware\u002FForceJsonResponse.php` that sets the header on every inbound request:\n\n```php\n\u003C?php\n\ndeclare(strict_types=1);\n\nnamespace App\\Http\\Middleware;\n\nuse Closure;\nuse Illuminate\\Http\\Request;\nuse Symfony\\Component\\HttpFoundation\\Response;\n\nfinal class ForceJsonResponse\n{\n    public function handle(Request $request, Closure $next): Response\n    {\n        $request->headers->set('Accept', 'application\u002Fjson');\n\n        return $next($request);\n    }\n}\n```\n\nRegister it as the first middleware on all API routes in `bootstrap\u002Fapp.php`:\n\n```php\n->withMiddleware(function (Middleware $middleware): void {\n    $middleware->alias([\n        'sunset'            => \\App\\Http\\Middleware\\Sunset::class,\n        'force.json'        => \\App\\Http\\Middleware\\ForceJsonResponse::class,\n    ]);\n})\n```\n\nApply it at the top of every resource route group:\n\n```php\nRoute::prefix('v1\u002Fposts')\n    ->middleware(['force.json', 'auth:sanctum', 'throttle:api'])\n    ->group(function (): void {\n        \u002F\u002F ...\n    });\n```\n\n---\n\n## 18. CORS\n\nA standalone API will be called from origins other than its own domain. Laravel includes `HandleCors` middleware out of the box, backed by `config\u002Fcors.php`.\n\nFor a standalone API, set `paths` to `['*']` — there is no web prefix to protect:\n\n```php\n\u002F\u002F config\u002Fcors.php\nreturn [\n    'paths'                    => ['*'],\n    'allowed_methods'          => ['*'],\n    'allowed_origins'          => ['*'], \u002F\u002F lock this down per environment\n    'allowed_origins_patterns' => [],\n    'allowed_headers'          => ['*'],\n    'exposed_headers'          => [],\n    'max_age'                  => 0,\n    'supports_credentials'     => false,\n];\n```\n\nIn production, replace `allowed_origins: ['*']` with an explicit list of trusted origins. Drive it from an environment variable so it can vary across environments without a code change:\n\n```php\n'allowed_origins' => explode(',', env('CORS_ALLOWED_ORIGINS', '*')),\n```\n\n`HandleCors` is applied globally by Laravel's default middleware stack, so no per-route changes are needed.\n\n---\n\n## 19. Code Quality Standards\n\nEvery PHP file in the project must meet these standards without exception:\n\n- **`declare(strict_types=1)`** on every file, always the first statement after the opening tag\n- **`final`** on every class — controllers, actions, payloads, jobs, middleware, resources — unless explicitly designed for extension\n- **`match`** over `if\u002Felseif` chains and nested ternaries wherever a value is being selected\n- **Named arguments** on constructor calls and method calls with multiple parameters — this is already demonstrated throughout the examples and is required, not optional\n- **Full type coverage** — typed properties, typed parameters, typed return types on every method\n- **PSR-12** naming and formatting conventions throughout\n\n```php\n\u003C?php \u002F\u002F ✓\n\ndeclare(strict_types=1); \u002F\u002F ✓ always first\n\nnamespace App\\Actions\\Posts;\n\nfinal class StorePostAction \u002F\u002F ✓ final\n{\n    public function handle(StorePayload $payload): Post \u002F\u002F ✓ fully typed\n    {\n        return $this->database->transaction(\n            callback: fn (): Post => Post::query()->create( \u002F\u002F ✓ named argument\n                attributes: $payload->toArray(),\n            ),\n        );\n    }\n}\n```\n\n---\n\n## 20. Model Identifiers — ULIDs\n\nNever use auto-increment integer IDs on API-facing models. Integer IDs expose record counts, enable enumeration attacks, and create ordering assumptions consumers should not rely on.\n\nAlways use Laravel's `HasUlids` trait:\n\n```php\n\u003C?php\n\ndeclare(strict_types=1);\n\nnamespace App\\Models;\n\nuse Illuminate\\Database\\Eloquent\\Concerns\\HasUlids;\nuse Illuminate\\Database\\Eloquent\\Model;\n\nfinal class Post extends Model\n{\n    use HasUlids;\n}\n```\n\nLaravel handles ULID generation automatically. No migration changes beyond defining the primary key column as `string` (26 characters) are required:\n\n```php\n$table->ulid('id')->primary();\n```\n\n---\n\n## 21. Model Strictness\n\nCall `Model::shouldBeStrict()` in `AppServiceProvider::boot()`. This enables three protections simultaneously:\n\n- **Prevents lazy loading** — any unloaded relationship accessed outside of `with()` throws immediately, surfacing N+1 queries during development\n- **Prevents silently discarded attributes** — assigning an attribute not in `$fillable` throws rather than silently ignoring it\n- **Prevents accessing missing attributes** — reading an attribute that doesn't exist on the model throws rather than returning `null`\n\n```php\nuse Illuminate\\Database\\Eloquent\\Model;\n\npublic function boot(): void\n{\n    Model::shouldBeStrict();\n\n    JsonResource::withoutWrapping();\n\n    RateLimiter::for('api', function (Request $request): Limit {\n        return Limit::perMinute(60)->by(\n            key: $request->user()?->id ?: $request->ip(),\n        );\n    });\n}\n```\n\nThese are development-time errors by design. Fix the underlying issue — don't suppress the exception.\n\n---\n\n## 22. Anti-patterns\n\nThe following are explicitly prohibited. If you find yourself reaching for any of these, stop and apply the correct pattern instead.\n\n| Anti-pattern | Why | What to do instead |\n|---|---|---|\n| Auto-increment integer primary keys | Exposes record counts, enables enumeration | Use `HasUlids` (section 20) |\n| Business logic in models (scopes excluded) | Violates single responsibility, untestable in isolation | Use Actions (section 9) |\n| Multi-method or resourceful controllers | Obscures intent, harder to locate logic | Single-action invokable controllers (section 2) |\n| Returning raw models or arrays from controllers | Leaks schema, no transformation layer | Always use API Resources (section 4) |\n| `app()`, `resolve()`, or Facades in controllers\u002Factions | Hides dependencies, harder to test | Constructor injection (section 11) |\n| `DB::transaction()` Facade | Same as above — hides the dependency | Inject `DatabaseManager` (section 9) |\n| `paginate()` on list endpoints | Runs an expensive `COUNT(*)` | Always `simplePaginate()` (section 12) |\n| Unthrottled routes | Exposes all endpoints to brute force and abuse | Always `throttle:api` (section 13) |\n| HTML error responses on API routes | Breaks every API client | `ForceJsonResponse` + full exception handler (sections 6, 17) |\n| Skipping `declare(strict_types=1)` | Silent type coercion bugs | Required on every file (section 19) |\n| Authorization checks in Actions | Actions receive already-authorized data | Authorize in Form Request `authorize()` (section 8) |\n\n---\n\n## References\n\nFor detailed folder structure and naming conventions, see [references\u002FCONVENTIONS.md](references\u002FCONVENTIONS.md).\n","# API Skill for Laravel Developers\n\nThis skill defines the exact patterns and rules for building scalable, reliable, and modern REST APIs in Laravel. All guidance here is prescriptive. When in doubt, follow the rule.\n\n---\n\n## 1. Route Organisation\n\nStandalone APIs have **no `api` prefix** on any route. Routes live under `routes\u002Fapi\u002F` as follows:\n\n```\nroutes\u002F\n  api\u002F\n    routes.php       ← entry point, requires all resource files\n    auth.php\n    posts.php        ← one file per resource\n    users.php\n```\n\n`routes\u002Fapi\u002Froutes.php` loads in each resource using a prefix and naming:\n\n```php\n\u003C?php\n\ndeclare(strict_types=1);\n\nuse Illuminate\\Support\\Facades\\Route;\n\nRoute::as('auth:')->group(base_path(\n    path: 'routes\u002Fapi\u002Fauth.php',\n));\n\nRoute::as('posts:')->group(base_path(\n    path: 'routes\u002Fapi\u002Fposts.php',\n));\n```\n\nEach resource file owns its own version prefix. This keeps versioning explicit and debuggable per resource:\n\n```php\n\u003C?php\n\ndeclare(strict_types=1);\n\nuse App\\Http\\Controllers\\Posts;\nuse Illuminate\\Support\\Facades\\Route;\n\nRoute::prefix('v1\u002Fposts')->middleware(['auth:sanctum', 'throttle:api'])->group(function (): void {\n    Route::get('\u002F', Posts\\V1\\IndexController::class)->name('v1:index');\n    Route::post('\u002F', Posts\\V1\\StoreController::class)->name('v1:store');\n    Route::get('\u002F{post}', Posts\\V1\\ShowController::class)->name('v1:show');\n    Route::put('\u002F{post}', Posts\\V1\\UpdateController::class)->name('v1:update');\n    Route::delete('\u002F{post}', Posts\\V1\\DestroyController::class)->name('v1:destroy');\n});\n```\n\n- Always version from day one.\n- Always use named routes, namespaced to their version (e.g. `posts:v1:index` and `posts:v1:store`).\n- The `throttle:api` middleware must always be present.\n\n---\n\n## 2. Single-Action Invokable Controllers\n\nEvery controller is a `final` single-action invokable class. No resourceful controllers. No multiple methods per class. Just an invokable action and a constructor for any dependency injection.\n\nControllers live under `app\u002FHttp\u002FControllers\u002F{Resource}\u002F{Version}\u002F`:\n\n```\napp\u002FHttp\u002FControllers\u002FPosts\u002FV1\u002F\n  IndexController.php\n  ShowController.php\n  StoreController.php\n  UpdateController.php\n  DestroyController.php\n```\n\nDependencies are always injected via the constructor. Never use Facades, `app()`, or `resolve()` inside a controller. The `__invoke` method handles the request and returns a response:\n\n```php\n\u003C?php\n\ndeclare(strict_types=1);\n\nnamespace App\\Http\\Controllers\\Posts\\V1;\n\nuse App\\Actions\\Posts\\StorePostAction;\nuse App\\Http\\Requests\\Posts\\V1\\StoreRequest;\nuse App\\Http\\Resources\\PostResource;\nuse Illuminate\\Http\\JsonResponse;\nuse Symfony\\Component\\HttpFoundation\\Response;\n\nfinal class StoreController\n{\n    public function __construct(\n        private readonly StorePostAction $action,\n    ) {}\n\n    public function __invoke(StoreRequest $request): JsonResponse\n    {\n        $post = $this->action->handle(\n            payload: $request->payload(),\n        );\n\n        return new JsonResponse(\n            data: new PostResource($post),\n            status: Response::HTTP_CREATED,\n        );\n    }\n}\n```\n\n---\n\n## 3. Form Requests and Payloads (DTOs)\n\nEvery state-mutating endpoint uses a **Form Request**. Form Requests live under `app\u002FHttp\u002FRequests\u002F{Resource}\u002F{Version}\u002F`.\n\nThe Form Request **must** expose a `payload()` method that returns a typed DTO from `app\u002FHttp\u002FPayloads\u002F`. This keeps controllers free of array handling and makes the data contract explicit:\n\n```php\n\u003C?php\n\ndeclare(strict_types=1);\n\nnamespace App\\Http\\Requests\\Posts\\V1;\n\nuse App\\Http\\Payloads\\Posts\\StorePayload;\nuse Illuminate\\Foundation\\Http\\FormRequest;\n\nfinal class StoreRequest extends FormRequest\n{\n    public function authorize(): bool\n    {\n        return true;\n    }\n\n    public function rules(): array\n    {\n        return [\n            'title'   => ['required', 'string', 'max:255'],\n            'content' => ['required', 'string'],\n        ];\n    }\n\n    public function payload(): StorePayload\n    {\n        return new StorePayload(\n            title:   $this->string('title')->toString(),\n            content: $this->string('content')->toString(),\n            userId:  $this->user()->id,\n        );\n    }\n}\n```\n\n**Payloads (DTOs)** are plain PHP objects. They have a typed constructor and a `toArray()` method that returns what Eloquent expects. They live in `app\u002FHttp\u002FPayloads\u002F`:\n\n```php\n\u003C?php\n\ndeclare(strict_types=1);\n\nnamespace App\\Http\\Payloads\\Posts;\n\nfinal class StorePayload\n{\n    public function __construct(\n        public readonly string $title,\n        public readonly string $content,\n        public readonly string $userId,\n    ) {}\n\n    public function toArray(): array\n    {\n        return [\n            'title'   => $this->title,\n            'content' => $this->content,\n            'user_id' => $this->userId,\n        ];\n    }\n}\n```\n\n---\n\n## 4. API Resources\n\nAlways use Laravel's Eloquent API Resources to transform model data. Generate them with the `--json-api` CLI flag:\n\n```bash\nphp artisan make:resource PostResource --json-api\n```\n\nResources live under `app\u002FHttp\u002FResources\u002F`. They define the contract for what consumers receive. Never return raw models or plain arrays from a controller.\n\nCall `JsonResource::withoutWrapping()` in `AppServiceProvider::boot()` to disable the automatic `data` envelope globally. This ensures resources serialise consistently whether returned directly from a controller or encoded inside a `JsonResponse`:\n\n```php\nuse Illuminate\\Http\\Resources\\Json\\JsonResource;\n\npublic function boot(): void\n{\n    JsonResource::withoutWrapping();\n}\n```\n\n---\n\n## 5. HTTP Status Codes\n\nAlways use Symfony's `Response::HTTP_*` constants. Never use bare integers. This makes intent readable at a glance:\n\n| Scenario | Constant |\n|---|---|\n| Successful read | `Response::HTTP_OK` |\n| Resource created | `Response::HTTP_CREATED` |\n| Accepted for background processing | `Response::HTTP_ACCEPTED` |\n| Successful delete (no body) | `Response::HTTP_NO_CONTENT` |\n| Validation failed | `Response::HTTP_UNPROCESSABLE_ENTITY` |\n| Unauthenticated | `Response::HTTP_UNAUTHORIZED` |\n| Forbidden | `Response::HTTP_FORBIDDEN` |\n| Not found | `Response::HTTP_NOT_FOUND` |\n| Server error | `Response::HTTP_INTERNAL_SERVER_ERROR` |\n\nImport: `use Symfony\\Component\\HttpFoundation\\Response;`\n\n---\n\n## 6. Error Handling — RFC 9457 Problem Details\n\nAll error responses follow [RFC 9457 Problem Details](https:\u002F\u002Fwww.rfc-editor.org\u002Frfc\u002Frfc9457). The response shape is:\n\n```json\n{\n    \"type\": \"https:\u002F\u002Fexample.com\u002Fproblems\u002Fvalidation-error\",\n    \"title\": \"Validation Error\",\n    \"status\": 422,\n    \"detail\": \"The given data was invalid.\",\n    \"errors\": {\n        \"title\": [\"The title field is required.\"]\n    }\n}\n```\n\nRFC 9457 also requires responses to be served with `Content-Type: application\u002Fproblem+json`, not `application\u002Fjson`. Enforce both the shape and the header through a single `ProblemResponse` class that implements Laravel's `Responsable` interface, living at `app\u002FHttp\u002FResponses\u002FProblemResponse.php`. Every exception handler closure returns a `ProblemResponse` — no raw arrays, no ad-hoc `JsonResponse` construction:\n\n```php\nreturn new ProblemResponse(\n    type:   'https:\u002F\u002Fexample.com\u002Fproblems\u002Fnot-found',\n    title:  'Not Found',\n    status: Response::HTTP_NOT_FOUND,\n    detail: 'The requested resource could not be found.',\n);\n```\n\nThe exception handler in `bootstrap\u002Fapp.php` is responsible for rendering **all** exceptions. No exception should ever produce an HTML response on an API route. At minimum, the following must be handled explicitly:\n\n| Exception | Status | Problem type slug |\n|---|---|---|\n| `ValidationException` | `422` | `validation-error` |\n| `AuthenticationException` | `401` | `unauthenticated` |\n| `AuthorizationException` | `403` | `forbidden` |\n| `ModelNotFoundException` | `404` | `not-found` |\n| `Throwable` (catch-all) | `500` | `server-error` |\n\nThe catch-all ensures nothing falls through to Laravel's default HTML error page. See [references\u002FCONVENTIONS.md](references\u002FCONVENTIONS.md) for the full `ProblemResponse` implementation and handler.\n\n---\n\n## 7. Authentication — Laravel Sanctum (Stateless Tokens)\n\nAll API routes are protected with Laravel Sanctum using stateless API tokens. Never use session-based authentication for API routes.\n\n- Middleware: `auth:sanctum`\n- Token abilities\u002Fscopes are used to restrict what a token can do\n- Registration and login flows are synchronous — token issuance must complete in the same request\n\n```php\n\u002F\u002F Protecting routes\nRoute::middleware(['auth:sanctum', 'throttle:api'])->group(function (): void {\n    \u002F\u002F ...\n});\n\n\u002F\u002F Checking abilities in a controller\u002Faction\n$request->user()->tokenCan('posts:create');\n```\n\n---\n\n## 8. Authorization — Policies\n\nAuthentication (section 7) confirms who the user is. Authorization confirms what they can do. Use **Laravel Policies** for resource-level access control.\n\nAuthorization belongs in the Form Request's `authorize()` method — not in the controller, not in the Action:\n\n```php\npublic function authorize(): bool\n{\n    return $this->user()->can('update', $this->route('post'));\n}\n```\n\nPolicies live in `app\u002FPolicies\u002F`. A failed authorization throws an `AuthorizationException`, which the exception handler (section 6) renders as a `403 Forbidden` Problem Details response.\n\nActions operate on data that has already been validated and authorized. Never put policy checks inside an Action.\n\n---\n\n## 9. The Action Pattern\n\nAll business logic lives in **Action classes** under `app\u002FActions\u002F{Resource}\u002F`. Controllers orchestrate, Actions execute. One action per operation.\n\nActions are injected into controllers via the constructor. They receive a DTO and return a model or value:\n\n```php\n\u003C?php\n\ndeclare(strict_types=1);\n\nnamespace App\\Actions\\Posts;\n\nuse App\\Http\\Payloads\\Posts\\StorePayload;\nuse App\\Models\\Post;\nuse Illuminate\\Database\\DatabaseManager;\n\nfinal class StorePostAction\n{\n    public function __construct(\n        private readonly DatabaseManager $database,\n    ) {}\n\n    public function handle(StorePayload $payload): Post\n    {\n        return $this->database->transaction(\n            callback: fn (): Post => Post::query()->create(\n                attributes: $payload->toArray(),\n            ),\n        );\n    }\n}\n```\n\nEvery action that writes to the database **must** be wrapped in `$this->database->transaction()` using the injected `DatabaseManager`.\n\n---\n\n## 10. Background Jobs — Non-Blocking Requests\n\nPrefer non-blocking API responses. When an operation can be deferred, dispatch a job and return `202 Accepted`:\n\n```php\n\u003C?php\n\ndeclare(strict_types=1);\n\nnamespace App\\Actions\\Posts;\n\nuse App\\Http\\Payloads\\Posts\\StorePayload;\nuse App\\Jobs\\Posts\\StorePostJob;\n\nfinal class StorePostAction\n{\n    public function handle(StorePayload $payload): void\n    {\n        dispatch(new StorePostJob($payload));\n    }\n}\n```\n\n```php\n\u002F\u002F Controller\nreturn new JsonResponse(status: Response::HTTP_ACCEPTED);\n```\n\nWhen a job receives an Eloquent model, use the `SerializesModels` trait alongside `Queueable`. This stores the model's class and key on the queue rather than the full serialized object, and re-fetches it fresh when the job runs. Because the trait restores model properties via `__wakeup()`, model constructor properties must not be `readonly`:\n\n```php\nuse Illuminate\\Contracts\\Queue\\ShouldQueue;\nuse Illuminate\\Foundation\\Queue\\Queueable;\nuse Illuminate\\Queue\\SerializesModels;\n\nfinal class DestroyPostJob implements ShouldQueue\n{\n    use Queueable;\n    use SerializesModels;\n\n    public function __construct(\n        private Post $post, \u002F\u002F not readonly — SerializesModels rehydrates via __wakeup()\n    ) {}\n}\n```\n\n**Exceptions to non-blocking:**\n- User registration — the user needs a token immediately.\n- Login \u002F token issuance — must be synchronous.\n- Any operation where the response body is needed by the client to proceed.\n\nUse judgement. If the client cannot function without the result, make it synchronous.\n\n---\n\n## 11. Dependency Injection\n\nAlways inject dependencies via the constructor. Never use:\n\n- `Facades` (unless there is no alternative.)\n- `app()` helper\n- `resolve()` helper\n\nIf you know you need a class, declare it in the constructor. Laravel's container will resolve it automatically.\n\n```php\n\u002F\u002F Correct\nfinal class StoreController\n{\n    public function __construct(\n        private readonly StorePostAction $action,\n    ) {}\n}\n\n\u002F\u002F Wrong — never do this inside a method\npublic function __invoke(): JsonResponse\n{\n    $action = app(StorePostAction::class); \u002F\u002F ❌\n}\n```\n\n---\n\n## 12. Pagination\n\nAlways use `simplePaginate()`. It avoids the expensive `COUNT(*)` query of `paginate()` and keeps the response lean:\n\n```php\nPost::query()->simplePaginate(perPage: 15);\n```\n\nNever use `paginate()` on API endpoints.\n\n---\n\n## 13. Rate Limiting\n\nEvery API route group must have `throttle:api` middleware. No endpoint is ever unthrottled. Define rate limiters in `App\\Providers\\AppServiceProvider` (or a dedicated `RateLimitServiceProvider`):\n\n```php\nRateLimiter::for('api', function (Request $request): Limit {\n    return Limit::perMinute(60)->by($request->user()?->id ?: $request->ip());\n});\n```\n\n---\n\n## 14. Query Filtering — Spatie Laravel Query Builder\n\nUse [Spatie Laravel Query Builder](https:\u002F\u002Fgithub.com\u002Fspatie\u002Flaravel-query-builder) for all filterable list endpoints. Never build raw query strings manually:\n\n```php\n\u003C?php\n\ndeclare(strict_types=1);\n\nnamespace App\\Http\\Controllers\\Posts\\V1;\n\nuse App\\Http\\Resources\\PostResource;\nuse App\\Models\\Post;\nuse Illuminate\\Http\\Resources\\Json\\AnonymousResourceCollection;\nuse Spatie\\QueryBuilder\\AllowedFilter;\nuse Spatie\\QueryBuilder\\QueryBuilder;\n\nfinal class IndexController\n{\n    public function __invoke(): AnonymousResourceCollection\n    {\n        $posts = QueryBuilder::for(Post::class)\n            ->allowedFilters([\n                AllowedFilter::exact('status'),\n                AllowedFilter::partial('title'),\n            ])\n            ->allowedSorts(['created_at', 'title'])\n            ->simplePaginate(perPage: 15);\n\n        return PostResource::collection($posts);\n    }\n}\n```\n\n---\n\n## 15. Testing\n\nTest from the **outside in**. Drive tests through HTTP — assert on the response, not on internals. Cover both the happy path and the unhappy paths.\n\n```php\nit('creates a post and returns 201', function (): void {\n    $user = User::factory()->create();\n\n    $this->actingAs($user)->postJson('\u002Fv1\u002Fposts', [\n        'title'   => 'Hello World',\n        'content' => 'This is the content.',\n    ])->assertStatus(\n        Response::HTTP_CREATED,\n    )->assertJsonPath('title', 'Hello World');\n});\n\nit('returns 422 when title is missing', function (): void {\n    $user = User::factory()->create();\n\n    $this->actingAs($user)->postJson('\u002Fv1\u002Fposts', [\n        'content' => 'Missing title.',\n    ])->assertStatus(\n        Response::HTTP_UNPROCESSABLE_ENTITY,\n    )->assertJsonPath('status', 422)->assertJsonPath('title', 'Validation Error');\n});\n```\n\n---\n\n## 16. API Versioning — Sunset Middleware\n\nWhen a versioned endpoint is scheduled for removal, signal this to consumers using the `Sunset` HTTP header ([RFC 8594](https:\u002F\u002Fwww.rfc-editor.org\u002Frfc\u002Frfc8594)). This gives clients advance warning to migrate before the endpoint disappears.\n\nCreate a `Sunset` middleware at `app\u002FHttp\u002FMiddleware\u002FSunset.php`:\n\n```php\n\u003C?php\n\ndeclare(strict_types=1);\n\nnamespace App\\Http\\Middleware;\n\nuse Closure;\nuse DateTimeImmutable;\nuse DateTimeInterface;\nuse Illuminate\\Http\\Request;\nuse Symfony\\Component\\HttpFoundation\\Response;\n\nfinal class Sunset\n{\n    public function handle(Request $request, Closure $next, string $date): Response\n    {\n        $response = $next($request);\n\n        $response->headers->set(\n            'Sunset',\n            (new DateTimeImmutable($date))->format(DateTimeInterface::RFC7231),\n        );\n\n        return $response;\n    }\n}\n```\n\nApply it per route group in the resource file when v1 has a known deprecation date:\n\n```php\nRoute::prefix('v1\u002Fposts')\n    ->middleware(['auth:sanctum', 'throttle:api', 'sunset:2026-12-31'])\n    ->group(function (): void {\n        \u002F\u002F v1 routes — sunset date is communicated on every response\n    });\n```\n\nThe v2 routes live in the same resource file without the middleware:\n\n```php\nRoute::prefix('v2\u002Fposts')\n    ->middleware(['auth:sanctum', 'throttle:api'])\n    ->group(function (): void {\n        \u002F\u002F v2 routes\n    });\n```\n\nRegister the middleware alias in `bootstrap\u002Fapp.php`:\n\n```php\n->withMiddleware(function (Middleware $middleware): void {\n    $middleware->alias([\n        'sunset' => \\App\\Http\\Middleware\\Sunset::class,\n    ]);\n})\n```\n\n---\n\n## 17. Forcing JSON Responses\n\nLaravel's exception handler only returns JSON when `$request->expectsJson()` is true — which checks for the `Accept: application\u002Fjson` header. If a client omits it, some exceptions (particularly those thrown before the handler fires, such as middleware failures) can still return HTML.\n\nFix this with a `ForceJsonResponse` middleware at `app\u002FHttp\u002FMiddleware\u002FForceJsonResponse.php` that sets the header on every inbound request:\n\n```php\n\u003C?php\n\ndeclare(strict_types=1);\n\nnamespace App\\Http\\Middleware;\n\nuse Closure;\nuse Illuminate\\Http\\Request;\nuse Symfony\\Component\\HttpFoundation\\Response;\n\nfinal class ForceJsonResponse\n{\n    public function handle(Request $request, Closure $next): Response\n    {\n        $request->headers->set('Accept', 'application\u002Fjson');\n\n        return $next($request);\n    }\n}\n```\n\nRegister it as the first middleware on all API routes in `bootstrap\u002Fapp.php`:\n\n```php\n->withMiddleware(function (Middleware $middleware): void {\n    $middleware->alias([\n        'sunset'            => \\App\\Http\\Middleware\\Sunset::class,\n        'force.json'        => \\App\\Http\\Middleware\\ForceJsonResponse::class,\n    ]);\n})\n```\n\nApply it at the top of every resource route group:\n\n```php\nRoute::prefix('v1\u002Fposts')\n    ->middleware(['force.json', 'auth:sanctum', 'throttle:api'])\n    ->group(function (): void {\n        \u002F\u002F ...\n    });\n```\n\n---\n\n## 18. CORS\n\nA standalone API will be called from origins other than its own domain. Laravel includes `HandleCors` middleware out of the box, backed by `config\u002Fcors.php`.\n\nFor a standalone API, set `paths` to `['*']` — there is no web prefix to protect:\n\n```php\n\u002F\u002F config\u002Fcors.php\nreturn [\n    'paths'                    => ['*'],\n    'allowed_methods'          => ['*'],\n    'allowed_origins'          => ['*'], \u002F\u002F lock this down per environment\n    'allowed_origins_patterns' => [],\n    'allowed_headers'          => ['*'],\n    'exposed_headers'          => [],\n    'max_age'                  => 0,\n    'supports_credentials'     => false,\n];\n```\n\nIn production, replace `allowed_origins: ['*']` with an explicit list of trusted origins. Drive it from an environment variable so it can vary across environments without a code change:\n\n```php\n'allowed_origins' => explode(',', env('CORS_ALLOWED_ORIGINS', '*')),\n```\n\n`HandleCors` is applied globally by Laravel's default middleware stack, so no per-route changes are needed.\n\n---\n\n## 19. Code Quality Standards\n\nEvery PHP file in the project must meet these standards without exception:\n\n- **`declare(strict_types=1)`** on every file, always the first statement after the opening tag\n- **`final`** on every class — controllers, actions, payloads, jobs, middleware, resources — unless explicitly designed for extension\n- **`match`** over `if\u002Felseif` chains and nested ternaries wherever a value is being selected\n- **Named arguments** on constructor calls and method calls with multiple parameters — this is already demonstrated throughout the examples and is required, not optional\n- **Full type coverage** — typed properties, typed parameters, typed return types on every method\n- **PSR-12** naming and formatting conventions throughout\n\n```php\n\u003C?php \u002F\u002F ✓\n\ndeclare(strict_types=1); \u002F\u002F ✓ always first\n\nnamespace App\\Actions\\Posts;\n\nfinal class StorePostAction \u002F\u002F ✓ final\n{\n    public function handle(StorePayload $payload): Post \u002F\u002F ✓ fully typed\n    {\n        return $this->database->transaction(\n            callback: fn (): Post => Post::query()->create( \u002F\u002F ✓ named argument\n                attributes: $payload->toArray(),\n            ),\n        );\n    }\n}\n```\n\n---\n\n## 20. Model Identifiers — ULIDs\n\nNever use auto-increment integer IDs on API-facing models. Integer IDs expose record counts, enable enumeration attacks, and create ordering assumptions consumers should not rely on.\n\nAlways use Laravel's `HasUlids` trait:\n\n```php\n\u003C?php\n\ndeclare(strict_types=1);\n\nnamespace App\\Models;\n\nuse Illuminate\\Database\\Eloquent\\Concerns\\HasUlids;\nuse Illuminate\\Database\\Eloquent\\Model;\n\nfinal class Post extends Model\n{\n    use HasUlids;\n}\n```\n\nLaravel handles ULID generation automatically. No migration changes beyond defining the primary key column as `string` (26 characters) are required:\n\n```php\n$table->ulid('id')->primary();\n```\n\n---\n\n## 21. Model Strictness\n\nCall `Model::shouldBeStrict()` in `AppServiceProvider::boot()`. This enables three protections simultaneously:\n\n- **Prevents lazy loading** — any unloaded relationship accessed outside of `with()` throws immediately, surfacing N+1 queries during development\n- **Prevents silently discarded attributes** — assigning an attribute not in `$fillable` throws rather than silently ignoring it\n- **Prevents accessing missing attributes** — reading an attribute that doesn't exist on the model throws rather than returning `null`\n\n```php\nuse Illuminate\\Database\\Eloquent\\Model;\n\npublic function boot(): void\n{\n    Model::shouldBeStrict();\n\n    JsonResource::withoutWrapping();\n\n    RateLimiter::for('api', function (Request $request): Limit {\n        return Limit::perMinute(60)->by(\n            key: $request->user()?->id ?: $request->ip(),\n        );\n    });\n}\n```\n\nThese are development-time errors by design. Fix the underlying issue — don't suppress the exception.\n\n---\n\n## 22. Anti-patterns\n\nThe following are explicitly prohibited. If you find yourself reaching for any of these, stop and apply the correct pattern instead.\n\n| Anti-pattern | Why | What to do instead |\n|---|---|---|\n| Auto-increment integer primary keys | Exposes record counts, enables enumeration | Use `HasUlids` (section 20) |\n| Business logic in models (scopes excluded) | Violates single responsibility, untestable in isolation | Use Actions (section 9) |\n| Multi-method or resourceful controllers | Obscures intent, harder to locate logic | Single-action invokable controllers (section 2) |\n| Returning raw models or arrays from controllers | Leaks schema, no transformation layer | Always use API Resources (section 4) |\n| `app()`, `resolve()`, or Facades in controllers\u002Factions | Hides dependencies, harder to test | Constructor injection (section 11) |\n| `DB::transaction()` Facade | Same as above — hides the dependency | Inject `DatabaseManager` (section 9) |\n| `paginate()` on list endpoints | Runs an expensive `COUNT(*)` | Always `simplePaginate()` (section 12) |\n| Unthrottled routes | Exposes all endpoints to brute force and abuse | Always `throttle:api` (section 13) |\n| HTML error responses on API routes | Breaks every API client | `ForceJsonResponse` + full exception handler (sections 6, 17) |\n| Skipping `declare(strict_types=1)` | Silent type coercion bugs | Required on every file (section 19) |\n| Authorization checks in Actions | Actions receive already-authorized data | Authorize in Form Request `authorize()` (section 8) |\n\n---\n\n## References\n\nFor detailed folder structure and naming conventions, see [references\u002FCONVENTIONS.md](references\u002FCONVENTIONS.md).\n",{"name":5,"license":15,"metadata":25,"description":7,"compatibility":28},{"author":26,"version":27},"juststeveking","2.0","Requires Laravel 13+ and PHP 8.5+.","main","30954af1dcd1a74b63f05deb2e2c41e5ecae4a82","05-Backend-API-Development\u002Fapi-skill","https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack","https:\u002F\u002Fgithub.com\u002Fitsmejay18","2026-09-18 16:06:36",{"source":8,"skillName":5,"commands":36,"prompt":46,"zipAvailable":47},[37,40,43],{"tool":38,"command":39},"npx","npx skills add itsmejay18\u002FAI-Skills-for-My-Development-Stack --skill api-skill",{"tool":41,"command":42},"bunx","bunx skills add itsmejay18\u002FAI-Skills-for-My-Development-Stack --skill api-skill",{"tool":44,"command":45},"pnpm","pnpm dlx skills add itsmejay18\u002FAI-Skills-for-My-Development-Stack --skill api-skill","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F05-Backend-API-Development\u002Fapi-skill\u002FSKILL.md",true,[49,55,59,63,67,71,75,79,83,87,91,95,99,103,107,111,115,119,123,127,131,135,139,143,147,151,155,159,163,167,171,175,179,183,187,191,195,199,203,207,213,217,221,225],{"path":50,"resourceType":51,"resourceTypeDesc":52,"sizeBytes":53,"sourceHtmlUrl":54},".gitignore","OTHER","其他",60,"https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F05-Backend-API-Development\u002Fapi-skill\u002F.gitignore",{"path":56,"resourceType":51,"resourceTypeDesc":52,"sizeBytes":57,"sourceHtmlUrl":58},"examples\u002Fauth\u002Factions\u002FLoginUserAction.php",754,"https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F05-Backend-API-Development\u002Fapi-skill\u002Fexamples\u002Fauth\u002Factions\u002FLoginUserAction.php",{"path":60,"resourceType":51,"resourceTypeDesc":52,"sizeBytes":61,"sourceHtmlUrl":62},"examples\u002Fauth\u002Factions\u002FRegisterUserAction.php",644,"https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F05-Backend-API-Development\u002Fapi-skill\u002Fexamples\u002Fauth\u002Factions\u002FRegisterUserAction.php",{"path":64,"resourceType":51,"resourceTypeDesc":52,"sizeBytes":65,"sourceHtmlUrl":66},"examples\u002Fauth\u002Fcontrollers\u002FLoginController.php",807,"https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F05-Backend-API-Development\u002Fapi-skill\u002Fexamples\u002Fauth\u002Fcontrollers\u002FLoginController.php",{"path":68,"resourceType":51,"resourceTypeDesc":52,"sizeBytes":69,"sourceHtmlUrl":70},"examples\u002Fauth\u002Fcontrollers\u002FLogoutController.php",441,"https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F05-Backend-API-Development\u002Fapi-skill\u002Fexamples\u002Fauth\u002Fcontrollers\u002FLogoutController.php",{"path":72,"resourceType":51,"resourceTypeDesc":52,"sizeBytes":73,"sourceHtmlUrl":74},"examples\u002Fauth\u002Fcontrollers\u002FRegisterController.php",827,"https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F05-Backend-API-Development\u002Fapi-skill\u002Fexamples\u002Fauth\u002Fcontrollers\u002FRegisterController.php",{"path":76,"resourceType":51,"resourceTypeDesc":52,"sizeBytes":77,"sourceHtmlUrl":78},"examples\u002Fauth\u002Fpayloads\u002FLoginPayload.php",220,"https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F05-Backend-API-Development\u002Fapi-skill\u002Fexamples\u002Fauth\u002Fpayloads\u002FLoginPayload.php",{"path":80,"resourceType":51,"resourceTypeDesc":52,"sizeBytes":81,"sourceHtmlUrl":82},"examples\u002Fauth\u002Fpayloads\u002FRegisterPayload.php",627,"https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F05-Backend-API-Development\u002Fapi-skill\u002Fexamples\u002Fauth\u002Fpayloads\u002FRegisterPayload.php",{"path":84,"resourceType":51,"resourceTypeDesc":52,"sizeBytes":85,"sourceHtmlUrl":86},"examples\u002Fauth\u002Frequests\u002FLoginRequest.php",682,"https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F05-Backend-API-Development\u002Fapi-skill\u002Fexamples\u002Fauth\u002Frequests\u002FLoginRequest.php",{"path":88,"resourceType":51,"resourceTypeDesc":52,"sizeBytes":89,"sourceHtmlUrl":90},"examples\u002Fauth\u002Frequests\u002FRegisterRequest.php",868,"https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F05-Backend-API-Development\u002Fapi-skill\u002Fexamples\u002Fauth\u002Frequests\u002FRegisterRequest.php",{"path":92,"resourceType":51,"resourceTypeDesc":52,"sizeBytes":93,"sourceHtmlUrl":94},"examples\u002Fauth\u002Fresources\u002FUserResource.php",470,"https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F05-Backend-API-Development\u002Fapi-skill\u002Fexamples\u002Fauth\u002Fresources\u002FUserResource.php",{"path":96,"resourceType":51,"resourceTypeDesc":52,"sizeBytes":97,"sourceHtmlUrl":98},"examples\u002Fauth\u002Froutes.php",526,"https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F05-Backend-API-Development\u002Fapi-skill\u002Fexamples\u002Fauth\u002Froutes.php",{"path":100,"resourceType":51,"resourceTypeDesc":52,"sizeBytes":101,"sourceHtmlUrl":102},"examples\u002Fauth\u002Ftests\u002FLoginTest.php",1388,"https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F05-Backend-API-Development\u002Fapi-skill\u002Fexamples\u002Fauth\u002Ftests\u002FLoginTest.php",{"path":104,"resourceType":51,"resourceTypeDesc":52,"sizeBytes":105,"sourceHtmlUrl":106},"examples\u002Fauth\u002Ftests\u002FLogoutTest.php",652,"https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F05-Backend-API-Development\u002Fapi-skill\u002Fexamples\u002Fauth\u002Ftests\u002FLogoutTest.php",{"path":108,"resourceType":51,"resourceTypeDesc":52,"sizeBytes":109,"sourceHtmlUrl":110},"examples\u002Fauth\u002Ftests\u002FRegisterTest.php",1808,"https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F05-Backend-API-Development\u002Fapi-skill\u002Fexamples\u002Fauth\u002Ftests\u002FRegisterTest.php",{"path":112,"resourceType":51,"resourceTypeDesc":52,"sizeBytes":113,"sourceHtmlUrl":114},"examples\u002Fauth\u002FUser.php",530,"https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F05-Backend-API-Development\u002Fapi-skill\u002Fexamples\u002Fauth\u002FUser.php",{"path":116,"resourceType":51,"resourceTypeDesc":52,"sizeBytes":117,"sourceHtmlUrl":118},"examples\u002Fposts\u002Factions\u002FDestroyPostAction.php",256,"https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F05-Backend-API-Development\u002Fapi-skill\u002Fexamples\u002Fposts\u002Factions\u002FDestroyPostAction.php",{"path":120,"resourceType":51,"resourceTypeDesc":52,"sizeBytes":121,"sourceHtmlUrl":122},"examples\u002Fposts\u002Factions\u002FStorePostAction.php",543,"https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F05-Backend-API-Development\u002Fapi-skill\u002Fexamples\u002Fposts\u002Factions\u002FStorePostAction.php",{"path":124,"resourceType":51,"resourceTypeDesc":52,"sizeBytes":125,"sourceHtmlUrl":126},"examples\u002Fposts\u002Factions\u002FUpdatePostAction.php",574,"https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F05-Backend-API-Development\u002Fapi-skill\u002Fexamples\u002Fposts\u002Factions\u002FUpdatePostAction.php",{"path":128,"resourceType":51,"resourceTypeDesc":52,"sizeBytes":129,"sourceHtmlUrl":130},"examples\u002Fposts\u002Fcontrollers\u002FDestroyController.php",621,"https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F05-Backend-API-Development\u002Fapi-skill\u002Fexamples\u002Fposts\u002Fcontrollers\u002FDestroyController.php",{"path":132,"resourceType":51,"resourceTypeDesc":52,"sizeBytes":133,"sourceHtmlUrl":134},"examples\u002Fposts\u002Fcontrollers\u002FIndexController.php",715,"https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F05-Backend-API-Development\u002Fapi-skill\u002Fexamples\u002Fposts\u002Fcontrollers\u002FIndexController.php",{"path":136,"resourceType":51,"resourceTypeDesc":52,"sizeBytes":137,"sourceHtmlUrl":138},"examples\u002Fposts\u002Fcontrollers\u002FShowController.php",439,"https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F05-Backend-API-Development\u002Fapi-skill\u002Fexamples\u002Fposts\u002Fcontrollers\u002FShowController.php",{"path":140,"resourceType":51,"resourceTypeDesc":52,"sizeBytes":141,"sourceHtmlUrl":142},"examples\u002Fposts\u002Fcontrollers\u002FStoreController.php",705,"https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F05-Backend-API-Development\u002Fapi-skill\u002Fexamples\u002Fposts\u002Fcontrollers\u002FStoreController.php",{"path":144,"resourceType":51,"resourceTypeDesc":52,"sizeBytes":145,"sourceHtmlUrl":146},"examples\u002Fposts\u002Fcontrollers\u002FUpdateController.php",766,"https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F05-Backend-API-Development\u002Fapi-skill\u002Fexamples\u002Fposts\u002Fcontrollers\u002FUpdateController.php",{"path":148,"resourceType":51,"resourceTypeDesc":52,"sizeBytes":149,"sourceHtmlUrl":150},"examples\u002Fposts\u002Fjobs\u002FDestroyPostJob.php",658,"https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F05-Backend-API-Development\u002Fapi-skill\u002Fexamples\u002Fposts\u002Fjobs\u002FDestroyPostJob.php",{"path":152,"resourceType":51,"resourceTypeDesc":52,"sizeBytes":153,"sourceHtmlUrl":154},"examples\u002Fposts\u002Fpayloads\u002FStorePayload.php",458,"https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F05-Backend-API-Development\u002Fapi-skill\u002Fexamples\u002Fposts\u002Fpayloads\u002FStorePayload.php",{"path":156,"resourceType":51,"resourceTypeDesc":52,"sizeBytes":157,"sourceHtmlUrl":158},"examples\u002Fposts\u002Fpayloads\u002FUpdatePayload.php",379,"https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F05-Backend-API-Development\u002Fapi-skill\u002Fexamples\u002Fposts\u002Fpayloads\u002FUpdatePayload.php",{"path":160,"resourceType":51,"resourceTypeDesc":52,"sizeBytes":161,"sourceHtmlUrl":162},"examples\u002Fposts\u002FPost.php",549,"https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F05-Backend-API-Development\u002Fapi-skill\u002Fexamples\u002Fposts\u002FPost.php",{"path":164,"resourceType":51,"resourceTypeDesc":52,"sizeBytes":165,"sourceHtmlUrl":166},"examples\u002Fposts\u002FPostPolicy.php",357,"https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F05-Backend-API-Development\u002Fapi-skill\u002Fexamples\u002Fposts\u002FPostPolicy.php",{"path":168,"resourceType":51,"resourceTypeDesc":52,"sizeBytes":169,"sourceHtmlUrl":170},"examples\u002Fposts\u002Frequests\u002FDestroyRequest.php",352,"https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F05-Backend-API-Development\u002Fapi-skill\u002Fexamples\u002Fposts\u002Frequests\u002FDestroyRequest.php",{"path":172,"resourceType":51,"resourceTypeDesc":52,"sizeBytes":173,"sourceHtmlUrl":174},"examples\u002Fposts\u002Frequests\u002FStoreRequest.php",721,"https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F05-Backend-API-Development\u002Fapi-skill\u002Fexamples\u002Fposts\u002Frequests\u002FStoreRequest.php",{"path":176,"resourceType":51,"resourceTypeDesc":52,"sizeBytes":177,"sourceHtmlUrl":178},"examples\u002Fposts\u002Frequests\u002FUpdateRequest.php",731,"https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F05-Backend-API-Development\u002Fapi-skill\u002Fexamples\u002Fposts\u002Frequests\u002FUpdateRequest.php",{"path":180,"resourceType":51,"resourceTypeDesc":52,"sizeBytes":181,"sourceHtmlUrl":182},"examples\u002Fposts\u002Fresources\u002FPostResource.php",612,"https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F05-Backend-API-Development\u002Fapi-skill\u002Fexamples\u002Fposts\u002Fresources\u002FPostResource.php",{"path":184,"resourceType":51,"resourceTypeDesc":52,"sizeBytes":185,"sourceHtmlUrl":186},"examples\u002Fposts\u002Froutes.php",641,"https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F05-Backend-API-Development\u002Fapi-skill\u002Fexamples\u002Fposts\u002Froutes.php",{"path":188,"resourceType":51,"resourceTypeDesc":52,"sizeBytes":189,"sourceHtmlUrl":190},"examples\u002Fposts\u002Ftests\u002FDestroyTest.php",1284,"https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F05-Backend-API-Development\u002Fapi-skill\u002Fexamples\u002Fposts\u002Ftests\u002FDestroyTest.php",{"path":192,"resourceType":51,"resourceTypeDesc":52,"sizeBytes":193,"sourceHtmlUrl":194},"examples\u002Fposts\u002Ftests\u002FIndexTest.php",1053,"https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F05-Backend-API-Development\u002Fapi-skill\u002Fexamples\u002Fposts\u002Ftests\u002FIndexTest.php",{"path":196,"resourceType":51,"resourceTypeDesc":52,"sizeBytes":197,"sourceHtmlUrl":198},"examples\u002Fposts\u002Ftests\u002FShowTest.php",1127,"https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F05-Backend-API-Development\u002Fapi-skill\u002Fexamples\u002Fposts\u002Ftests\u002FShowTest.php",{"path":200,"resourceType":51,"resourceTypeDesc":52,"sizeBytes":201,"sourceHtmlUrl":202},"examples\u002Fposts\u002Ftests\u002FStoreTest.php",1201,"https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F05-Backend-API-Development\u002Fapi-skill\u002Fexamples\u002Fposts\u002Ftests\u002FStoreTest.php",{"path":204,"resourceType":51,"resourceTypeDesc":52,"sizeBytes":205,"sourceHtmlUrl":206},"examples\u002Fposts\u002Ftests\u002FUpdateTest.php",1819,"https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F05-Backend-API-Development\u002Fapi-skill\u002Fexamples\u002Fposts\u002Ftests\u002FUpdateTest.php",{"path":208,"resourceType":209,"resourceTypeDesc":210,"sizeBytes":211,"sourceHtmlUrl":212},"examples\u002FREADME.md","REFERENCE","参考文档",4277,"https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F05-Backend-API-Development\u002Fapi-skill\u002Fexamples\u002FREADME.md",{"path":214,"resourceType":51,"resourceTypeDesc":52,"sizeBytes":215,"sourceHtmlUrl":216},"examples\u002Fresponses\u002FProblemResponse.php",964,"https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F05-Backend-API-Development\u002Fapi-skill\u002Fexamples\u002Fresponses\u002FProblemResponse.php",{"path":218,"resourceType":218,"resourceTypeDesc":219,"sizeBytes":220,"sourceHtmlUrl":16},"LICENSE","许可证",1098,{"path":222,"resourceType":209,"resourceTypeDesc":210,"sizeBytes":223,"sourceHtmlUrl":224},"README.md",4563,"https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F05-Backend-API-Development\u002Fapi-skill\u002FREADME.md",{"path":226,"resourceType":209,"resourceTypeDesc":210,"sizeBytes":227,"sourceHtmlUrl":228},"references\u002FCONVENTIONS.md",21412,"https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F05-Backend-API-Development\u002Fapi-skill\u002Freferences\u002FCONVENTIONS.md",[230,237,244,251,258,265],{"skillNo":231,"name":232,"nameZh":6,"description":233,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":234,"categories":235,"keywords":236,"publishedAt":20},"01M7D2RKBHPZ3E1RNN5DWHT550","vectorization","Design, implement, optimize, and review SIMD code in .NET. USE FOR: vectorizing scalar loops with TensorPrimitives, Vector64\u002F128\u002F256\u002F512, or platform hardware intrinsics; reviewing existing SIMD code, including Vector\u003CT>, for contract equivalence, tail handling, memory safety, portability, fallbacks, and measured performance. DO NOT USE FOR: performance work unrelated to SIMD or vectorization.","https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F20-Performance-Optimization\u002Fvectorization\u002FSKILL.md",[],[],{"skillNo":238,"name":239,"nameZh":6,"description":240,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":241,"categories":242,"keywords":243,"publishedAt":20},"01M7D2RDJ7RN3QK8GJR0QTER1D","resolve-project-references","Guide for interpreting ResolveProjectReferences time in MSBuild performance summaries. Activate when ResolveProjectReferences appears as the most expensive target and developers are trying to optimize it directly. Explains that the reported time includes wait time for dependent project builds and is misleading. Guides users to focus on task self-time instead. Do not activate for general build performance -- use build-perf-diagnostics instead.","https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F20-Performance-Optimization\u002Fresolve-project-references\u002FSKILL.md",[],[],{"skillNo":245,"name":246,"nameZh":6,"description":247,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":248,"categories":249,"keywords":250,"publishedAt":20},"01M7D2R1H2GTNZYHG9YRX3JDQW","optimizing-ef-core-queries","Optimize and improve the performance of slow Entity Framework Core (EF Core) queries: make them generate less SQL, make fewer database round-trips, and return results faster. Use whenever an EF Core or DbContext query or data-access path is slow or should be made faster — whether or not EF Core owns the database schema. For EF Core, not Dapper or raw ADO.NET.","https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F20-Performance-Optimization\u002Foptimizing-ef-core-queries\u002FSKILL.md",[],[],{"skillNo":252,"name":253,"nameZh":6,"description":254,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":255,"categories":256,"keywords":257,"publishedAt":20},"01M7D2QREG04W1YT0NEBHEW5C9","microbenchmarking","Activate this skill when BenchmarkDotNet (BDN) is involved in the task — creating, running, configuring, or reviewing BDN benchmarks. Also activate when microbenchmarking .NET code would be useful and BenchmarkDotNet is the likely tool. Consider activating when answering a .NET performance question requires measurement and BenchmarkDotNet may be needed. Covers microbenchmark design, BDN configuration and project setup, how to run BDN microbenchmarks efficiently and effectively, and using BDN for side-by-side performance comparisons. Do NOT use for profiling\u002Ftracing .NET code (dotnet-trace, PerfView), production telemetry, or load\u002Fstress testing (Crank, k6).","https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F20-Performance-Optimization\u002Fmicrobenchmarking\u002FSKILL.md",[],[],{"skillNo":259,"name":260,"nameZh":6,"description":261,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":262,"categories":263,"keywords":264,"publishedAt":20},"01M7D2QGE175XWPZVACVH2868Z","incremental-build","Guide for optimizing MSBuild incremental builds. USE FOR: builds slower than expected on subsequent runs, 'nothing changed but it rebuilds anyway', diagnosing why targets re-execute unnecessarily, fixing broken no-op builds. Covers 8 common causes: missing Inputs\u002FOutputs on custom targets, volatile properties in output paths (timestamps\u002FGUIDs), file writes outside tracked Outputs, missing FileWrites registration, glob changes, Visual Studio Fast Up-to-Date Check (FUTDC) issues. Key diagnostic: look for 'Building target completely' vs 'Skipping target' in binlog. DO NOT USE FOR: first-time build slowness (use build-perf-baseline), parallelism issues (use build-parallelism), evaluation-phase slowness (use eval-performance), non-MSBuild build systems.","https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F20-Performance-Optimization\u002Fincremental-build\u002FSKILL.md",[],[],{"skillNo":266,"name":267,"nameZh":6,"description":268,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":269,"categories":270,"keywords":271,"publishedAt":20},"01M7D2Q1DQTC6K49R73WQTTPSB","eval-performance","Guide for diagnosing and improving MSBuild project evaluation performance. USE FOR: builds slow before any compilation starts, high evaluation time in binlog analysis, expensive glob patterns walking large directories (node_modules, .git, bin\u002Fobj), deep import chains (>20 levels), preprocessed output >10K lines indicating heavy evaluation, property functions with file I\u002FO ($([System.IO.File]::ReadAllText(...))), multiple evaluations per project. Covers the 5 MSBuild evaluation phases, glob optimization via DefaultItemExcludes, import chain analysis with \u002Fpp preprocessing. DO NOT USE FOR: compilation-time slowness (use build-perf-diagnostics), incremental build issues (use incremental-build), non-MSBuild build systems.","https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F20-Performance-Optimization\u002Feval-performance\u002FSKILL.md",[],[]]