api-contract
API Contract - Typed Frontend/Backend Contracts
Ensures every API endpoint has a typed contract: Pydantic models on the backend, Zod response schemas on the frontend, and documented error responses. Bridges the gap between apps/backend/src/api/ and apps/web/lib/api/.
Description
Enforces type-safe API contracts across the FastAPI backend and Next.js frontend. Every endpoint must declare a Pydantic response_model, have a matching Zod schema on the frontend, and document error responses via OpenAPI. Prevents schema drift, untyped responses, and manual type definitions by mandating a single source of truth through the Contract Triangle pattern.
When to Apply
Positive Triggers
- Creating or modifying API endpoints (FastAPI routes)
- Adding frontend API calls (
apiClient.get/post/put/patch/delete) - Reviewing type safety between backend responses and frontend consumers
- Documenting API error responses
- Planning API versioning or deprecation
- User mentions: "API contract", "endpoint", "response type", "OpenAPI", "schema"
More from cleanexpo/unite-hub
tdd
Use when implementing any feature or bug fix. Hard gate — no production code without a failing test first. Applies to vitest (apps/web/) and pytest (apps/backend/). Triggers on "implement", "add feature", "fix bug", "new component", "new endpoint", or any code-writing task.
1idea-to-production
Plain-English pipeline from idea to production — routes user requests to the right phase and agent
1oauth-flow
OAuth 2.0 and OIDC integration with PKCE, Supabase Auth providers, and redirect URI validation
1health-check
>-
1csv-processor
>-
1vector-search
>-
1