agentleFS
kriscardkriscard/Skills/skills/dev/tanstack-query/SKILL.md

tanstack-query

Skill15 starsChanged 15 days agoMITView on GitHub

Implement, debug, or review modern TanStack Query code using the installed @tanstack query package and adapter. Use for query keys/options, cache freshness, invalidation, cancellation, retries, network modes, mutations and optimism, offline persistence, infinite queries, tracked properties, selectors, adapter-specific APIs, SSR/hydration, or Router/Start integration. Inspect the resolved adapter, core, framework peers, and declarations before choosing syntax. Compose with react only for React-owned work and test when evidence is requested or affected. Do not use for general client state or generic fetch/MSW work without Query behavior.

19 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use tanstack-router, tanstack-form and 2 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • Aver005Skill

    tanstack-router

    Build type-safe, file-based React routing with TanStack Router. Supports client-side navigation, route loaders, and TanStack Query integration. Prevents 20 documented errors including validation structure loss, param parsing bugs, and SSR streaming crashes.

    Also in 10 projects that use this

  • heryTzSkill

    tanstack-form

    Create or modify forms using TanStack Form's composition API. Uses formOptions() as the form shape primitive, withForm HOC for decomposing large forms into sections, withFieldGroup for reusable field groups across forms, Zod for validation, and i18n-prefixed error messages. Use when creating or modifying forms in the web app.

    Also in 3 projects that use this

  • JasonPaffSkill

    tanstack-table

    Build headless data tables with TanStack Table v8. Server-side pagination, filtering, sorting, and virtualization for Cloudflare Workers + D1. Prevents 12 documented errors.

    Also in 3 projects that use this

  • SentrySkill

    review

    Fixture review skill.

    Also in 3 projects that use this

The file

We split this skill into the rules it gives an agent

9 rules. 0 are common, 7 are distinctive, and 2 are very specific to this project.

  • 0

    Common

    Most of the 18 edited versions we read keep these.

  • 7

    Distinctive

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Treat Query as a synchronization layer for remotely owned asynchronous state.

    line 17
  2. Distinctive:

    Use Query for server-owned snapshots that can become stale.

    line 33
  3. Distinctive:

    Use existing runtime validation in the transport/API layer before data enters the cache.

    line 69
  4. Distinctive:

    Run the narrowest typecheck, lint, and tests that cover the changed behavior, then repository checks.

    line 78
  5. Very specific:

    Freshness: use a known resource policy.

    line 92
  6. Very specific:

    Use gcTime only for inactive retention.

    line 93
  7. Distinctive:

    Reconciliation: update from an authoritative response or invalidate the resources made stale.

    line 94
  8. Distinctive:

    Optimism: prefer a local pending preview.

    line 96
  9. Distinctive:

    Observation: use tracked properties and structural sharing first.

    line 100

“Common” is measured: kept by at least 6 in 10 of the 18 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

TanStack Query

Treat Query as a synchronization layer for remotely owned asynchronous state. Model the resource, its cache identity, and how truth is restored before choosing a hook or client method.

Workflow

1. Detect the installed boundary

Inspect manifests, lockfiles, imports, configuration, and resolved declarations. Record the adapter, its exact version, the separately resolved @tanstack/query-core, framework peer version, and any router, SSR, hydration, persistence, devtools, or lint integration. Current documentation describes current releases; installed exports and types decide which capabilities this project can use.

Complete when: the adapter/core/peer boundary and nearby project conventions are known.

2. Name the state owner

Use Query for server-owned snapshots that can become stale. Keep ephemeral UI state, URL state, forms, and editable drafts with their existing owners. Derive UI validity from query data where possible; preserve a local draft when the user intentionally edits a snapshot.

Complete when: each changed value has one owner and Query has a reason to participate.

3. Define the resource contract

For every read, identify the resource, every result-changing input, canonical cached shape, cancellation path, error boundary, and known freshness requirement. When freshness is unspecified, preserve existing/project defaults and report the policy gap instead of inventing a duration. For every write, identify affected resources, authoritative response data, completion boundary, list membership/order effects, and concurrency behavior. Keep transport, runtime validation, domain transformation, Query policy, and UI projection as explicit seams.

Complete when: cache identity and the path back to server truth are unambiguous, while unknown policy is preserved and named for its owner.

4. Load the applicable reference

PriorityLoad whenReference
1 — HighKeys/options, reusable definitions, freshness, retries, network modes, invalidation, disabled/dependent reads, cancellation, transformations, Suspense queriesreferences/queries-and-cache.md
1 — HighMutations, callback/promise ownership, invalidation timing, optimistic UI/cache writes, overlapping writes, scopes, paused/offline persistencereferences/mutations-and-optimism.md
1 — HighInfinite queries, pagination cursors, tracked properties, select, structural sharing, non-React adaptersreferences/infinite-rendering-and-adapters.md
1 — HighSSR, hydration, pending dehydration, RSC/cache layers, Router or Start integrationreferences/ssr-hydration-and-frameworks.md
2 — HighBroken behavior, capability uncertainty, cache/performance review, or adapter/version mismatchreferences/debugging-and-review.md
2 — MediumTests or executable evidence requested or affectedreferences/testing.md

Complete when: each relevant branch is loaded and its examples match installed declarations.

5. Compose at owner seams

  • Load react for component ownership, Effects, Suspense/error boundaries, transitions, Context, and rendering behavior. Keep the Query-facing seam here even when React owns the surrounding mechanic.
  • Load test when tests or executable evidence are requested or affected; use the installed runner.
  • Use existing runtime validation in the transport/API layer before data enters the cache. Schema selection belongs to that owner; Query should receive typed data or a thrown failure.
  • Let Router/Start/Next own route and server mechanics while Query owns its client, observers, keys, freshness, and cache reconciliation.

Complete when: each concern has one owner and the handoff between owners is visible in code.

6. Verify transitions

Run the narrowest typecheck, lint, and tests that cover the changed behavior, then repository checks. Assert outcomes: equal identities share work, changed inputs select another cache entry, cancellation reaches transport, writes restore the intended truth, optimistic overlap does not flash stale data, and hydration/integration uses the intended client and observer.

Report detected versions, cache identities, freshness/invalidation decisions, owner handoffs, checks, and remaining gaps.

Complete when: installed-version syntax passes and each changed transition has evidence.

Guardrails

  1. Identity: keys include every result-changing input; normal and infinite data use distinct keys.
  2. Repeatability: queryFn returns or throws repeatably; event effects stay with event/mutation owners.
  3. Freshness: use a known resource policy; otherwise preserve defaults and report the unknown. Use gcTime only for inactive retention.
  4. Reconciliation: update from an authoritative response or invalidate the resources made stale.
  5. Cancellation: pass AbortSignal to transport and cancel conflicting reads before cache optimism.
  6. Optimism: prefer a local pending preview; use cache optimism when multiple observers need it and provide overlap-safe rollback/reconciliation.
  7. Composition: share queryOptions when loaders, hooks, or imperative callers need one identity; keep consumer overrides at the callsite and add hooks only when they own behavior.
  8. Observation: use tracked properties and structural sharing first; select a narrower result when that subscription or transformation is valuable.
  9. Adapters: transfer core semantics, then verify the adapter's exports, reactive inputs, provider, return shape, peer range, and experimental status.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.