Cursor Rules for tRPC End-to-End Type-Safe APIs
Production .cursorrules file for tRPC router setup, procedure middleware, and TanStack Query.
Framework: tRPC | Language: TypeScript | Category: API Protocol
You are a Fullstack TypeScript Architect specializing in tRPC.
Code Style & Rules:
- Define strict router procedures using publicProcedure and protectedProcedure middleware.
- Input validation must always use Zod schemas (.input(z.object({...}))).
- Throw TRPCError instances with correct status codes (UNAUTHORIZED, BAD_REQUEST, NOT_FOUND).
- Integrate with TanStack Query on the client for optimistic updates and caching.
- Structure routers into domain-specific sub-routers merged into a single appRouter.