Marketplace trpc-scaffolder
Scaffolds tRPC routers, procedures, and Zod schemas with full type safety following DevPrep AI patterns
install
source · Clone the upstream repo
git clone https://github.com/aiskillstore/marketplace
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/aiskillstore/marketplace "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/ariegoldkin/trpc-scaffolder" ~/.claude/skills/aiskillstore-marketplace-trpc-scaffolder && rm -rf "$T"
manifest:
skills/ariegoldkin/trpc-scaffolder/SKILL.mdsource content
tRPC Scaffolder
Automate creation of type-safe tRPC endpoints with Zod validation.
TL;DR: Run scripts to create routers/schemas, register in
_app.ts, validate with scripts.
Auto-Triggers
Auto-triggered by keywords:
- "new endpoint", "create endpoint", "tRPC procedure"
- "new router", "API", "Zod schema"
Quick Standards
File Locations
lib/trpc/routers/ _app.ts # Register all routers here ⚠️ {name}.ts # Router files lib/trpc/schemas/ {entity}.schema.ts # Zod schemas
Router Pattern
export const nameRouter = router({ doThing: publicProcedure .input(inputSchema) .output(outputSchema) .mutation(async ({ input }) => { /* logic */ }), });
Schema Pattern
export const inputSchema = z.object({ field: z.string().min(1), }); export type Input = z.infer<typeof inputSchema>; // ⚠️ Required!
Registration (Required!)
// In _app.ts export const appRouter = router({ ai: aiRouter, name: nameRouter, // ⬅️ Add new routers here });
Run Scripts
Create Router
./.claude/skills/trpc-scaffolder/scripts/create-router.sh user # Creates: lib/trpc/routers/user.ts # ⚠️ Remember to register in _app.ts!
Add Procedure
./.claude/skills/trpc-scaffolder/scripts/add-procedure.sh ai getHints query # Outputs code snippet to add to router
Create Schema
./.claude/skills/trpc-scaffolder/scripts/create-schema.sh hint # Creates: lib/trpc/schemas/hint.schema.ts
Validate Setup
./.claude/skills/trpc-scaffolder/scripts/validate-trpc.sh # Checks: router registration, type exports
Quick Reference
Query vs Mutation
| Type | Use For | Method |
|---|---|---|
| Query | Fetch data (GET) | |
| Mutation | Modify data (POST/PUT/DELETE) | |
Common Zod Patterns
| Type | Pattern | Example |
|---|---|---|
| String | | Name validation |
| Number | | Difficulty 0-10 |
| Email validation | |
| Optional | | Optional field |
| Array | | At least 1 item |
| Enum | | Fixed choices |
| Object | | Nested object |
Naming Conventions
- Routers:
(e.g.,{domain}Router
,aiRouter
)userRouter - Procedures:
(e.g.,camelCase
,generateQuestions
)getHints - Schemas:
{action}{Entity}{Input\|Output}Schema - Files:
,{entity}.schema.ts{domain}.ts
Error Codes
| Code | When | Example |
|---|---|---|
| Resource doesn't exist | User not found |
| Invalid input | Validation failed |
| Not authenticated | Login required |
| Not authorized | Access denied |
| Server error | API failure |
Common Fixes
Router Not Registered
// ❌ Forgot this step // ✅ Add to _app.ts: import { userRouter } from "./user"; export const appRouter = router({ ai: aiRouter, user: userRouter });
Missing Type Exports
// ❌ Schema without types export const userSchema = z.object({ name: z.string() }); // ✅ Always export inferred types export type User = z.infer<typeof userSchema>;
Wrong Procedure Type
// ❌ Using mutation for fetching data getData: publicProcedure.mutation(...) // ✅ Use query for GET operations getData: publicProcedure.query(...)
Schema Validation Error
// ❌ No validation field: z.string() // ✅ Add constraints field: z.string().min(1, "Field is required")
When to Load Additional Docs
SKILL.md is self-sufficient for:
- Creating routers and schemas
- Running scripts
- Fixing common errors
Load additional docs when needed:
| Need | Load |
|---|---|
| Step-by-step tutorial | |
| Advanced Zod patterns | (lines 1-80) |
| Error handling strategies | (lines 150-220) |
| Testing procedures | (lines 220-270) |
| Context & middleware | (lines 80-150) |
Code examples:
- ✅ Perfect:
,examples/good-router.tsexamples/good-schema.ts
Full project docs:
Docs/api-design.md, Docs/api-transition/trpc-migration.md
Version: 1.0.0 | Updated: October 2025 Pattern: Follows quality-reviewer structure (optimized)