Skip to main content
skill CX Codex

tanstack-integration-best-practices — Claude Code skill for TanStack stacks

A skill that hands the agent rules for wiring TanStack Query, Router and Start together: loaders, SSR hydration, cache ownership. Useful once all three live in one codebase.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add DeckardGer/tanstack-agent-skills --skill tanstack-integration-best-practices -a claude-code
npx skills add DeckardGer/tanstack-agent-skills --skill tanstack-integration -a claude-code
Open on GitHub

What tanstack-integration-best-practices does

Rules are grouped by priority, from setup down to caching. The rules/ folder holds files under the setup-, flow-, cache- and ssr- prefixes. Each one explains why the pattern exists, shows the anti-pattern, then the recommended code, and notes when to skip it. The agent pulls these in while you build data fetching on TanStack Start.

Setup and SSR integration carry the highest weight. Those rules cover passing QueryClient through router context, wrapping the app in QueryClientProvider, aligning staleTime across router and queries, and calling setupRouterSsrQueryIntegration. For SSR there is also a separate QueryClient per request.

The rest concerns data flow. Loaders call ensureQueryData. Components use useSuspenseQuery. Server functions back the query functions, and mutations trigger invalidation through a shared pattern. Query owns the cache. Skip the install and your agent writes this from scratch instead.

What it helps with

  • align staleTime between router and queries
  • set up SSR with query hydration
  • pass QueryClient via router context
  • pair mutations with cache invalidation
  • stop double caching in router and Query

Example prompts for the agent

  • Add SSR with query hydration to my new TanStack Start project.
  • Move these loaders to ensureQueryData and tell me why.
  • After this mutation the cache is stale — show the invalidation pattern.

How to install tanstack-integration-best-practices

1Skills CLI (Vercel)

npx skills add DeckardGer/tanstack-agent-skills --skill tanstack-integration-best-practices -a claude-code
npx skills add DeckardGer/tanstack-agent-skills --skill tanstack-integration -a claude-code

2Manually: put the files in place

~/.claude/skills/tanstack-integration/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/tanstack-integration/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about tanstack-integration-best-practices

How do I install tanstack-integration-best-practices in Claude Code?

Two commands, in this order. First npx skills add DeckardGer/tanstack-agent-skills --skill tanstack-integration-best-practices -a claude-code. If the skill name is not found, the catalog lists an alternate path with the same tool: npx skills add DeckardGer/tanstack-agent-skills --skill tanstack-integration -a claude-code.

What does tanstack-integration-best-practices do?

It supplies the agent with rules for running TanStack Query, Router and Start side by side: setup, data flow, caching, SSR. The agent follows them while writing data fetching code.

Who should skip it?

Anyone using TanStack Query alone, without Router or Start. The context and SSR rules have nothing to attach to in that case.

Source text

SKILL.md · MIT
---
name: tanstack-integration-best-practices
description: Best practices for integrating TanStack Query with TanStack Router and TanStack Start. Patterns for full-stack data flow, SSR, and caching coordination.
---

# TanStack Integration Best Practices

Guidelines for integrating TanStack Query, Router, and Start together effectively. These patterns ensure optimal data flow, caching coordination, and type safety across the stack.

## When to Apply

- Setting up a new TanStack Start project
- Integrating TanStack Query with TanStack Router
- Configuring SSR with query hydration
- Coordinating caching between router and query
- Setting up type-safe data fetching patterns

## Rule Categories by Priority

| Priority | Category | Rules | Impact |
|----------|----------|-------|--------|
| CRITICAL | Setup | 3 rules | Foundational configuration |
| CRITICAL | SSR Integration | 1 rule | Router + Query SSR setup |
| HIGH | Data Flow | 4 rules | Correct data fetching patterns |
| MEDIUM | Caching | 3 rules | Performance optimization |
| MEDIUM | SSR | 2 rules | Additional SSR patterns |

## Quick Reference

### Setup (Prefix: `setup-`)

- `setup-query-client-context` — Pass QueryClient through router context
- `setup-provider-wrapping` — Correctly wrap with QueryClientProvider
- `setup-stale-time-coordination` — Coordinate staleTime between router and query

### Data Flow (Prefix: `flow-`)

- `flow-loader-query-pattern` — Use loaders with ensureQueryData
- `flow-suspense-query-component` — Use useSuspenseQuery in components
- `flow-mutations-invalidation` — Coordinate mutations with query invalidation
- `flow-server-functions-queries` — Use server functions for query functions

### Caching (Prefix: `cache-`)

- `cache-single-source` — Let TanStack Query manage caching
- `cache-preload-coordination` — Coordinate preloading between router and query
- `cache-invalidation-patterns` — Unified invalidation patterns

### SSR Integration (Prefix: `ssr-`)

- `ssr-dehydrate-hydrate` — Use setupRouterSsrQueryIntegration for automatic SSR

### Additional SSR (Prefix: `ssr-`)

- `ssr-per-request-client` — Create QueryClient per request
- `ssr-streaming-queries` — Handle streaming with queries

## How to Use

Each rule file in the `rules/` directory contains:
1. **Explanation** — Why this pattern matters
2. **Bad Example** — Anti-pattern to avoid
3. **Good Example** — Recommended implementation
4. **Context** — When to apply or skip this rule

## Full Reference

See individual rule files in `rules/` directory for detailed guidance and code examples.

© DeckardGer · MIT · DeckardGer/tanstack-agent-skills

Similar skills

Everything for Frontend and UI →

From the same set4

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor