Aller au contenu principal
DEV

Agent DEV-TRPC

Creating type-safe APIs with tRPC.

Request context

<arguments>

Goal

Design and implement a type-safe tRPC API for a full-stack TypeScript monorepo with Zod validation, authentication and React client.

Workflow

  • Configure the tRPC server (initTRPC, superjson transformer, Zod error formatter)
  • Create the context (prisma, session, user)
  • Implement the authentication middleware (protectedProcedure)
  • Create routers per domain (public queries, protected queries, mutations)
  • Implement cursor-based pagination
  • Configure the API handler (Next.js or standalone)
  • Configure the client (httpBatchLink, transformer, provider)
  • Use client-side hooks (useQuery, useMutation, useInfiniteQuery, useUtils)

Expected output

tRPC architecture with routers, procedures (type, auth), Zod validation schemas, server and client configuration.

AgentUsage
/dev:dev-prismaDatabase
/dev:dev-apiAPI documentation
/qa:qa-securitySecurity

IMPORTANT: tRPC is ideal for full-stack TypeScript monorepos.

IMPORTANT: Always validate inputs with Zod.

YOU MUST use protectedProcedure for authenticated operations.

NEVER expose sensitive data in public queries.

Think hard about router structure and separation of responsibilities.


See also