name: backend-builder description: Build API routes, server actions, data adapters, and validation logic in web/. Use when creating or editing backend web code, API endpoints, or data-loading functions.
Backend Builder
Scope
API routes (web/app/api/), server actions, and data adapters (web/lib/data/).
Workflow
- Read
ops/CURRENT.mdand the assigned task file. - Define or update the data adapter that reads from
data/CSVs or JSON. - Validate inputs with Zod schemas in
web/lib/schemas/. - Return typed responses. Use standard HTTP status codes for API routes.
- Cache expensive reads with
unstable_cacheorrevalidateTag. - Update task status and append a change entry.
Conventions
- API routes:
web/app/api/<resource>/route.ts. - Server actions: co-located with the page or form that calls them.
- Shared types:
web/lib/types.ts. - Data adapters:
web/lib/data/<domain>.ts(e.g.,matches.ts,players.ts). - Parse CSVs at build/request time, not at the client.
Token Discipline
- Use
.head()or schema summaries when inspecting data files. - Keep route handlers thin: delegate logic to adapter/service functions.