tRPC
Expert guidance for tRPC (TypeScript Remote Procedure Call) including router setup, procedures, middleware, context, client configuration, and Next.js integration. Use this when building type-safe APIs, integrating tRPC with Next.js, or implementing client-server communication with full TypeScript inference.
Why use this skill?
Master end-to-end type safety with our expert tRPC skill. Get assistance with router setup, middleware, context, and Next.js integration for robust APIs.
Install via CLI (Recommended)
clawhub install openclaw/skills/skills/ifoster01/trpc-best-practicesWhat This Skill Does
The tRPC skill for OpenClaw provides expert-level assistance for implementing end-to-end typesafe APIs in TypeScript environments. It acts as an architectural advisor for developers using tRPC, streamlining the configuration of routers, procedures, middleware, and context. By leveraging TypeScript's inference engine, this skill helps users bridge the gap between their backend API definitions and frontend implementations without the overhead of manual code generation or schema synchronization.
Installation
To integrate this skill into your environment, use the OpenClaw command-line interface:
clawhub install openclaw/skills/skills/ifoster01/trpc-best-practices
Ensure you have the required peer dependencies installed in your project, specifically @tanstack/react-query and zod, to support the reactive data fetching and input validation layers required by modern tRPC setups.
Use Cases
This skill is ideal for projects requiring strict contract-based development. Use it when building full-stack applications with Next.js App Router, as it simplifies the complex boilerplate involved in linking server-side router definitions with client-side React Query hooks. It is also highly effective for refactoring existing Express or Next.js APIs into a centralized, typesafe tRPC structure, ensuring that any breaking changes in the API schema trigger immediate TypeScript errors in the frontend consuming the data.
Example Prompts
- "I'm setting up a new Next.js project with tRPC. Can you walk me through the correct way to structure my server context so that I can inject user session data into all my procedures?"
- "I have an existing router, but I need to implement a middleware that checks for authentication headers and logs the request execution time. How should I write this correctly in tRPC v11?"
- "My frontend component is failing to infer the return type of a specific mutation. Could you review my trpc.ts client definition and the app router configuration to see where the type inference chain is breaking?"
Tips & Limitations
When using this skill, always ensure that your Zod schemas are defined separately from your router definitions for better modularity. A common pitfall is attempting to use tRPC features that require older versions of React Query; ensure your versioning matches the current documentation. Remember that while tRPC provides exceptional type safety, it is strictly for TypeScript environments; if your project requires language-agnostic API consumption (like for external third-party developers), you may still need to maintain an OpenAPI or REST interface alongside your tRPC implementation.
Metadata
Not sure this is the right skill?
Describe what you want to build — we'll match you to the best skill from 16,000+ options.
Find the right skillPaste this into your clawhub.json to enable this plugin.
{
"plugins": {
"official-ifoster01-trpc-best-practices": {
"enabled": true,
"auto_update": true
}
}
}Tags(AI)
Flags: code-execution