Agent skill

Tanstack Query Best Practices

by DeckardGer in DeckardGer/tanstack-agent-skills

TanStack Query (React Query) best practices for data fetching, caching, mutations, and server state management.

MITAuto-check passedBackend & APIs

Install Tanstack Query Best Practices

skills CLI
$ npx skills add DeckardGer/tanstack-agent-skills --skill tanstack-query-best-practices -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install DeckardGer/tanstack-agent-skills tanstack-query-best-practices --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/DeckardGer/tanstack-agent-skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/tanstack-query .claude/skills/tanstack-query-best-practices && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
tanstack-query-best-practices
GitHub stars
222
Used in
1 other repo
Token cost
~1.2k tokens
SKILL.md length
475 words
Files
39
Skills in repo
4
Repo updated
First seen
Licence
MIT

At a glance

TanStack Query (React Query) best practices for data fetching, caching, mutations, and server state management.

  • Works in 4 steps: Explanation — Why this pattern matters → Bad Example — Anti-pattern to avoid → Good Example — Recommended implementation → …
  • Tasks that involve Caching
  • SKILL.md covers When to Apply, Rule Categories by Priority, Quick Reference and How to Use, plus 1 more section
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

Tanstack Query Best Practices is an agent skill from DeckardGer/tanstack-agent-skills. TanStack Query (React Query) best practices for data fetching, caching, mutations, and server state management. Activate when building data-driven React applications with server state.

Its SKILL.md is about 1.2k tokens, which your agent loads only when the skill is triggered. The skill folder holds 39 other files (for example `rules/cache-defaults.md`, `rules/cache-gc-time.md` and `rules/cache-invalidation.md`).

It sits in Backend & APIs, covering Caching and State management. It works with TanStack and React. The repository describes itself as: TanStack Agent Skills: Best practices for TanStack Query, Router, and Start for AI coding agents. The licence is MIT.

When your agent uses it

  • Tasks that involve Caching
  • Tasks that involve State management

Example prompts

  • “/tanstack-query-best-practices”

Workflow steps

4 steps, taken from the first numbered list in SKILL.md.

  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

What it can do on your machine

Read from SKILL.md and the folder at commit b2fc14c. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md.

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Tanstack Query Best Practices loads about 1.2k tokens when it runs. Until then it costs about 54 tokens; SKILL.md has 475 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~54
When it runs · the whole SKILL.md, loaded when a task matches
~1.2k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from DeckardGer/tanstack-agent-skills at commit b2fc14c, republished under its MIT licence (© DeckardGer). 475 words, ~1,210 tokens.

