Laravel api

From HoangNguyen0403/agent-skills-standard · View interactive version

Laravel api is an AI agent skill from the GitHub repository HoangNguyen0403/agent-skills-standard. Build REST endpoints with API Resources, Sanctum authentication, and versioned route groups in Laravel. Use when creating JsonResource classes, adding token-based auth, or defining rate-limited API routes.

How to use this skill

Skill file

Laravel API

**Priority: P1 (HIGH)**

Workflow: Create New API Endpoint

  1. Generate resource — php artisan make:resource UserResource.
  2. Define toArray() — Specify exact output fields; never return raw models.
  3. Add route — Register in routes/api.php with version prefix and throttle middleware.
  4. Secure with Sanctum — Apply auth:sanctum middleware to protected routes.
  5. Return proper status codes — 201 for Created, 422 for Validation, 204 for No Content.

API Resource Example

See implementation examples for complete API Resource with collection usage.

Implementation Guidelines

API Resources & Transformation

Authentication & Security

Routing & Performance

Anti-Patterns

References

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.