Trpc

From Esposter/Esposter · View interactive version

Trpc is an AI agent skill from the GitHub repository Esposter/Esposter. Apply when writing tRPC routers, procedures, or router tests. Esposter's tRPC conventions — how a router, a procedure and its input are laid out, named and guarded, and how a client calls one.

How to use this skill

Skill file

tRPC Conventions

Settled — do not re-propose

Deep dives

Procedures

Where the Pieces Live

One input schema file per procedure under shared/models/db/<feature>/, even for identical shapes; helpers one per file under server/services/<feature>/, a store-shared one under shared/services/, a Functions-shared query under packages/db, and a live event's union under packages/db-schema/src/models/realtime/ (references/file-placement.md).

Client-Side Calling Conventions

Every user-facing read and write goes through useQuery/useMutation; never a bare {} input (trpc-procedure/no-empty-input); an empty optional id is omitted and an empty required one returns early; a reader-sized list in a query's input is read in chunks, since it rides the URL (references/client-calls.md).

Live updates are not tRPC subscriptions. The rule, and how a client takes a frame, is references/subscriptions.md.

Router Structure

The client path mirrors the file path; sub-routers compose in the feature's index.ts through a base*Router; no Function.prototype name is a key (trpc-procedure/no-prototype-key) (references/router-structure.md).

Procedure & Result Naming

Every query names its verb — read*, search*, generate* (trpc-procedure/require-query-verb), a count is read*Count, a result type ends in Result, upsert* for an upsert, and a socket event's type is named for the write that sends it (references/procedure-naming.md).

Procedure Helpers (Room RBAC)

getMemberProcedure or getPermissionsProcedure from server/trpc/procedure/room/, and a read takes the builder its data deserves, never the one its caller's UI implies (references/room-procedures.md).

Ownership Guards in Mutations

ownedBy(table, id, userId) and inRoom(table, id, roomId), never a hand-written and(eq…); a router file holds its router({ ... }) and nothing else (references/ownership-guards.md).

Router and Store Structure

One router and one Pinia store per table, named after the table (references/router-structure.md).

Error Handling

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.