Agent skill
trpc
tRPC end-to-end type safety, procedures, routers, middleware, and React integration.
Install this agent skill to your Project
npx add-skill https://github.com/a5c-ai/babysitter/tree/main/library/specializations/web-development/skills/trpc
SKILL.md
tRPC Skill
Expert assistance for building type-safe APIs with tRPC.
Capabilities
- Create type-safe procedures and routers
- Implement middleware for auth/validation
- Set up tRPC with Next.js/React
- Handle subscriptions
- Configure error handling
- Build type-safe client hooks
Usage
Invoke this skill when you need to:
- Build end-to-end type-safe APIs
- Integrate with React/Next.js
- Replace REST with type-safe RPC
- Implement real-time features
Patterns
Router Definition
// server/trpc/routers/user.ts
import { z } from 'zod';
import { router, publicProcedure, protectedProcedure } from '../trpc';
import { TRPCError } from '@trpc/server';
export const userRouter = router({
list: protectedProcedure
.input(z.object({
page: z.number().min(1).default(1),
limit: z.number().min(1).max(100).default(10),
search: z.string().optional(),
}))
.query(async ({ ctx, input }) => {
const users = await ctx.prisma.user.findMany({
where: input.search
? { name: { contains: input.search } }
: undefined,
skip: (input.page - 1) * input.limit,
take: input.limit,
});
return users;
}),
byId: protectedProcedure
.input(z.string())
.query(async ({ ctx, input }) => {
const user = await ctx.prisma.user.findUnique({
where: { id: input },
});
if (!user) {
throw new TRPCError({ code: 'NOT_FOUND' });
}
return user;
}),
create: protectedProcedure
.input(z.object({
name: z.string().min(1),
email: z.string().email(),
}))
.mutation(async ({ ctx, input }) => {
return ctx.prisma.user.create({ data: input });
}),
});
React Integration
// In component
const { data, isLoading } = trpc.user.list.useQuery({ page: 1 });
const createUser = trpc.user.create.useMutation();
<button onClick={() => createUser.mutate({ name, email })}>
Create
</button>
Best Practices
- Use Zod for input validation
- Implement proper middleware
- Leverage type inference
- Handle errors consistently
Target Processes
- t3-stack-development
- nextjs-full-stack
- type-safe-api
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
gsd-tools
Central utility skill for GSD operations. Provides config parsing, slug generation, timestamps, path operations, and orchestrates calls to other specialized skills. Acts as the unified entry point that the original gsd-tools.cjs provided via its lib/ modules (commands, config, core, init).
model-profile-resolution
Resolve model profile (quality/balanced/budget) at orchestration start and map agents to specific models. Enables cost/quality tradeoffs by selecting appropriate AI models for each agent role.
verification-suite
Plan structure validation, phase completeness checks, reference integrity verification, and artifact existence confirmation. Provides the structured verification layer ensuring GSD artifacts are well-formed and complete.
state-management
STATE.md reading, writing, and field-level updates. Provides cross-session state persistence via .planning/STATE.md with structured fields for current task, completed phases, blockers, decisions, and quick tasks.
git-integration
Git commit patterns, formats, and conventions for GSD methodology. Provides atomic commits per task, structured commit messages, planning file commits, branch management, and milestone tag operations.
frontmatter-parsing
YAML frontmatter parsing and manipulation for .planning/ documents. Provides read, write, update, query, and validation operations on frontmatter blocks in GSD markdown artifacts.
Didn't find tool you were looking for?