Agent skill · software engineering · lobehub
trpc-router
Use for server TRPC routers, procedures and API endpoints in apps/server/src/routers.
Why this skill is useful
Provides specific patterns and conventions for TRPC router development that the AI wouldn't reliably generate on its own.
What it needs
About 2k tokens when loaded. Last updated 2026-08-07. 81,352 stars on the source repository.
What this skill does
TRPC Router Guide File Location Routers: apps/server/src/routers/lambda/<domain>.ts Helpers: apps/server/src/routers/lambda/helpers/ Schemas: apps/server/src/routers/lambda/schema/ Router Structure Imports Middleware: Inject Models into ctx Always use middleware to inject models into ctx instead of creating new Model(ctx.serverDB, ctx.userId) inside every procedure. Then use ctx.fooModel in procedures: Exception: When a model needs a different userId (e.g., watchdog iterating over multiple users' tasks), create it inline. Procedure Pattern Aggregated Detail Endpoint For views that need multiple related data, create a single detail procedure that fetches everything in parallel: This avoids the CLI or frontend making N sequential requests. Conventions Return shape: { data, success: true } for queries, { data?, message, success: true } for mutations Error handling: re-throw TRPCError, wrap others with console.error + new TRPCError Input validation: use zod schemas, define at file top Router name: export const fooRouter = router({ ... }) Procedure names: alphabetical order within the router object Log prefix: [domain:procedure] format, e.g. [task:create]
How to use it
Reference it in AdaL, Claude Code, Cursor or any coding agent — nothing to install:
@skills lobehub/trpc-router