[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7EW89N9XSEETP9ED55833GZ":3,"skill-same:01M7EW89N9XSEETP9ED55833GZ":47},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":25,"commitSha":26,"skillDirectory":27,"forksCount":28,"repositoryHtmlUrl":29,"repositoryHomepageUrl":6,"ownerHtmlUrl":30,"ownerBlogUrl":31,"ownerDescription":6,"updatedAt":32,"install":33,"resources":46},"01M7EW89N9XSEETP9ED55833GZ","trpc-pro",null,"tRPC guidance — end-to-end typesafe APIs, routers, procedures, auth, and React Query integration.","TanNhatCMS\u002Fjarvis","TanNhatCMS","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F113796420?v=4","01M753MV17KG5CD3152G3WQEQY","KietNT","01M7EKEDYVYQ6PWVJJMZ911VMX",0,"MIT","https:\u002F\u002Fgithub.com\u002FTanNhatCMS\u002Fjarvis\u002Fblob\u002Fmain\u002Fskills\u002Fams-trpc-pro\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: trpc-pro\ndescription: tRPC guidance — end-to-end typesafe APIs, routers, procedures, auth, and React Query integration.\ncategory: development\n---\n\n## Overview\n\ntRPC gives you end-to-end type safety for TypeScript APIs without codegen or schemas: define procedures on the server, call them from the client like functions, and types flow automatically. It's the fastest path to a typesafe full-stack TypeScript app — and it's deliberately not a public-API technology. This skill covers structuring tRPC routers, procedure patterns (query\u002Fmutation\u002Fsubscription), auth via context, and the React Query integration that powers the client.\n\n## When to use\n\n- Building a full-stack TypeScript app (Next.js, Vite + Express, etc.).\n- Choosing between tRPC, REST, and GraphQL for internal APIs.\n- Structuring routers, procedures, and middleware in tRPC.\n- Adding auth, validation (Zod), and error handling to tRPC.\n- Using subscriptions (WebSockets\u002FSSE) with tRPC.\n- Migrating an existing REST API to tRPC incrementally.\n\n## Core concepts\n\n- **Procedures are the API.** `publicProcedure`, `protectedProcedure` (via middleware), `query`\u002F`mutation`\u002F`subscription` — each procedure is one endpoint with inferred input\u002Foutput types. No schema files, no codegen step.\n- **Routers compose.** Nest routers by domain (`appRouter` → `userRouter`, `orderRouter`) with `mergeRouters` or nested `.router()` calls. Router structure is your API structure — organize by domain, not by technical layer.\n- **Context is the request scope.** Created per request (user, DB client, request ID); middleware enriches or rejects it. Auth checks belong in middleware producing `protectedProcedure` — not repeated inside every procedure.\n- **Validation with Zod.** `.input(z.object({...}))` validates at runtime and infers TypeScript types. Validate every input; tRPC's type safety is compile-time only without it.\n- **Middleware pipeline.** Reusable wrappers for auth, logging, rate limiting: `.use()` chains that run before the procedure. Compose small middlewares rather than one god-middleware.\n- **Error shaping.** `TRPCError` with codes (`UNAUTHORIZED`, `NOT_FOUND`, `BAD_REQUEST`...) maps to HTTP statuses; unexpected errors masked in production. Keep error codes consistent — clients switch on them.\n- **React Query integration.** The client is a thin wrapper over TanStack Query: `trpc.order.get.useQuery()`, mutations with optimistic updates, automatic cache invalidation via `utils`. Learn invalidation patterns — stale UI is the common complaint.\n- **Batching.** `httpBatchLink` combines calls into one HTTP request — fewer round trips, but one slow procedure delays the batch; split latency-sensitive calls onto a separate link.\n- **Subscriptions.** WebSocket or SSE links for realtime; like all subscriptions, design for reconnect and resume. tRPC subscriptions are convenient but carry the same operational weight as raw WebSockets.\n- **It's not for public APIs.** tRPC assumes a TypeScript client and couples client\u002Fserver deploys. For third-party consumers, put a REST (or GraphQL) facade in front — don't expose tRPC directly.\n- **Versioning.** tRPC has no built-in versioning; evolve procedures additively, deprecate with naming or comments, and coordinate client\u002Fserver deploys since types are shared.\n- **Server-component caller.** `createCaller` invokes procedures directly inside React Server Components without HTTP — same validation and auth, zero round trip.\n- **Output validation.** `.output(zodSchema)` validates procedure results at runtime — catches service-layer shape drift before it reaches clients.\n\n## Practical workflow\n\n1. **Set up the foundation.** `initTRPC` with context creation (auth session, DB), a `publicProcedure` base, and middleware for logging; choose links (`httpBatchLink` default, `wsLink` if subscriptions).\n   ```ts\n   export const t = initTRPC.context\u003CContext>().create();\n   export const publicProcedure = t.procedure;\n   export const protectedProcedure = t.procedure.use(isAuthed);\n   ```\n2. **Build domain routers.** One router per domain with queries\u002Fmutations; Zod schemas for inputs; thin procedures calling services.\n   ```ts\n   export const orderRouter = t.router({\n     get: protectedProcedure\n       .input(z.object({ id: z.string().uuid() }))\n       .query(({ ctx, input }) => orderService.get(ctx, input.id)),\n     cancel: protectedProcedure\n       .input(z.object({ id: z.string().uuid() }))\n       .mutation(({ ctx, input }) => orderService.cancel(ctx, input.id)),\n   });\n   ```\n3. **Enforce auth in middleware.** `isAuthed` throws `UNAUTHORIZED` when `ctx.user` is missing; resource-level checks (ownership) inside services, not routers.\n4. **Handle errors consistently.** Throw `TRPCError` with the right code; global error formatter for logging + masking; clients map codes to UI states.\n5. **Wire the client.** React Query provider + tRPC client; use `useQuery`\u002F`useMutation` with `onSuccess` invalidation (`utils.order.get.invalidate()`); optimistic updates for snappy mutations with rollback on error.\n   ```ts\n   const utils = trpc.useUtils();\n   const cancel = trpc.order.cancel.useMutation({\n     onMutate: async (input) => {\n       await utils.order.get.cancel();\n       const prev = utils.order.get.getData({ id: input.id });\n       utils.order.get.setData({ id: input.id }, (o) => o && { ...o, status: \"cancelled\" });\n       return { prev };\n     },\n     onError: (_e, input, ctx) => utils.order.get.setData({ id: input.id }, ctx?.prev),\n     onSettled: (_d, _e, input) => utils.order.get.invalidate({ id: input.id }),\n   });\n   ```\n6. **Paginate inputs.** Cursor-based input schemas (`{ cursor, limit }`) for lists; never return unbounded arrays from a query.\n7. **Add subscriptions where needed.** `wsLink` + subscription procedures for live data; client reconnect logic; server-side cleanup on disconnect.\n8. **Deploy coordinated.** Since types are shared, deploy server and client together (monorepo) or version the router contract; monitor procedure-level error rates and latencies.\n\n## Common pitfalls\n\n- **No input validation** — trusting TypeScript types at runtime; every procedure needs a Zod schema.\n- **Auth inside procedures** — repeated, inconsistent checks; centralize in middleware → `protectedProcedure`.\n- **Fat procedures** — business logic in routers becomes untestable; push to services.\n- **Unbounded queries** — returning full tables; paginate every list procedure.\n- **Over-batching latency** — one slow procedure in a batch delays everything; split links by latency class.\n- **Exposing tRPC publicly** — third parties can't consume it without TypeScript; add a REST facade for external consumers.\n- **Ignoring invalidation** — mutations that don't invalidate queries leave stale UI; define invalidation per mutation.\n- **Leaking internal errors** — raw DB\u002Fvalidation errors to clients; format and mask in production.\n- **No rate limiting** — procedures are cheap to call in loops; add middleware-based limits on expensive ones.\n- **Breaking changes without coordination** — renaming a procedure breaks the client build; treat router changes as contract changes in CI.\n- **Skipping output validation** — service refactors silently changing response shapes; `.output()` schemas catch the drift in tests.\n- **Server-component waterfalls** — awaiting procedures sequentially in RSCs; parallelize with `Promise.all` or prefetch instead.\n","## Overview\n\ntRPC gives you end-to-end type safety for TypeScript APIs without codegen or schemas: define procedures on the server, call them from the client like functions, and types flow automatically. It's the fastest path to a typesafe full-stack TypeScript app — and it's deliberately not a public-API technology. This skill covers structuring tRPC routers, procedure patterns (query\u002Fmutation\u002Fsubscription), auth via context, and the React Query integration that powers the client.\n\n## When to use\n\n- Building a full-stack TypeScript app (Next.js, Vite + Express, etc.).\n- Choosing between tRPC, REST, and GraphQL for internal APIs.\n- Structuring routers, procedures, and middleware in tRPC.\n- Adding auth, validation (Zod), and error handling to tRPC.\n- Using subscriptions (WebSockets\u002FSSE) with tRPC.\n- Migrating an existing REST API to tRPC incrementally.\n\n## Core concepts\n\n- **Procedures are the API.** `publicProcedure`, `protectedProcedure` (via middleware), `query`\u002F`mutation`\u002F`subscription` — each procedure is one endpoint with inferred input\u002Foutput types. No schema files, no codegen step.\n- **Routers compose.** Nest routers by domain (`appRouter` → `userRouter`, `orderRouter`) with `mergeRouters` or nested `.router()` calls. Router structure is your API structure — organize by domain, not by technical layer.\n- **Context is the request scope.** Created per request (user, DB client, request ID); middleware enriches or rejects it. Auth checks belong in middleware producing `protectedProcedure` — not repeated inside every procedure.\n- **Validation with Zod.** `.input(z.object({...}))` validates at runtime and infers TypeScript types. Validate every input; tRPC's type safety is compile-time only without it.\n- **Middleware pipeline.** Reusable wrappers for auth, logging, rate limiting: `.use()` chains that run before the procedure. Compose small middlewares rather than one god-middleware.\n- **Error shaping.** `TRPCError` with codes (`UNAUTHORIZED`, `NOT_FOUND`, `BAD_REQUEST`...) maps to HTTP statuses; unexpected errors masked in production. Keep error codes consistent — clients switch on them.\n- **React Query integration.** The client is a thin wrapper over TanStack Query: `trpc.order.get.useQuery()`, mutations with optimistic updates, automatic cache invalidation via `utils`. Learn invalidation patterns — stale UI is the common complaint.\n- **Batching.** `httpBatchLink` combines calls into one HTTP request — fewer round trips, but one slow procedure delays the batch; split latency-sensitive calls onto a separate link.\n- **Subscriptions.** WebSocket or SSE links for realtime; like all subscriptions, design for reconnect and resume. tRPC subscriptions are convenient but carry the same operational weight as raw WebSockets.\n- **It's not for public APIs.** tRPC assumes a TypeScript client and couples client\u002Fserver deploys. For third-party consumers, put a REST (or GraphQL) facade in front — don't expose tRPC directly.\n- **Versioning.** tRPC has no built-in versioning; evolve procedures additively, deprecate with naming or comments, and coordinate client\u002Fserver deploys since types are shared.\n- **Server-component caller.** `createCaller` invokes procedures directly inside React Server Components without HTTP — same validation and auth, zero round trip.\n- **Output validation.** `.output(zodSchema)` validates procedure results at runtime — catches service-layer shape drift before it reaches clients.\n\n## Practical workflow\n\n1. **Set up the foundation.** `initTRPC` with context creation (auth session, DB), a `publicProcedure` base, and middleware for logging; choose links (`httpBatchLink` default, `wsLink` if subscriptions).\n   ```ts\n   export const t = initTRPC.context\u003CContext>().create();\n   export const publicProcedure = t.procedure;\n   export const protectedProcedure = t.procedure.use(isAuthed);\n   ```\n2. **Build domain routers.** One router per domain with queries\u002Fmutations; Zod schemas for inputs; thin procedures calling services.\n   ```ts\n   export const orderRouter = t.router({\n     get: protectedProcedure\n       .input(z.object({ id: z.string().uuid() }))\n       .query(({ ctx, input }) => orderService.get(ctx, input.id)),\n     cancel: protectedProcedure\n       .input(z.object({ id: z.string().uuid() }))\n       .mutation(({ ctx, input }) => orderService.cancel(ctx, input.id)),\n   });\n   ```\n3. **Enforce auth in middleware.** `isAuthed` throws `UNAUTHORIZED` when `ctx.user` is missing; resource-level checks (ownership) inside services, not routers.\n4. **Handle errors consistently.** Throw `TRPCError` with the right code; global error formatter for logging + masking; clients map codes to UI states.\n5. **Wire the client.** React Query provider + tRPC client; use `useQuery`\u002F`useMutation` with `onSuccess` invalidation (`utils.order.get.invalidate()`); optimistic updates for snappy mutations with rollback on error.\n   ```ts\n   const utils = trpc.useUtils();\n   const cancel = trpc.order.cancel.useMutation({\n     onMutate: async (input) => {\n       await utils.order.get.cancel();\n       const prev = utils.order.get.getData({ id: input.id });\n       utils.order.get.setData({ id: input.id }, (o) => o && { ...o, status: \"cancelled\" });\n       return { prev };\n     },\n     onError: (_e, input, ctx) => utils.order.get.setData({ id: input.id }, ctx?.prev),\n     onSettled: (_d, _e, input) => utils.order.get.invalidate({ id: input.id }),\n   });\n   ```\n6. **Paginate inputs.** Cursor-based input schemas (`{ cursor, limit }`) for lists; never return unbounded arrays from a query.\n7. **Add subscriptions where needed.** `wsLink` + subscription procedures for live data; client reconnect logic; server-side cleanup on disconnect.\n8. **Deploy coordinated.** Since types are shared, deploy server and client together (monorepo) or version the router contract; monitor procedure-level error rates and latencies.\n\n## Common pitfalls\n\n- **No input validation** — trusting TypeScript types at runtime; every procedure needs a Zod schema.\n- **Auth inside procedures** — repeated, inconsistent checks; centralize in middleware → `protectedProcedure`.\n- **Fat procedures** — business logic in routers becomes untestable; push to services.\n- **Unbounded queries** — returning full tables; paginate every list procedure.\n- **Over-batching latency** — one slow procedure in a batch delays everything; split links by latency class.\n- **Exposing tRPC publicly** — third parties can't consume it without TypeScript; add a REST facade for external consumers.\n- **Ignoring invalidation** — mutations that don't invalidate queries leave stale UI; define invalidation per mutation.\n- **Leaking internal errors** — raw DB\u002Fvalidation errors to clients; format and mask in production.\n- **No rate limiting** — procedures are cheap to call in loops; add middleware-based limits on expensive ones.\n- **Breaking changes without coordination** — renaming a procedure breaks the client build; treat router changes as contract changes in CI.\n- **Skipping output validation** — service refactors silently changing response shapes; `.output()` schemas catch the drift in tests.\n- **Server-component waterfalls** — awaiting procedures sequentially in RSCs; parallelize with `Promise.all` or prefetch instead.\n",{"name":5,"category":24,"description":7},"development","main","af388a77c2fe5e0b4fd879cca4300a0ffa9a6579","skills\u002Fams-trpc-pro",1,"https:\u002F\u002Fgithub.com\u002FTanNhatCMS\u002Fjarvis","https:\u002F\u002Fgithub.com\u002FTanNhatCMS","https:\u002F\u002Fmrkiet.name.vn","2026-11-07 14:23:08",{"source":8,"skillName":5,"commands":34,"prompt":44,"zipAvailable":45},[35,38,41],{"tool":36,"command":37},"npx","npx skills add TanNhatCMS\u002Fjarvis --skill trpc-pro",{"tool":39,"command":40},"bunx","bunx skills add TanNhatCMS\u002Fjarvis --skill trpc-pro",{"tool":42,"command":43},"pnpm","pnpm dlx skills add TanNhatCMS\u002Fjarvis --skill trpc-pro","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FTanNhatCMS\u002Fjarvis\u002Fblob\u002Fmain\u002Fskills\u002Fams-trpc-pro\u002FSKILL.md",true,[],[48,55,63,70,77,84],{"skillNo":49,"name":50,"nameZh":6,"description":51,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":52,"categories":53,"keywords":54,"publishedAt":19},"01M7EWYJR0J8DARY7E59Z6Y9MV","web-scrape","Turn web pages into LLM-ready markdown via the Firecrawl API (renders JS, anti-bot handling). Use when browser_open\u002Ffetch fails on JS-heavy pages, or when you need clean markdown\u002Fstructured extraction from a site. Requires FIRECRAWL_API_KEY.","https:\u002F\u002Fgithub.com\u002FTanNhatCMS\u002Fjarvis\u002Fblob\u002Fmain\u002Fskills\u002Fweb-scrape\u002FSKILL.md",[],[],{"skillNo":56,"name":57,"nameZh":6,"description":58,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":59,"sourceHtmlUrl":60,"categories":61,"keywords":62,"publishedAt":19},"01M7EWYBN5P6F2AJG3FR24T9BP","design-taste-frontend","tasteskill v2, the anti-slop frontend skill. Art direction for websites, distilled from a study of 247 curated gallery sites (One Page Love, Awwwards Sites of the Day). Deals researched directions (idea, composition, type, palette, photographs, section blueprints) from a library, enforces a strict no-slop house style with a real-browser inspector, and runs a look-and-fix loop on screenshots. Use this whenever you build, design, redesign, restyle, polish or review a landing page, marketing site, portfolio, product page, one-pager, hero or any public-facing web page, in any stack (HTML\u002FCSS, React, Next.js, Vue, Svelte, Astro, Tailwind) — also when the user says a page looks generic, templated, \"AI-made\", sloppy, or asks to make it look designed, premium, award-level or less like every other site. Not for dashboards or app screens.","https:\u002F\u002Fgithub.com\u002FTanNhatCMS\u002Fjarvis\u002Fblob\u002Fmain\u002Fskills\u002Ftaste-design\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FTanNhatCMS\u002Fjarvis\u002Fblob\u002Fmain\u002Fskills\u002Ftaste-design\u002FSKILL.md",[],[],{"skillNo":64,"name":65,"nameZh":6,"description":66,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":67,"categories":68,"keywords":69,"publishedAt":19},"01M7EWY8FQFNQ2GB7NZZWGSSDX","test-driven-development","Use when implementing any feature or bugfix, before writing implementation code","https:\u002F\u002Fgithub.com\u002FTanNhatCMS\u002Fjarvis\u002Fblob\u002Fmain\u002Fskills\u002Fsuperpowers-tdd\u002FSKILL.md",[],[],{"skillNo":71,"name":72,"nameZh":6,"description":73,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":74,"categories":75,"keywords":76,"publishedAt":19},"01M7EWY5SHBFRH1HDHVWM9K7TV","systematic-debugging","Use when encountering any bug, test failure, or unexpected behavior, before proposing fixes","https:\u002F\u002Fgithub.com\u002FTanNhatCMS\u002Fjarvis\u002Fblob\u002Fmain\u002Fskills\u002Fsuperpowers-debugging\u002FSKILL.md",[],[],{"skillNo":78,"name":79,"nameZh":6,"description":80,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":81,"categories":82,"keywords":83,"publishedAt":19},"01M7EWY3NM0Z0JAKS7HDZ24K66","requesting-code-review","Use when completing tasks, implementing major features, or before merging to verify work meets requirements","https:\u002F\u002Fgithub.com\u002FTanNhatCMS\u002Fjarvis\u002Fblob\u002Fmain\u002Fskills\u002Fsuperpowers-code-review\u002FSKILL.md",[],[],{"skillNo":85,"name":86,"nameZh":6,"description":87,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":88,"categories":89,"keywords":90,"publishedAt":19},"01M7EWY0WRMWX4M9ZFY0WKC593","brainstorming","You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation).","https:\u002F\u002Fgithub.com\u002FTanNhatCMS\u002Fjarvis\u002Fblob\u002Fmain\u002Fskills\u002Fsuperpowers-brainstorming\u002FSKILL.md",[],[]]