Skip to content
Back to skills

Trpc Patterns

ASecurity

Implement ChatJS tRPC routers, TanStack Query hooks, mutations, and cache invalidation. Use when adding or changing tRPC procedures or their React consumers in apps/chat.

  • 1,200 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added September 2, 2026
ai-agentsreactdatabasebackend

Works with

  • cli

Security analysis

A100/100

Scanned September 20, 2026

npx -y skills add FranciscoMoretti/chat-js --skill trpc-patterns --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Trpc Patterns?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Trpc Patterns
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/franciscomoretti-trpc-patterns-chat-js/badge)](https://www.skillsdirectory.com/skills/franciscomoretti-trpc-patterns-chat-js)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: trpc-patterns
description: Implement ChatJS tRPC routers, TanStack Query hooks, mutations, and cache invalidation. Use when adding or changing tRPC procedures or their React consumers in apps/chat.
---

# ChatJS tRPC patterns

## Backend

- Add feature routers under `apps/chat/trpc/routers/*.router.ts` and register them in `apps/chat/trpc/routers/_app.ts`.
- Use `protectedProcedure` for authenticated operations.
- Validate inputs with Zod and verify ownership before mutations.
- Keep database access in `apps/chat/lib/db/queries.ts`.

## React queries

Use `useTRPC()` with TanStack Query:

```tsx
const trpc = useTRPC();
const query = useQuery({
  ...trpc.feature.list.queryOptions(),
  enabled: Boolean(condition),
});
```

For mutations, use generated mutation options and invalidate related keys after success:

```tsx
const trpc = useTRPC();
const queryClient = useQueryClient();

const mutation = useMutation(
  trpc.feature.update.mutationOptions({
    onSuccess: () =>
      queryClient.invalidateQueries({
        queryKey: trpc.feature.list.queryKey(),
      }),
  })
);
```

Handle loading and error states in the consumer.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.