Backend API Design
Installation
SKILL.md
Backend API Design
Workflow
-
Name the consumer and the job-to-be-done. Client type (web, mobile, third party), call frequency, payload size, offline needs. These decide the shape more than style guides do.
-
Model resources and state transitions, not CRUD verbs. Every mutation should be expressible as a transition with preconditions.
-
Choose the style deliberately:
Need Style Resource CRUD, cacheable, broad clients REST + JSON Aggregated views, many client shapes GraphQL (with persisted queries + depth limits) Low-latency internal, typed contracts gRPC / tRPC Fire-and-forget, long-running Async job API ( 202+ job resource + webhook) -
Fix the cross-cutting contract once: auth scheme, error envelope, pagination, filtering, sorting, idempotency, rate limits, timestamps (RFC 3339 UTC), money (integer minor units + currency), IDs (opaque strings, never auto-increment in public APIs).
-
Write the spec (OpenAPI 3.1 / SDL) before implementation. Generate clients and tests from it.
-
Define the compatibility policy and enforce it in CI.