trpc-patterns

Implement type-safe tRPC APIs with routers, procedures, and Zod validation.

15|3|Updated Apr 29, 2025
One-click install
npx skills add https://github.com/chaingraphlabs/chaingraph --skill trpc-patterns-chaingraphlabs
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: trpc-patterns
Source: https://github.com/chaingraphlabs/chaingraph/tree/main/.claude/skills/trpc-patterns
Command: npx skills add https://github.com/chaingraphlabs/chaingraph --skill trpc-patterns-chaingraphlabs

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps teams implement robust, type-safe APIs with tRPC by providing tested patterns for routers, procedures, subscriptions, and middleware.

Core Features & Use Cases

  • Clear pattern examples for initialization, context creation, and error handling.
  • Guidance on using zod validation, SuperJSON, and WS subscriptions across backend and frontend.
  • Real-world scenarios covering authentication, access control, and client-server communication.

Quick Start

Review the included trpc-patterns examples and integrate the shown patterns into a new or existing tRPC-based project.

Frequently Asked Questions about trpc-patterns

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

FAQPage Schema
How do I implement type-safe API routing with tRPC and Zod?

Create type-safe tRPC APIs by defining routers and procedures, then validating inputs with Zod schemas. This Skill provides pattern examples for initialization, context creation, and standard routing to ensure robust client-server communication.

How does context creation and middleware work in tRPC?

Context creation and middleware in tRPC work by passing request-specific data through procedures. This Skill demonstrates patterns for building context, handling errors, and enforcing access control and authentication across your API.

Can I use tRPC for WebSocket and SSE subscriptions?

Yes, you can use tRPC for WebSocket and SSE subscriptions. This Skill provides guidance on implementing WS subscriptions and SSE subscriptions to handle real-time data streaming between backend services and frontends.

What is the best way to handle data transformation with SuperJSON in tRPC?

The best way to handle data transformation with SuperJSON in tRPC is to apply it during client and server setup. This Skill demonstrates SuperJSON transformation patterns to preserve type safety for complex data structures across the API.

Does this tRPC pattern guide cover error handling and access control?

Yes, this tRPC pattern guide covers error handling and access control. It includes real-world scenarios demonstrating standard patterns for authentication, access control enforcement, and robust error handling within procedures.