api-designlisted
Install: claude install-skill AllThingsSmitty/agent-skills
# API Design
An API is a contract with callers you may never meet. Design it to be honest, consistent, and survivable: easy to use correctly, hard to use wrong, and possible to evolve without breaking existing clients.
## Resource modeling
Design around resources (nouns), not actions (verbs). A resource is a thing the API manages — not a procedure.
Good: `POST /orders`, `GET /orders/{id}`, `PATCH /orders/{id}/status`
Avoid: `POST /createOrder`, `POST /getOrderById`, `POST /cancelOrder`
When it's genuinely an action with no natural resource (e.g., triggering a batch job, sending a notification), a sub-resource on a relevant entity works well:
`POST /reports/{id}/export`, `POST /users/{id}/password-reset`
**Pluralize consistently.** Pick one convention and hold it: `/users` not `/user`, `/orders/{id}` not `/order/{id}`.
**Nest only one level deep.** `/users/{id}/addresses` is fine. `/users/{id}/addresses/{id}/lines` is where you lose people and create coupling. If the nested resource makes sense standalone, give it a top-level route too.
## HTTP method semantics
| Method | Semantics | Idempotent? | Safe? |
| ------ | -------------------------------- | ------------------------------ | ----- |
| GET | Read, no side effects | Yes | Yes |
| POST | Create, or non-idempotent action | No | No |
| PUT | Full replace of a resource | Yes