Workflow Development

Add an API Endpoint

Workflow for building a new API route end-to-end

apibackenddevelopment
CLAUDE.md

When adding a new API endpoint:

  1. Define the route path, HTTP method, request shape, and response shape.
  2. Add input validation using a schema validator (Zod, Joi, etc.).
  3. Create or update the service function that handles the business logic.
  4. Wire the route handler: parse input, call the service, format the response.
  5. Add error handling: return appropriate status codes for validation errors (400), not found (404), and server errors (500).
  6. Write integration tests covering the happy path, validation failures, and edge cases.
  7. Document the endpoint with request/response examples.
  8. Run the test suite and manually test with a sample request.

Copy this workflow into your CLAUDE.md or agent config file so your agent follows this process automatically.

get crystl