From ravn-ai-toolkit
Guides tRPC end-to-end typesafe API development: router architecture, procedure design, Zod validation, middleware chaining, error handling, Vertical Slice Architecture.
npx claudepluginhub ravnhq/ai-toolkitThis skill is limited to using the following tools:
Type-safe remote procedure calls with full client-server type inference. No code generation needed. tRPC excels at:
rules/_sections.mdrules/arch-one-procedure-per-file.mdrules/arch-vertical-slice.mdrules/cross-no-slice-imports.mdrules/data-repository-per-slice.mdrules/error-domain-specific.mdrules/proc-middleware-composition.mdrules/proc-procedure-hierarchy.mdrules/schema-always-extract.mdrules/schema-always-output.mdrules/schema-input-validation-zod.mdBuilds end-to-end type-safe APIs with tRPC including routers, procedures, middleware, subscriptions, Zod validation, and Next.js/React integration for TypeScript full-stack apps.
Provides tRPC v11 knowledge including SSE subscriptions with tracked() reconnection, streaming queries/mutations, TanStack React Query options API, Next.js server actions, lazy routers, OpenAPI support. Load before writing tRPC v11 code.
Designs production-ready Next.js App Router API routes with auth guards, Zod validation, typed responses, and error handling for RESTful endpoints and schemas.
Share bugs, ideas, or general feedback.
Type-safe remote procedure calls with full client-server type inference. No code generation needed. tRPC excels at:
unstable_pipe() for authentication, logging, authorizationTRPCError codes mapped to HTTP status automaticallyCore patterns: procedures (queries/mutations) in routers, input/output schemas for contracts, middleware for cross-cutting concerns, domain errors with proper codes.
When designing tRPC APIs:
invitations, payments, users).procedure.input().query()unstable_pipe()TRPCError with domain-specific codes, not plain ErrorPatterns are organized by concern:
See rules/ for implementation patterns and examples.
User: "Add a tRPC mutation for creating invoices with Zod input validation."
Expected behavior: Use tech-trpc guidance, apply procedure design with Zod schema and proper error handling.
User: "Write a Python Flask endpoint for file uploads."
Expected behavior: Do not prioritize tech-trpc; choose a more relevant skill or proceed without it.
Error: Throwing plain Error in procedures
Cause: Plain errors become INTERNAL_SERVER_ERROR (500); clients cannot distinguish errors
Solution: Throw TRPCError with domain code: throw new TRPCError({ code: 'NOT_FOUND', message: '...' })
Error: Middlewares not chaining properly; context lost
Cause: Middlewares not piped with unstable_pipe(); context isolation between middleware layers
Solution: Use .unstable_pipe() to chain middleware and extend context
Error: Client receives generic "Input validation failed"
Cause: No custom errorFormatter configured; Zod errors not sent to client
Solution: Configure initTRPC.create({ errorFormatter }) to flatten Zod errors in response
Error: Middleware context not accessible in procedure
Cause: Middleware not piped or context not merged in opts.next()
Solution: Ensure middleware returns opts.next({ ctx: { ...prevCtx, newKey: value } })
Error: Procedure types leak into client; can import server code
Cause: Exporting procedure instance instead of type; typeof appRouter not used
Solution: Export only type AppRouter = typeof appRouter; client imports type only