Build a complete API surface from an existing web controller. Use when the user asks to add API methods, expose a resource via API, or mirror a web controller as an API, especially for adminland resources. Activates when user mentions API methods, API controller, API routes, or wants to expose an existing web resource via API.
Instalación
Instalar con Codex o Claude Copia este prompt, pégalo en Codex, Claude u otro asistente, y deja que revise la página de la skill y la instale por ti.
Build a complete API surface from an existing web controller. Use when the user asks to add API methods, expose a resource via API, or mirror a web controller as an API, especially for adminland resources. Activates when user mentions API methods, API controller, API routes, or wants to expose an existing web resource via API.
API from Web Controller
This skill walks through creating a full API surface for a resource that already has a web controller. The canonical example is an adminland resource like Offices or Office Types.
Before you start
Load these skills immediately — they apply to every step:
laravel-controllers — API controller rules and conventions
test-writer — test structure and PHPUnit patterns
At the end, load and run both documentation skills in order:
bruno-docs-writer — after all code is complete and tests pass
marketing-api-docs-writer — after Bruno docs are written
Step 1 — Study the web controller
Read the existing web controller (app/Http/Controllers/App/…). Extract:
The resource name (singular, e.g. Office)
Which actions are used (CreateXxx, UpdateXxx, DestroyXxx)
The validated fields and their rules
The permission model (who can do what — check the action's validate() method)
Step 2 — Create the Eloquent Resource
Create app/Http/Resources/{Resource}Resource.php.
Rules:
type field is snake_case resource name (e.g. 'office')
id is cast to string
attributes contains all relevant model fields; timestamps as Unix integers via ->timestamp
links.self points to the show route for this resource