agentsclimarketplace

Tanstack query architecture

Skill meyverick/agy-skills/skills/tanstack-query-architecture

Architects robust server state management using TanStack Query. Use when configuring caching TTLs, optimistic updates, and SSR hydration.From its SKILL.md

Install
npx -y skills add meyverick/agy-skills --skill tanstack-query-architecture

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

SKILL.md

2.5 KB, 548 tokens by cl100k_base, as published. Nobody here has run it

TanStack Query Architecture

This skill manages server state using TanStack Query (React Query / Svelte Query). It ensures aggressive caching, prevents unnecessary network spam, and governs strict optimistic UI updates.

When to Use

  • Use when fetching, caching, synchronizing, or updating server state in frontend frameworks.
  • Use when implementing infinite scrolling or paginated data fetching.
  • NOT for global client state (like a dark mode toggle); use standard Context/Stores for that.

Core Process

Phase 1: Query Keys & Caching

  • Treat Query Keys strictly as dependency arrays. If the query function relies on a variable (e.g., userId), that variable MUST be in the query key array ['user', userId].
  • Define explicit staleTime and gcTime. The default staleTime is 0, which means every re-render causes a background fetch. Configure this to a sensible default (e.g., 1000 * 60 * 5 for 5 minutes).

Phase 2: Optimistic Updates

  • When mutating data, update the UI immediately before the server responds to create a fast UX.
  • In the onMutate callback, cancel outgoing queries for that key, snapshot the previous value, and manually set the query data using queryClient.setQueryData.
  • In onError, rollback the cache to the snapshot.

Phase 3: SSR Hydration

  • When using Next.js or SvelteKit, fetch data on the server during SSR and use HydrationBoundary or dehydrate() to pass the cache to the client to prevent a loading spinner on the initial paint.

Common Rationalizations

RationalizationReality
"I'll use a useEffect to fetch data and store it in React State."useEffect for data fetching causes race conditions, lack of caching, and duplicate requests. TanStack Query replaces it entirely.
"I don't need optimistic updates, the API is fast."Network latency is unpredictable. Optimistic updates are mandatory for a premium, snappy UX.

Red Flags

  • Utilizing useEffect or Svelte $effect to perform raw fetch calls.
  • Missing staleTime configuration on QueryClient, causing massive API spam.

Verification

Before finalizing the query architecture:

  • All API fetches occur exclusively through useQuery or createQuery.
  • Mutations implement optimistic cache updates and rollback mechanisms.
  • Query keys correctly reflect all variables used inside the fetch function.

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Gives 0 of the 12 instructions most architecture codebase skills give in 548 tokens

Counted across 811 of the 1,134 authors here whose files we hold, read 2026-08-07

  • Ask the user which candidate to explorein 45 of 811, across 15 files
  • Apply the deletion test to suspected shallow modulesin 43 of 811, across 15 files
  • Read any relevant architecture decision records firstin 31 of 811, across 8 files
  • Use exact glossary terms in every suggestionin 30 of 811, across 10 files
  • Accept dependencies instead of creating themin 24 of 811, across 5 files
  • Include before and after visualisations for each candidatein 24 of 811, across 5 files
  • Read the domain glossary before exploringin 24 of 811, across 6 files
  • Return results instead of producing side effectsin 23 of 811, across 4 files
  • Explore the codebase for shallow modules and frictionin 23 of 811, across 3 files
  • Introduce seams only where things varyin 22 of 811, across 3 files
  • Reduce the number of methodsin 21 of 811, across 2 files
  • Design deep modules with small interfacesin 21 of 811, across 3 files

Said here and by no other author read

  • include all fetch variables in query keys
  • define explicit staleTime and gcTime
  • cancel outgoing queries in onMutate
  • snapshot previous cache value in onMutate
  • manually set query data in onMutate
  • rollback cache to snapshot in onError

Grouped from the skills themselves: near-identical wordings counted once, and counted by distinct author, so one author publishing three of these counts once. Length counted with cl100k_base; the agent that loads this file may tokenize it differently.

Keep looking

Skills are one crate of 326,645. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.