Library / Build

API endpoint from pattern

Add a route that matches your backend conventions, with tests.

Build api backend testing Claude Code
The prompt
Add a <METHOD> <route> endpoint following the pattern in @<router-file>. Validate the input, return typed responses, and add one happy-path test plus one error-case test.

Why it works

Naming the router file anchors the model to your validation, error, and response conventions. Requiring two tests forces it to reason about both the success and failure paths instead of only the happy one.

Fill in

  • <METHOD> <route> — e.g. POST /api/orders.
  • @<router-file> — a similar existing endpoint.

Follow-ups

  • “Add auth the same way the /admin routes do it.”