Download SKILL.mdSave it as .claude/skills/tanstack-query-best-practices/SKILL.md (or your agent's skills folder). This skill also uses 38 other files; get the full folder from GitHub.
name
tanstack-query-best-practices
description
TanStack Query (React Query) best practices for data fetching, caching, mutations, and server state management. Activate when building data-driven React applications with server state.

TanStack Query Best Practices

Comprehensive guidelines for implementing TanStack Query (React Query) patterns in React applications. These rules optimize data fetching, caching, mutations, and server state synchronization.

When to Apply

  • Creating new data fetching logic
  • Setting up query configurations
  • Implementing mutations and optimistic updates
  • Configuring caching strategies
  • Integrating with SSR/SSG
  • Refactoring existing data fetching code

Rule Categories by Priority

PriorityCategoryRulesImpact
CRITICALQuery Keys5 rulesPrevents cache bugs and data inconsistencies
CRITICALCaching5 rulesOptimizes performance and data freshness
HIGHMutations6 rulesEnsures data integrity and UI consistency
HIGHError Handling3 rulesPrevents poor user experiences
MEDIUMPrefetching4 rulesImproves perceived performance
MEDIUMParallel Queries2 rulesEnables dynamic parallel fetching
MEDIUMInfinite Queries3 rulesPrevents pagination bugs
MEDIUMSSR Integration4 rulesEnables proper hydration
LOWPerformance4 rulesReduces unnecessary re-renders
LOWOffline Support2 rulesEnables offline-first patterns

Quick Reference

Query Keys (Prefix: qk-)
  • qk-array-structure — Always use arrays for query keys
  • qk-include-dependencies — Include all variables the query depends on
  • qk-hierarchical-organization — Organize keys hierarchically (entity → id → filters)
  • qk-factory-pattern — Use query key factories for complex applications
  • qk-serializable — Ensure all key parts are JSON-serializable
Caching (Prefix: cache-)
  • cache-stale-time — Set appropriate staleTime based on data volatility
  • cache-gc-time — Configure gcTime for inactive query retention
  • cache-defaults — Set sensible defaults at QueryClient level
  • cache-invalidation — Use targeted invalidation over broad patterns
  • cache-placeholder-vs-initial — Understand placeholder vs initial data differences
Mutations (Prefix: mut-)
  • mut-invalidate-queries — Always invalidate related queries after mutations
  • mut-optimistic-updates — Implement optimistic updates for responsive UI
  • mut-rollback-context — Provide rollback context from onMutate
  • mut-error-handling — Handle mutation errors gracefully
  • mut-loading-states — Use isPending for mutation loading states
  • mut-mutation-state — Use useMutationState for cross-component tracking
Error Handling (Prefix: err-)
  • err-error-boundaries — Use error boundaries with useQueryErrorResetBoundary
  • err-retry-config — Configure retry logic appropriately
  • err-fallback-data — Provide fallback data when appropriate
Show full SKILL.md (182 more words)Show less
Prefetching (Prefix: pf-)
  • pf-intent-prefetch — Prefetch on user intent (hover, focus)
  • pf-route-prefetch — Prefetch data during route transitions
  • pf-stale-time-config — Set staleTime when prefetching
  • pf-ensure-query-data — Use ensureQueryData for conditional prefetching
Infinite Queries (Prefix: inf-)
  • inf-page-params — Always provide getNextPageParam
  • inf-loading-guards — Check isFetchingNextPage before fetching more
  • inf-max-pages — Consider maxPages for large datasets
SSR Integration (Prefix: ssr-)
  • ssr-dehydration — Use dehydrate/hydrate pattern for SSR
  • ssr-client-per-request — Create QueryClient per request
  • ssr-stale-time-server — Set higher staleTime on server
  • ssr-hydration-boundary — Wrap with HydrationBoundary
Parallel Queries (Prefix: parallel-)
  • parallel-use-queries — Use useQueries for dynamic parallel queries
  • query-cancellation — Implement query cancellation properly
Performance (Prefix: perf-)
  • perf-select-transform — Use select to transform/filter data
  • perf-structural-sharing — Leverage structural sharing
  • perf-notify-change-props — Limit re-renders with notifyOnChangeProps
  • perf-placeholder-data — Use placeholderData for instant UI
Offline Support (Prefix: offline-)
  • network-mode — Configure network mode for offline support
  • persist-queries — Configure query persistence for offline support

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. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 38 other files in skills/tanstack-query of DeckardGer/tanstack-agent-skills.

  • SKILL.md
  • rules/cache-defaults.md
  • rules/cache-gc-time.md
  • rules/cache-invalidation.md
  • rules/cache-placeholder-vs-initial.md
  • rules/cache-stale-time.md
  • rules/err-error-boundaries.md
  • rules/err-fallback-data.md
  • rules/err-retry-config.md
  • rules/inf-loading-guards.md
  • rules/inf-max-pages.md
  • rules/inf-page-params.md
  • rules/mut-error-handling.md
  • rules/mut-invalidate-queries.md
  • rules/mut-loading-states.md
  • rules/mut-mutation-state.md
  • rules/mut-optimistic-updates.md
  • rules/mut-rollback-context.md
  • rules/network-mode.md
  • rules/parallel-use-queries.md
  • … and 19 more

Open the folder on GitHubat commit b2fc14c

Used in 1 other repository

We found 1 copy of this SKILL.md (exact, near-identical or edited) in other folders, from 1 other GitHub owner. This page covers the copy in DeckardGer/tanstack-agent-skills, which our catalogue first saw on October 7, 2026.

Compare with similar skills

Tanstack Query Best Practices next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Tanstack Query Best Practices compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Tanstack Query Best Practices this skillDeckardGer/tanstack-agent-skills2221 repos~1.2kAutomated safety check: PassMIT
Olore Tanstack Query 4olorehq/olore103—~583Automated safety check: PassMIT
Tanstack Querysecondsky/claude-skills227—~7.9kAutomated safety check: PassMIT
Tanstack QueryMindrally/skills267—~3.6kAutomated safety check: PassApache-2.0
Olore Tanstack Query 3olorehq/olore103—~700Automated safety check: PassMIT
Olore Tanstack Query Latestolorehq/olore103—~487Automated safety check: PassMIT

Similar skills

  • Local TanStack Query documentation reference (v4). An agent skill from olorehq/olore.

    103 GitHub stars~583 tokensUpdated today
    Backend & APIsAuto-check passed
  • Tanstack Query

    secondsky/claude-skills

    TanStack Query v5 (React Query) server state management. An agent skill from secondsky/claude-skills.

    227 GitHub stars~7.9k tokensUpdated 9 days ago
    Frontend & DesignAuto-check passed
  • Tanstack Query

    Mindrally/skills

    Best practices for TanStack Query v5 (React Query) server state management, including query key factories, the queryOptions helper, mutations, optimistic updates, infinite queries, and Suspense mode.

    267 GitHub stars~3.6k tokensUpdated 1 mo ago
    Frontend & DesignAuto-check passed
  • Local TanStack Query v3 (React Query) documentation reference.

    103 GitHub stars~700 tokensUpdated today
    Frontend & DesignAuto-check passed
  • Local TanStack Query documentation reference (latest). An agent skill from olorehq/olore.

    103 GitHub stars~487 tokensUpdated today
    Frontend & DesignAuto-check passed
  • Trpc Patterns

    FranciscoMoretti/chat-js

    Implement ChatJS tRPC routers, TanStack Query hooks, mutations, and cache invalidation.

    1.2k GitHub stars~288 tokensUpdated today
    Backend & APIsAuto-check passed

More from DeckardGer/tanstack-agent-skills

  • Tanstack Router Best Practices

    DeckardGer/tanstack-agent-skills

    TanStack Router best practices for type-safe routing, data loading, search params, and navigation.

    222 GitHub stars~1.1k tokensUpdated 28 days ago
    Auto-check passed
  • Tanstack Start Best Practices

    DeckardGer/tanstack-agent-skills

    TanStack Start best practices for full-stack React applications.

    222 GitHub stars~1k tokensUpdated 28 days ago
    Auto-check passed
  • Tanstack Integration Best Practices

    DeckardGer/tanstack-agent-skills

    Best practices for integrating TanStack Query with TanStack Router and TanStack Start.

    222 GitHub stars~644 tokensUpdated 28 days ago
    Auto-check passed

Works with

Questions about Tanstack Query Best Practices

What does Tanstack Query Best Practices do?

TanStack Query (React Query) best practices for data fetching, caching, mutations, and server state management. Tanstack Query Best Practices is an agent skill from DeckardGer/tanstack-agent-skills. TanStack Query (React Query) best practices for data fetching, caching, mutations, and server state management.

When should I use Tanstack Query Best Practices?

Tanstack Query Best Practices fits situations like: tasks that involve Caching; tasks that involve State management.

How do I install Tanstack Query Best Practices in Claude Code?

Run `npx skills add DeckardGer/tanstack-agent-skills --skill tanstack-query-best-practices -a claude-code`. Or copy the skill folder (skills/tanstack-query in DeckardGer/tanstack-agent-skills) into .claude/skills/tanstack-query-best-practices in your project. Claude Code loads it when a task matches its description.

How do I install Tanstack Query Best Practices in Codex?

Run `npx skills add DeckardGer/tanstack-agent-skills --skill tanstack-query-best-practices -a codex`. Or copy the skill folder (skills/tanstack-query in DeckardGer/tanstack-agent-skills) into .agents/skills/tanstack-query-best-practices in your project. Codex loads it when a task matches its description.

Can I use Tanstack Query Best Practices in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add DeckardGer/tanstack-agent-skills --skill tanstack-query-best-practices -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/tanstack-query-best-practices, .gemini/skills/tanstack-query-best-practices, .github/skills/tanstack-query-best-practices and .opencode/skills/tanstack-query-best-practices in your project.

What does Tanstack Query Best Practices need to run?

SKILL.md names no scripts, command-line tools or credentials: Tanstack Query Best Practices is instructions for the agent only.

Does Tanstack Query Best Practices access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Tanstack Query Best Practices safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Tanstack Query Best Practices use?

Tanstack Query Best Practices is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Tanstack Query Best Practices use?

About 1.2k tokens (SKILL.md is roughly 4.8k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Tanstack Query Best Practices?

Skills that share tags, products or a category with Tanstack Query Best Practices: Olore Tanstack Query 4 (olorehq/olore, 103 stars), Tanstack Query (secondsky/claude-skills, 227 stars), Tanstack Query (Mindrally/skills, 267 stars) and Olore Tanstack Query 3 (olorehq/olore, 103 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Tanstack Query Best Practices?

DeckardGer (a GitHub user) maintains it in DeckardGer/tanstack-agent-skills, which has 222 GitHub stars. The repository holds 4 skills in this directory. The repository was last updated on September 9, 2026.

Source: DeckardGer/tanstack-agent-skills on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.