trpc-router

Create TRPC routers with middleware-based context injection and standardized procedures.

1|Updated Apr 14, 2026
One-click install
npx skills add https://github.com/andershi666/lobehub-hr-demo --skill trpc-router-andershi666
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: trpc-router
Source: https://github.com/andershi666/lobehub-hr-demo/tree/main/lobehub/.agents/skills/trpc-router
Command: npx skills add https://github.com/andershi666/lobehub-hr-demo --skill trpc-router-andershi666

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Building TRPC routers often lacks a consistent pattern for ctx injection, error handling, and procedure organization. This guide provides a blueprint to streamline router development and ensure reliability across API endpoints.

Core Features & Use Cases

  • Middleware pattern to inject models into ctx for consistent access in procedures.
  • Domain-oriented procedures with authedProcedure, standardized error handling, and input validation.
  • Aggregated detail endpoints and conventions for router naming and log prefixes to improve maintainability.

Quick Start

Create or update a TRPC router by following the example structure and implement procedures using authedProcedure with injected context models.

Frequently Asked Questions about trpc-router

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I structure a tRPC router for scalable server-side APIs?

Implement context injection in tRPC by applying a middleware pattern that injects models directly into the context. This allows procedures to consistently access required data models without repetitive setup or manual passing.

What is the best way to handle errors and validate input in tRPC procedures?

Handle errors and validate input in tRPC procedures by utilizing domain-oriented procedures with standardized error handling and built-in input validation. This ensures clear structure and predictable behavior for server-side API endpoints.

How do I create an authenticated tRPC procedure using context injection?

Create an authenticated tRPC procedure by implementing an authedProcedure that relies on injected context models. This pattern streamlines secure data access and maintains consistency across your server-side API implementation.

Does this tRPC router guide support organizing routers under src/server/routers?

Yes, this tRPC router guide applies to creating or modifying routers and implementing procedures specifically within src/server/routers. It provides clear naming conventions and log prefixes to improve maintainability.