api-endpoint
Grounded corpus: endpoint-shape decisions (pagination, error
shape, idempotency, rate limits) are grounded via the
api-design corpus — ./scripts-run <skills-root>/corpus-grounding/scripts/ground search --manifest <skills-root>/api-design/data/manifest.json "<concern>".
When to use
Use this skill when the user asks to create a new API endpoint, REST route, or HTTP handler.
Do NOT use when:
- Modifying existing endpoints — use the code-refactoring skill.
- API design decisions (versioning, deprecation, contract shape) — use
api-design.
Stack routing
Detect the stack, then hand off to the matching carve-out skill for the framework-specific procedure (file layout, validation primitive, response-shaping convention).
| Detected stack |
Carve-out skill |
Laravel (artisan + composer.json with laravel/framework) |
laravel-api-endpoint |
Symfony (bin/console + composer.json with symfony/framework-bundle) |
symfony-workflow |
Next.js (next in package.json) |
nextjs-patterns |
| Express / Fastify / NestJS / plain Node |
follow project conventions in agents/ + package.json scripts |
| FastAPI / Django / Flask |
follow project conventions in agents/ + pyproject.toml |
Go (net/http, gin, echo, fiber) |
follow project conventions in agents/ + go.mod |
Rust (axum, actix-web, rocket) |
follow project conventions in agents/ + Cargo.toml |
If the project doc folder (agents/) has an endpoint-creation guide, that is the source of truth — read it before generating code.
Procedure: Create an API endpoint (stack-neutral)
- Read project docs — Check
./agents/ and AGENTS.md for endpoint conventions, routing layout, response shape.
- Detect stack and route to the carve-out per the table above.
- Plan the endpoint — method, path, request shape, response shape, auth requirement, idempotency.
- Create the route registration in the project's routing surface (route file, decorator-annotated handler, file-based router).
- Create the request handler / controller — thin; delegate business logic to a service / use-case.
- Validate input at the boundary via the framework's validation primitive (FormRequest, Zod, class-validator, Pydantic, struct-tag validators, etc.) — never inline ad-hoc
if checks.
- Authorize the action via the framework's authz primitive (Policy, voter, guard, middleware, route dependency).
- Shape the response through a transformer / serializer / DTO — never return raw ORM entities.
- Document the endpoint (OpenAPI annotations / generated spec / project doc).
- Verify — run the project type-checker + targeted tests + smoke probe (
curl / Bruno / Postman / integration test).
Conventions (apply on every stack)
- One handler, one responsibility — prefer single-purpose handlers over multi-action controllers when the framework supports it.
- No business logic in the handler — delegate to a service / use-case layer.
- Validate at the boundary — never trust raw request data inside the handler.
- Authorize every state-changing action — no unprotected mutating endpoints.
- Shape responses through a transformer — DTO, serializer, API resource, response model — never expose raw ORM entities.
- Version the API surface explicitly (
/v1/, header, content-type) — don't rely on implicit versioning.
Stack-specific procedures
For Laravel projects (the most fully-fleshed-out carve-out in this package), see laravel-api-endpoint — covers single-action controllers, FormRequest, Resource, Policy, CollectionFormRequest, OpenAPI attributes, and the versioned route layout.
For other stacks, read the matching carve-out from the table above and combine with the project's agents/ docs.
Output format
- Generated files — route registration, handler, request validator, response shaper, authorization rule.
- Test file with happy path and validation-error cases (using the project's test framework).
- Summary of created files and their locations.
Gotcha
- Don't forget to register the route — creating the handler without the route is a common miss.
- Always check if a similar endpoint already exists — duplicates cause confusion.
- Validation rules must match the documented contract (OpenAPI / schema / typed client) — keep them in sync.
- Response shapes are part of the public contract — adding a field is additive; renaming or removing is breaking.
Do NOT
- Do NOT put business logic in the handler — delegate to services / use-cases.
- Do NOT skip request validation — every handler validates at the boundary via the framework's primitive.
- Do NOT return raw ORM entities — always go through a transformer / serializer / response model.
- Do NOT create unprotected state-changing endpoints — authorize every mutation.
- Do NOT improvise framework idioms — read the carve-out (
laravel-api-endpoint, nextjs-patterns, etc.) for the stack-correct shape.
Auto-trigger keywords
- create endpoint
- new API route
- route handler
- controller creation
- REST endpoint
- add endpoint
1---2name: api-endpoint3description: Use when creating an API endpoint or HTTP route handler — detects the project stack and routes to the matching carve-out (laravel-api-endpoint, nextjs-patterns, symfony-workflow).4---56# api-endpoint789> **Grounded corpus:** endpoint-shape decisions (pagination, error10> shape, idempotency, rate limits) are grounded via the11> [`api-design`](../api-design/SKILL.md) corpus — `./scripts-run12> <skills-root>/corpus-grounding/scripts/ground search13> --manifest <skills-root>/api-design/data/manifest.json "<concern>"`.1415## When to use1617Use this skill when the user asks to create a new API endpoint, REST route, or HTTP handler.1819Do NOT use when:20- Modifying existing endpoints — use the code-refactoring skill.21- API design decisions (versioning, deprecation, contract shape) — use [`api-design`](../api-design/SKILL.md).2223## Stack routing2425Detect the stack, then hand off to the matching carve-out skill for the framework-specific procedure (file layout, validation primitive, response-shaping convention).2627| Detected stack | Carve-out skill |28|---|---|29| Laravel (`artisan` + `composer.json` with `laravel/framework`) | [`laravel-api-endpoint`](../laravel-api-endpoint/SKILL.md) |30| Symfony (`bin/console` + `composer.json` with `symfony/framework-bundle`) | [`symfony-workflow`](../symfony-workflow/SKILL.md) |31| Next.js (`next` in `package.json`) | [`nextjs-patterns`](../nextjs-patterns/SKILL.md) |32| Express / Fastify / NestJS / plain Node | follow project conventions in `agents/` + `package.json scripts` |33| FastAPI / Django / Flask | follow project conventions in `agents/` + `pyproject.toml` |34| Go (`net/http`, `gin`, `echo`, `fiber`) | follow project conventions in `agents/` + `go.mod` |35| Rust (`axum`, `actix-web`, `rocket`) | follow project conventions in `agents/` + `Cargo.toml` |3637If the project doc folder (`agents/`) has an endpoint-creation guide, that is the source of truth — read it before generating code.3839## Procedure: Create an API endpoint (stack-neutral)40411. **Read project docs** — Check `./agents/` and `AGENTS.md` for endpoint conventions, routing layout, response shape.422. **Detect stack** and route to the carve-out per the table above.433. **Plan the endpoint** — method, path, request shape, response shape, auth requirement, idempotency.444. **Create the route registration** in the project's routing surface (route file, decorator-annotated handler, file-based router).455. **Create the request handler / controller** — thin; delegate business logic to a service / use-case.466. **Validate input at the boundary** via the framework's validation primitive (FormRequest, Zod, class-validator, Pydantic, struct-tag validators, etc.) — never inline ad-hoc `if` checks.477. **Authorize the action** via the framework's authz primitive (Policy, voter, guard, middleware, route dependency).488. **Shape the response** through a transformer / serializer / DTO — never return raw ORM entities.499. **Document** the endpoint (OpenAPI annotations / generated spec / project doc).5010. **Verify** — run the project type-checker + targeted tests + smoke probe (`curl` / Bruno / Postman / integration test).5152## Conventions (apply on every stack)5354- **One handler, one responsibility** — prefer single-purpose handlers over multi-action controllers when the framework supports it.55- **No business logic in the handler** — delegate to a service / use-case layer.56- **Validate at the boundary** — never trust raw request data inside the handler.57- **Authorize every state-changing action** — no unprotected mutating endpoints.58- **Shape responses through a transformer** — DTO, serializer, API resource, response model — never expose raw ORM entities.59- **Version the API surface** explicitly (`/v1/`, header, content-type) — don't rely on implicit versioning.6061## Stack-specific procedures6263For Laravel projects (the most fully-fleshed-out carve-out in this package), see [`laravel-api-endpoint`](../laravel-api-endpoint/SKILL.md) — covers single-action controllers, `FormRequest`, `Resource`, `Policy`, `CollectionFormRequest`, OpenAPI attributes, and the versioned route layout.6465For other stacks, read the matching carve-out from the table above and combine with the project's `agents/` docs.6667## Output format68691. Generated files — route registration, handler, request validator, response shaper, authorization rule.702. Test file with happy path and validation-error cases (using the project's test framework).713. Summary of created files and their locations.7273## Gotcha7475- Don't forget to register the route — creating the handler without the route is a common miss.76- Always check if a similar endpoint already exists — duplicates cause confusion.77- Validation rules must match the documented contract (OpenAPI / schema / typed client) — keep them in sync.78- Response shapes are part of the public contract — adding a field is additive; renaming or removing is breaking.7980## Do NOT8182- Do NOT put business logic in the handler — delegate to services / use-cases.83- Do NOT skip request validation — every handler validates at the boundary via the framework's primitive.84- Do NOT return raw ORM entities — always go through a transformer / serializer / response model.85- Do NOT create unprotected state-changing endpoints — authorize every mutation.86- Do NOT improvise framework idioms — read the carve-out (`laravel-api-endpoint`, `nextjs-patterns`, etc.) for the stack-correct shape.8788## Auto-trigger keywords8990- create endpoint91- new API route92- route handler93- controller creation94- REST endpoint95- add endpoint