
- Installs
- 470
- Last 24h
- —
- Trending rank
- —
- Security
- Not audited
Install
Works with every agent the skills CLI supports.
npx skills add https://github.com/pymodel/react-frontend-skills --skill tanstack-query- 01
Install
Run the command in your project. The CLI asks which agents to install for.
- 02
Describe the task
Ask your agent for something this skill covers. It loads tanstack-query automatically when relevant.
- 03
Review the result
The agent follows the SKILL.md steps, scripts and references bundled with the skill.
SKILL.md
The instructions your agent reads when the skill is triggered.
TanStack Query Best Practices
Comprehensive performance optimization guide for TanStack Query v5 applications. Contains 41 rules across 8 categories, prioritized by impact to guide automated refactoring and code generation.
When to Apply
Reference these guidelines when:
- Writing new queries, mutations, or data fetching logic
- Implementing caching strategies (staleTime, gcTime)
- Reviewing code for performance issues or request waterfalls
- Refactoring existing TanStack Query code
- Implementing infinite queries, Suspense, or optimistic updates
Rule Categories by Priority
| Priority | Category | Impact | Prefix |
|---|---|---|---|
| 1 | Query Key Structure | CRITICAL | tquery- |
| 2 | Caching Configuration | CRITICAL | cache- |
| 3 | Mutation Patterns | HIGH | mutation- |
| 4 | Prefetching & Waterfalls | HIGH | prefetch- |
| 5 | Infinite Queries | MEDIUM | infinite- |
| 6 | Suspense Integration | MEDIUM | suspense- |
| 7 | Error & Retry Handling | MEDIUM | error- |
| 8 | Render Optimization | LOW-MEDIUM | render- |
Quick Reference
1. Query Key Structure (CRITICAL)
tquery-key-factories- Use centralized query key factoriestquery-hierarchical-keys- Structure keys from generic to specifictquery-always-arrays- Always use array query keystquery-serializable-objects- Use serializable objects in keystquery-options-pattern- Use queryOptions for type-safe sharingtquery-colocate-keys- Colocate query keys with features
2. Caching Configuration (CRITICAL)
cache-staletime-gctime- Understand staleTime vs gcTimecache-global-defaults- Configure global defaults appropriatelycache-placeholder-vs-initial- Use placeholderData vs initialData correctlycache-invalidation-precision- Invalidate with precisioncache-refetch-triggers- Control automatic refetch triggerscache-enabled-option- Use enabled or skipToken for conditional queries
3. Mutation Patterns (HIGH)
mutation-optimistic-updates- Implement optimistic updates with rollbackmutation-invalidate-onsettled- Choose invalidation callbacks by mutation contractmutation-cancel-queries- Cancel queries before optimistic updatesmutation-setquerydata- Use setQueryData for immediate cache updatesmutation-avoid-parallel- Avoid parallel mutations on same data
4. Prefetching & Waterfalls (HIGH)
prefetch-avoid-waterfalls- Avoid request waterfallsprefetch-on-hover- Prefetch on hover for perceived speedprefetch-in-queryfn- Start follow-up prefetches when keys become knownprefetch-server-components- Prefetch in Server Componentsprefetch-infinite-query- Prefetch infinite lists with queryClient.infiniteQuery (5.102+)prefetch-flatten-api- Flatten API to reduce waterfalls
5. Infinite Queries (MEDIUM)
infinite-max-pages- Limit infinite query pages with maxPagesinfinite-flatten-pages- Flatten pages for renderinginfinite-refetch-behavior- Understand infinite query refetch behaviorinfinite-loading-states- Handle infinite query loading states correctly
6. Suspense Integration (MEDIUM)
suspense-use-suspense-hooks- Use Suspense hooks for simpler loading statessuspense-error-boundaries- Always pair Suspense with Error Boundariessuspense-parallel-queries- Combine Suspense queries with useSuspenseQueriessuspense-boundaries-placement- Place Suspense boundaries strategically
7. Error & Retry Handling (MEDIUM)
error-retry-config- Configure retry with exponential backofferror-conditional-retry- Use conditional retry based on error typeerror-global-handler- Use global error handler for common errorserror-display-patterns- Display errors appropriatelyerror-throw-on-error- Use throwOnError with Error Boundaries
8. Render Optimization (LOW-MEDIUM)
render-select-memoize- Memoize select functionsrender-select-derived- Use select to derive data and reduce re-rendersrender-notify-props- Rely on tracked properties before notifyOnChangePropsrender-structural-sharing- Understand structural sharingrender-tracked-props- Preserve tracked-property optimization
How to Use
Run in the project root first:
npx -y @pymodel/react-frontend-skills detect # installed vs. targeted versions
npx -y @pymodel/react-frontend-skills scan --skill tanstack-query # deprecated APIs → rule IDs
Read references/<rule-id>.md for each rule above that matches the task and for each scan hit: why it matters, then incorrect vs. correct code.
Related Skills
- For mocking API responses in tests, see
mswskill - For React 19 data fetching patterns, see
reactskill
FAQ
What does the tanstack-query skill do?
TanStack Query v5 data fetching and caching.
How do I install tanstack-query?
Run npx skills add https://github.com/pymodel/react-frontend-skills --skill tanstack-query in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/tanstack-query/ (personal) or .claude/skills/tanstack-query/ (project).
Which AI agents can use tanstack-query?
Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.
Is tanstack-query safe to install?
No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.
Who maintains tanstack-query?
It is published by pymodel in pymodel/react-frontend-skills. It has 470 recorded installs.
More from pymodel/react-frontend-skills
ui-design
pymodel/react-frontend-skills
Accessible, responsive frontend UI and UX design.
typescript
pymodel/react-frontend-skills
TypeScript types, tsconfig and TypeScript 7 migration.
tailwind
pymodel/react-frontend-skills
Tailwind CSS v4 styling and configuration.
zod
pymodel/react-frontend-skills
Zod 4 schema validation and type inference.
Popular frontend & design skills
setup-matt-pocock-skills
mattpocock/skills
Configure this repo for the engineering skills: set up its issue tracker, triage label vocabulary, and domain doc layout. Run once before first use of the other engineering skills.
frontend-design
anthropics/skills
Guidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults.
hyperframes-animation
heygen-com/hyperframes
All animation knowledge for HyperFrames — atomic motion rules, multi-phase scene blueprints, scene transitions, broader motion-design techniques, AND the seven runtime adapters (GSAP default, plus Lottie, Three.js, Anime.js, CSS keyframes, Web Animations API, TypeGPU). Use for any motion or animation task: pick 2-4 rules and compose, or load a blueprint, or look up runtime-specific API (e.g. GSAP eases / Lottie player / Three.js mixer). Also covers auditing an existing composition's choreography (animation map) and 24 named text-animation effects. HyperFrames-native: single paused timeline, seek-safe, deterministic.
prototype
mattpocock/skills
Build a throwaway prototype to answer a design question. Use when the user wants to sanity-check whether a state model or logic feels right, or explore what a UI should look like.
hyperframes-core
heygen-com/hyperframes
The HyperFrames composition contract — build one renderable project. Use for composition structure, the data- timing attributes, class="clip", tracks, sub-compositions, variables, framework-owned media playback, deterministic-render rules, and validation. Read before writing composition HTML.
vercel-react-best-practices
vercel-labs/agent-skills
React and Next.js performance optimization guidelines from Vercel Engineering. This skill should be used when writing, reviewing, or refactoring React/Next.js code to ensure optimal performance patterns. Triggers on tasks involving React components, Next.js pages, data fetching, bundle optimization, or performance improvements.