tRPC's test setup and TypeScript conventions, which win where the generic pstack tdd, typescript-best-practices and principle-type-system-discipline skills disagree. Use when fixing a bug, writing or changing tests, or writing or reviewing TypeScript in packages/.
Getting started
Full instructionsInstall the skill, then ask your AI tool for the task in plain words. The full SKILL.md below shows what it covers.
Instructions: SKILL.mdv1.0.1
tRPC conventions
Tests
-
Every bug fix gets a regression test that fails without the fix, even when the test path is an integration test. Put it in
packages/tests/server/regression/issue-<number>-<slug>.test.ts, or beside the code's existing tests (the legacy React package haspackages/react-query/test/regression/). -
Test through a real client and server.
testServerAndClientResourceis in@trpc/client/__tests__/testClientResource; the React packages have their own helpers, so copy the setup from the nearest test.tsawait using ctx = testServerAndClientResource(router); -
Watch it fail, then pass:
pnpm vitest run <file>from the repo root. -
The PR's
Regression check:line names the test and what it catches without the fix. -
In new tests, wait on a condition with
vi.waitForrather than a fixed sleep. -
No
beforeEach,beforeAll,afterEachorafterAll(vitest/no-hooks). Each test sets up what it needs withusing/await using: a helper returns a disposable that undoes its setup, such asusing _timers = fakeTimersResource(). Share expensive read-only setup with a memoised getter instead ofbeforeAll. -
Add tests; don't rewrite or weaken existing ones unless the expected behaviour changed and the PR says why.
TypeScript
-
Internal (non-exported) parameters, properties and options are required. Pass absence explicitly as
null,undefined, a literal or a symbol, whichever fits:x: T | undefinedthat every caller passes is fine, but notx?: Tor an optional or defaulted parameter. Optionals are only conveniences on public APIs; normalise a public options object once at the boundary into a fully required internal shape.tsfunction connect(url: string, retry?: RetryOptions); // before function connect(url: string, retry: RetryOptions | null); // after -
Take one options object,
opts, and read its members. Destructure only keys read three or more times. -
Clean up with
await usingandmakeResource()ormakeAsyncResource(), nottry/finally. -
Brands use
__brand, as instream/tracked.ts.anyis fine in generic constraints such asAnyRouter. Declare return types only on public APIs. -
Lint (
.oxlintrc.json,tooling/oxlint-plugin/) already enforces type imports, at most three parameters, type-parameter names, no non-null assertions and exhaustive switches.
Explore more skills
Browse all- Adapter FastifyMount tRPC as a Fastify plugin with fastifyTRPCPlugin from @trpc/server/adapters/fastify. Configure prefix, trpcOptions…
- Typescript Best PracticesTypeScript best practices. Use when reading or editing any .ts or .tsx file.
- Adapter FetchDeploy tRPC on WinterCG-compliant edge runtimes with fetchRequestHandler() from @trpc/server/adapters/fetch. Supports…
- Service Oriented ArchitectureBreak a tRPC backend into multiple services with custom routing links that split on the first path segment…
- React Query Classic MigrationMigrate from @trpc/react-query (classic) to @trpc/tanstack-react-query. Run npx @trpc/upgrade CLI for automated…
- Nextjs Pages RouterSet up tRPC in Next.js Pages Router with createNextApiHandler, createTRPCNext, withTRPC HOC, SSR via ssr option and…
Security
Reviews (0)
More from tRPC
View source →Frequently asked questions about trpc-conventions
What does the trpc-conventions skill do?
tRPC's test setup and TypeScript conventions, which win where the generic pstack tdd, typescript-best-practices and principle-type-system-discipline skills disagree. Use when fixing a bug, writing or changing tests, or writing or reviewing TypeScript in packages/. It's a reusable SKILL.md instruction set that loads into your AI coding assistant on demand, no prompt engineering, no copy-pasting every session.
How do I install the trpc-conventions skill?
Run `npx @skills-hub-ai/cli install trpc-conventions` from your terminal. The CLI writes the SKILL.md to the correct location for your AI tool (e.g. ~/.claude/skills/trpc-conventions/ for Claude Code or ~/.cursor/skills/ for Cursor with --target cursor) and adds it to your project's .skills.json lockfile.
Which AI tools does trpc-conventions work with?
trpc-conventions runs in Claude Code. It follows the open Agent Skills standard (SKILL.md), so the same skill works in every supported tool without modification.
Is the trpc-conventions skill free?
Yes. Every skill on skills-hub.ai is free and open-source. There are no premium tiers, paywalls, or usage limits. You only pay for whatever AI assistant you're already using.
How do I use trpc-conventions after installing it?
In Claude Code, type `/trpc-conventions` (or whatever slash command the skill registers) and the AI follows the skill's instructions immediately. You can also reference it by name in natural language, your AI loads the skill into context when relevant.
Can I share the trpc-conventions skill with my team?
Yes. Commit your project's .skills.json lockfile and teammates run `npx @skills-hub-ai/cli install` (no args) to install every skill at the exact version you pinned. Organization-scoped installs work via skills-hub.ai organizations.
Badge for your README
Show that this skill is on Skills Hub. The badge links back to this page and shows the live install count.
[](https://skills-hub.ai/skills/trpc-conventions)<a href="https://skills-hub.ai/skills/trpc-conventions"><img src="https://skills-hub.ai/api/badges/skill/trpc-conventions" alt="Install on Skills Hub"></a>More options in the badge docs.