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.
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-codeWhat 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
staleTimebetween router and queries - set up SSR with query hydration
- pass
QueryClientvia 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
ensureQueryDataand 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-codenpx skills add DeckardGer/tanstack-agent-skills --skill tanstack-integration -a claude-code2Manually: put the files in place
~/.claude/skills/tanstack-integration/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/tanstack-integration/
1Skills CLI (Vercel)
npx skills add DeckardGer/tanstack-agent-skills --skill tanstack-integration -a codex2Manually: put the files in place
.agents/skills/tanstack-integration/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add DeckardGer/tanstack-agent-skills --skill tanstack-integration -a cursor2Manually: put the files in place
.cursor/skills/tanstack-integration/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install DeckardGer/tanstack-agent-skills tanstack-integration2Manually: put the files in place
.github/skills/tanstack-integration/SKILL.md1Skills CLI (Vercel)
npx skills add DeckardGer/tanstack-agent-skills --skill tanstack-integration -a gemini-cli2Platform CLI
gemini skills install https://github.com/DeckardGer/tanstack-agent-skills --path skills/tanstack-integrationManually: put the files in place
.devin/skills/tanstack-integration/SKILL.mdThe legacy .windsurf/skills/ path still works
Skills CLI (Vercel)
npx skills add DeckardGer/tanstack-agent-skills --skill tanstack-integration -a opencodeClaude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
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