Agent skill

React Query Best Practices

by simstudioai in simstudioai/sim

Audit React Query usage for best practices — key factories, staleTime, mutations, and server state ownership

Apache-2.0Auto-check passed

Install React Query Best Practices

skills CLI
$ npx skills add simstudioai/sim --skill react-query-best-practices -a claude-code

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

GitHub CLI
$ gh skill install simstudioai/sim react-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/simstudioai/sim.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.agents/skills/react-query-best-practices .claude/skills/react-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
react-query-best-practices
GitHub stars
30k
Token cost
~1.2k tokens
SKILL.md length
580 words
Files
1
Skills in repo
40
Repo updated
First seen
Licence
Apache-2.0

At a glance

Audit React Query usage for best practices — key factories, staleTime, mutations, and server state ownership

  • Works in 3 steps: https://tkdodo.eu/blog/practical-react-qu… → https://tkdodo.eu/blog/effective-react-qu… → https://tkdodo.eu/blog/react-query-as-a-s…
  • SKILL.md covers Context, References, Rules to enforce and Steps
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

React Query Best Practices is an agent skill from simstudioai/sim. Audit React Query usage for best practices — key factories, staleTime, mutations, and server state ownership

Its SKILL.md is about 1.2k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It works with TanStack. The repository describes itself as: Sim is the collaborative workspace to build, deploy, and monitor AI agents and workflows. Used by 100,000+ builders. The licence is Apache-2.0.

Example prompts

  • “/react-query-best-practices”

Workflow steps

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

  1. https://tkdodo.eu/blog/practical-react-query — foundational defaults, custom hooks, avoiding local state copies
  2. https://tkdodo.eu/blog/effective-react-query-keys — key factory pattern, hierarchical keys, fuzzy invalidation
  3. https://tkdodo.eu/blog/react-query-as-a-state-manager — React Query IS your server state manager

What it can do on your machine

Read from SKILL.md and the folder at commit 546d4e7. 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

    Links to these hosts (documentation or services it may open):

    • tkdodo.eu

    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

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

Always · name and description, kept in context so the agent knows when to use it
~34
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 simstudioai/sim at commit 546d4e7, republished under its Apache-2.0 licence (© simstudioai). 580 words, ~1,183 tokens.

