home / skills / ehtbanton / claudeskillsrepo / trpc-router-generator

trpc-router-generator skill

/trpc-router-generator

This skill generates complete trpc router files with type-safe procedures and Zod validation for rapid, reliable API development.

npx playbooks add skill ehtbanton/claudeskillsrepo --skill trpc-router-generator

Review the files below or copy the command above to add this skill to your agents.

Files (2)
SKILL.md
614 B
---
name: trpc-router-generator
description: Generate tRPC router files with procedures and validation. Triggers on "create trpc router", "generate trpc procedure", "trpc api", "typesafe api".
---

# tRPC Router Generator

Generate tRPC routers with type-safe procedures and Zod validation.

## Output Requirements

**File Output:** `*.router.ts` tRPC router files
**Format:** Valid tRPC v11
**Standards:** tRPC 11.x, Zod

## When Invoked

Immediately generate a complete tRPC router.

## Example Invocations

**Prompt:** "Create tRPC router for users"
**Output:** Complete `users.router.ts` with CRUD procedures.

Overview

This skill generates complete tRPC v11 router files with type-safe procedures and Zod validation. It produces ready-to-save *.router.ts files following tRPC 11.x patterns and idiomatic TypeScript. The goal is to speed up API scaffolding with correct types, input validation, and common CRUD patterns.

How this skill works

On trigger phrases like "create trpc router" or "trpc api", the skill emits a fully-formed router file that exports a tRPC router and its procedures. Each procedure includes Zod schemas for inputs and outputs, example contexts, and typed resolver stubs. The output adheres to tRPC v11 and Zod conventions so it can be dropped into a TypeScript project immediately.

When to use it

  • Scaffolding a new resource API (users, posts, products) with CRUD endpoints
  • Generating a typesafe API surface for front-end consumption
  • Prototyping server-side logic with validation already wired
  • Ensuring consistent tRPC + Zod patterns across a codebase
  • Onboarding or pairing when you want a correct initial router file

Best practices

  • Review and adapt the generated context typing to match your app's auth and DB clients
  • Keep Zod schemas colocated with procedures for single-source validation
  • Replace resolver stubs with actual business logic and preserve exported types
  • Use explicit input/output schemas for stable client typings
  • Run TypeScript checks after generation to catch environment-specific types

Example use cases

  • Create users.router.ts with list, get, create, update, delete procedures and Zod schemas
  • Generate posts.router.ts that includes pagination and search filters with typed inputs
  • Produce an auth.router.ts scaffold with signUp, signIn, refreshToken procedures and validation
  • Build nested routers (e.g., users.posts.router.ts) with typed context propagation
  • Quickly scaffold APIs during prototype sprints to iterate on client-server contracts

FAQ

Which tRPC and validation versions does this target?

It targets tRPC v11 and uses Zod for runtime validation and type inference.

Does the generator write files to disk?

It outputs the complete file contents for a *.router.ts file; integrate with your tooling to write to disk as needed.