Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
pproenca avatar

Tanstack Query

  • 376 installs
  • 191 repo stars
  • Updated July 24, 2026
  • pproenca/dot-skills

tanstack-query is an agent skill that applies 40 TanStack Query v5 performance rules across eight categories for developers optimizing useQuery, useMutation, caching, and prefetch patterns in React apps.

About

tanstack-query is an agent skill from pproenca/dot-skills that distills 40 concrete performance rules across eight categories for TanStack Query v5, covering query key design, staleTime and gcTime caching, mutations, prefetch flows, infinite queries, optimistic updates, and render stability. The skill inspects useQuery and useMutation usage, queryClient invalidation, centralized key factories, and Suspense integration, mapping each recommendation to priority levels so developers apply highest-impact fixes first. Developers reach for tanstack-query when refactoring request waterfalls, reducing redundant refetches, tuning staleTime policies, or reviewing PRs with TanStack Query caching smells. tanstack-query explicitly does not generate query hooks from OpenAPI—that belongs to the orval skill—and does not cover MSW test mocking handled by test-msw. Install with npx add-skill pproenca/dot-skills --skill tanstack-query; skill metadata version 1.0.0. Use during React data-layer refactors when cache hit rate, invalidation precision, or mutation UX is the bottleneck.

  • tanstack-query

Tanstack Query by the numbers

  • 376 all-time installs (skills.sh)
  • +9 installs in the week ending Aug 4, 2026 (Skillselion tracking)
  • Ranked #1,144 of 4,347 Backend & APIs skills by installs in the Skillselion catalog
  • Data as of Aug 4, 2026 (Skillselion catalog sync)
npx skills add https://github.com/pproenca/dot-skills --skill tanstack-query

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs376
repo stars191
Last updatedJuly 24, 2026
Repositorypproenca/dot-skills

How do you optimize TanStack Query v5 caching?

Use tanstack-query for development tasks

Who is it for?

React developers using TanStack Query v5 who need prioritized caching, mutation, and prefetch optimizations with concrete refactor guidance.

Skip if: Teams needing OpenAPI-generated query hooks or MSW API mocking, which tanstack-query explicitly excludes in favor of orval and test-msw skills.

When should I use this skill?

User mentions useQuery, useMutation, queryClient, staleTime, prefetch, infinite queries, or TanStack Query performance review.

What you get

Prioritized TanStack Query refactors covering query keys, staleTime or gcTime tuning, invalidation strategy, and prefetch or mutation patterns.

  • Prioritized query refactor recommendations
  • Caching and invalidation policy guidance

By the numbers

  • Contains 40 rules across 8 categories for TanStack Query v5
  • Skill metadata version 1.0.0

Files

SKILL.mdMarkdownGitHub ↗

TanStack Query Best Practices

Comprehensive performance optimization guide for TanStack Query v5 applications. Contains 40 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

PriorityCategoryImpactPrefix
1Query Key StructureCRITICALtquery-
2Caching ConfigurationCRITICALcache-
3Mutation PatternsHIGHmutation-
4Prefetching & WaterfallsHIGHprefetch-
5Infinite QueriesMEDIUMinfinite-
6Suspense IntegrationMEDIUMsuspense-
7Error & Retry HandlingMEDIUMerror-
8Render OptimizationLOW-MEDIUMrender-

Quick Reference

1. Query Key Structure (CRITICAL)

  • tquery-key-factories - Use centralized query key factories
  • tquery-hierarchical-keys - Structure keys from generic to specific
  • tquery-always-arrays - Always use array query keys
  • tquery-serializable-objects - Use serializable objects in keys
  • tquery-options-pattern - Use queryOptions for type-safe sharing
  • tquery-colocate-keys - Colocate query keys with features

2. Caching Configuration (CRITICAL)

  • cache-staletime-gctime - Understand staleTime vs gcTime
  • cache-global-defaults - Configure global defaults appropriately
  • cache-placeholder-vs-initial - Use placeholderData vs initialData correctly
  • cache-invalidation-precision - Invalidate with precision
  • cache-refetch-triggers - Control automatic refetch triggers
  • cache-enabled-option - Use enabled for conditional queries

3. Mutation Patterns (HIGH)

  • mutation-optimistic-updates - Implement optimistic updates with rollback
  • mutation-invalidate-onsettled - Invalidate in onSettled, not onSuccess
  • mutation-cancel-queries - Cancel queries before optimistic updates
  • mutation-setquerydata - Use setQueryData for immediate cache updates
  • mutation-avoid-parallel - Avoid parallel mutations on same data

4. Prefetching & Waterfalls (HIGH)

  • prefetch-avoid-waterfalls - Avoid request waterfalls
  • prefetch-on-hover - Prefetch on hover for perceived speed
  • prefetch-in-queryfn - Prefetch dependent data in queryFn
  • prefetch-server-components - Prefetch in Server Components
  • prefetch-flatten-api - Flatten API to reduce waterfalls

5. Infinite Queries (MEDIUM)

  • infinite-max-pages - Limit infinite query pages with maxPages
  • infinite-flatten-pages - Flatten pages for rendering
  • infinite-refetch-behavior - Understand infinite query refetch behavior
  • infinite-loading-states - Handle infinite query loading states correctly

6. Suspense Integration (MEDIUM)

  • suspense-use-suspense-hooks - Use Suspense hooks for simpler loading states
  • suspense-error-boundaries - Always pair Suspense with Error Boundaries
  • suspense-parallel-queries - Combine Suspense queries with useSuspenseQueries
  • suspense-boundaries-placement - Place Suspense boundaries strategically

7. Error & Retry Handling (MEDIUM)

  • error-retry-config - Configure retry with exponential backoff
  • error-conditional-retry - Use conditional retry based on error type
  • error-global-handler - Use global error handler for common errors
  • error-display-patterns - Display errors appropriately
  • error-throw-on-error - Use throwOnError with Error Boundaries

8. Render Optimization (LOW-MEDIUM)

  • render-select-memoize - Memoize select functions
  • render-select-derived - Use select to derive data and reduce re-renders
  • render-notify-props - Use notifyOnChangeProps to limit re-renders
  • render-structural-sharing - Understand structural sharing
  • render-tracked-props - Avoid destructuring all properties

How to Use

Read individual reference files for detailed explanations and code examples:

  • Section definitions - Category structure and impact levels
  • Reference files: references/{prefix}-{slug}.md

Each reference file contains:

  • Brief explanation of why it matters
  • Incorrect code example with explanation
  • Correct code example with explanation
  • Additional context and references

Related Skills

  • For generating type-safe query hooks, see orval skill
  • For mocking API responses in tests, see test-msw skill
  • For React 19 data fetching patterns, see react-19 skill

Full Compiled Document

For the complete guide with all rules expanded: AGENTS.md

Related skills

How it compares

Pick tanstack-query over generic React performance skills when the bottleneck is TanStack Query caching, invalidation, or mutation patterns specifically.

FAQ

How many rules does tanstack-query include?

tanstack-query provides 40 concrete TanStack Query v5 rules organized into eight categories, prioritized by impact for refactors, new implementations, and automated code transformations.

Does tanstack-query generate hooks from OpenAPI?

tanstack-query does not generate query hooks from OpenAPI schemas. The skill directs developers to the orval skill for OpenAPI hook generation and test-msw for API mocking in tests.

Backend & APIsbackendintegrations

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.