Download SKILL.mdSave it as .claude/skills/react-query-best-practices/SKILL.md (or your agent's skills folder).
name
react-query-best-practices
description
Audit React Query usage for best practices — key factories, staleTime, mutations, and server state ownership
argument-hint
[scope] [fix=true|false]

React Query Best Practices

Arguments:

  • scope: what to analyze (default: your current changes). Examples: "diff to main", "PR #123", "src/hooks/queries/", "whole codebase"
  • fix: whether to apply fixes (default: true). Set to false to only propose changes.

User arguments: $ARGUMENTS

Context

This codebase uses React Query (TanStack Query) as the single source of truth for all server state. All query hooks live in hooks/queries/. Zustand is used only for client-only UI state. Server data must never be duplicated into useState or Zustand outside of mutation callbacks that coordinate cross-store state.

References

Read these before analyzing:

  1. https://tkdodo.eu/blog/practical-react-query — foundational defaults, custom hooks, avoiding local state copies
  2. https://tkdodo.eu/blog/effective-react-query-keys — key factory pattern, hierarchical keys, fuzzy invalidation
  3. https://tkdodo.eu/blog/react-query-as-a-state-manager — React Query IS your server state manager

Rules to enforce

Query keys and hooks

Enforce .claude/rules/sim-queries.md (key factory with all + plural prefixes, signal forwarding, named staleTime constants reused by prefetches, keepPreviousData only on variable keys, requestJson boundary). Additionally:

  • Key factories live next to their hooks — except a factory, standalone fetcher/mapper, or staleTime constant that a server module (a prefetch.ts, route, block, trigger) imports, which must live in a non-'use client' module under hooks/queries/utils/ per .claude/rules/sim-queries.md (a 'use client' export called from the server crashes SSR)
  • Use enabled to prevent queries from running without required params
  • Warm data for hover/focus intent with prefetchQueryOnIntent(queryClient, sharedQueryOptions) (hooks/queries/utils/prefetch-query-on-intent.ts, which cleans up a speculative failure per sim-react-performance.md); never temporarily enable a mounted hidden observer, which can remain active after focus restoration and refetch data for closed UI
  • When gating a query by view or modal state, move every consumer to the active query too: imperative refresh/pagination, loading and error feedback, and data-derived controls must never read a disabled query or placeholder data from a previous key
  • Compose caller-controlled enabled options with required-param guards (Boolean(id) && (options?.enabled ?? true)). Never spread options after an internal guard, because { enabled: true } can silently re-enable an invalid request.
  • A disabled query can still report isPending: true. Aggregate loading state only for queries that are applicable/enabled, or an optional query can hold the whole surface in a permanent loading state.
  • Deferred authorization or policy queries must fail closed. Do not give pending/error data the same fallback as a successfully loaded unrestricted policy; disable guarded actions until the policy query succeeds.
  • Server prefetches must call the authorized use case, apply the route presenter/response schema, and reuse the client's exact key, mapper, and stale time. Keep all fallible auth/read/parse work inside queryFn so an optional warm cannot fail the page, and never bypass a route that redacts fields.
Show full SKILL.md (161 more words)Show less
Mutations

Enforce .claude/rules/sim-queries.md "Mutation Hook" (targeted invalidation, onMutate/onError rollback, mutation objects out of useCallback deps). Additionally:

  • Plain mutations invalidate in onSuccess; optimistic mutations reconcile in onSettled (fires on success and error) with rollback in onError — see .claude/rules/sim-queries.md "Mutation Hook" / "Optimistic Updates"
Server state ownership
  • Never copy query data into useState. Use query data directly in components.
  • Never copy query data into Zustand stores (exception: mutation callbacks that coordinate cross-store state like temp ID replacement)
  • The query cache is not a local state manager — setQueryData is for optimistic updates and the server-prefetch seeding case in .claude/rules/sim-queries.md "Server prefetching", nothing else
  • Forms are the one deliberate exception (a keyed form child initialized lazily from loaded query data) — the pattern is owned by /you-might-not-need-an-effect "Query-backed forms"; do not duplicate its finding

Steps

  1. Read the references above to understand the guidelines
  2. Analyze the specified scope against the rules listed above
  3. If fix=true, apply the fixes. If fix=false, propose the fixes without applying.

© simstudioai, Apache-2.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in .agents/skills/react-query-best-practices of simstudioai/sim.

Open the folder on GitHubat commit 546d4e7

Compare with similar skills

React 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.

React Query Best Practices compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
React Query Best Practices this skillsimstudioai/sim30k—~1.2kAutomated safety check: PassApache-2.0
Native Data FetchingCherryHQ/cherry-studio-app4k6 repos~2.9kAutomated safety check: NotesMIT
Game Changing FeaturesopenstatusHQ/data-table-filters2.3k3 repos~2.1kAutomated safety check: PassMIT
Frontend Query Mutationlangflow-ai/langflow156k—~979Automated safety check: PassMIT
React Frontend Development Guidelinesdiet103/claude-code-infrastructure-showcase10k2 repos~2.9kAutomated safety check: PassMIT
Wagmi Feature Developmentwevm/wagmi6.8k—~3.8kAutomated safety check: PassMIT

Similar skills

  • Native Data Fetching

    CherryHQ/cherry-studio-app

    A skill your agent uses when implementing or debugging ANY network request, API call, or data fetching.

    4k GitHub starsUsed in 6 repos~2.9k tokens
    DevelopmentAuto-check: notes
  • Game Changing Features

    openstatusHQ/data-table-filters

    Find 10x product opportunities and high-leverage improvements.

    2.3k GitHub starsUsed in 3 repos~2.1k tokens
    Product & Project ManagementAuto-check passed
  • Frontend Query Mutation

    langflow-ai/langflow

    Guide for implementing Langflow frontend query and mutation patterns with Axios and TanStack React Query v5.

    156k GitHub stars~979 tokensUpdated today
    Frontend & DesignAuto-check passed
  • React Frontend Development Guidelines

    diet103/claude-code-infrastructure-showcase

    Guidelines for React 18 and TypeScript apps covering Suspense data fetching, lazy loading, feature folders, MUI v7 styling, TanStack Router and performance.

    10k GitHub starsUsed in 2 repos~2.9k tokens
    Frontend & DesignAuto-check passed
  • Walks through adding a Wagmi feature across its layers: a Viem-based core action, TanStack Query options, and React and Vue bindings.

    6.8k GitHub stars~3.8k tokensUpdated 6 days ago
    DevelopmentAuto-check passed
  • React State Management

    involvex/youtube-music-cli

    Master modern React state management with Redux Toolkit, Zustand, Jotai, and React Query.

    456 GitHub starsUsed in 12 repos~3k tokens
    Frontend & DesignAuto-check passed

More from simstudioai/sim

All 40 skills in this repo
  • Sim Helm

    simstudioai/sim

    Install, upgrade, and operate the Sim Helm chart on Kubernetes.

    30k GitHub stars~2.2k tokensUpdated today
    Auto-check passed
  • Add Column Type

    simstudioai/sim

    Add a new table column type to Sim — registry entry, icon, storage shape, coercion, and the behavioral hooks the grid and API read.

    30k GitHub stars~2.9k tokensUpdated today
    Auto-check passed
  • Add Enrichment

    simstudioai/sim

    Add a code-defined table enrichment (registry entry) under apps/sim/enrichments/ backed by an ordered provider cascade, ensuring every provider tool it calls has hosted-key support.

    30k GitHub stars~2.2k tokensUpdated today
    Auto-check passed
  • Add Hosted Key

    simstudioai/sim

    Add hosted API key support to a tool so Sim provides the key (metered and billed to the workspace) when a user has not brought their own.

    30k GitHub stars~3.4k tokensUpdated today
    Auto-check passed
  • Add Managed CLI

    simstudioai/sim

    Add or upgrade a curated, immutable managed CLI for Sim Function sandboxes, including client-safe catalog metadata, a pinned server-only installation recipe, checksum and executable verification…

    30k GitHub stars~2.4k tokensUpdated today
    Auto-check passed
  • Add Selector

    simstudioai/sim

    Add or update a Sim dynamic selector using the shared manifest, server attachment, and selectors.execute path.

    30k GitHub stars~1.7k tokensUpdated today
    Auto-check passed

Works with

Questions about React Query Best Practices

What does React Query Best Practices do?

Audit React Query usage for best practices — key factories, staleTime, mutations, and server state ownership. React Query Best Practices is an agent skill from simstudioai/sim.

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

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

How do I install React Query Best Practices in Codex?

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

Can I use React 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 simstudioai/sim --skill react-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/react-query-best-practices, .gemini/skills/react-query-best-practices, .github/skills/react-query-best-practices and .opencode/skills/react-query-best-practices in your project.

What does React Query Best Practices need to run?

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

Does React Query Best Practices access the network?

SKILL.md names 1 domain. As links in the text: tkdodo.eu. This is read from the text; nothing was executed.

Is React 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 React Query Best Practices use?

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

How many tokens does React Query Best Practices use?

About 1.2k tokens (SKILL.md is roughly 4.7k 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 React Query Best Practices?

Skills that share tags, products or a category with React Query Best Practices: Native Data Fetching (CherryHQ/cherry-studio-app, 4k stars), Game Changing Features (openstatusHQ/data-table-filters, 2.3k stars), Frontend Query Mutation (langflow-ai/langflow, 156k stars) and React Frontend Development Guidelines (diet103/claude-code-infrastructure-showcase, 10k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains React Query Best Practices?

simstudioai (a GitHub organization) maintains it in simstudioai/sim, which has 29,785 GitHub stars. The repository holds 40 skills in this directory. The repository was last updated on October 7, 2026.

Source: simstudioai/sim on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.