agentleFS
shreyam1008shreyam1008/shre-skills/skills/tanstack/SKILL.md

tanstack

Skill0 starsChanged 48 days agoMITView on GitHub

Uses TanStack Query, Router, Table, Form, Virtual, or Start in an existing or explicitly selected TanStack project. Use for its query keys, mutations, loaders, URL state, and library APIs; do not introduce the stack for generic React work.

We split this skill into the rules it gives an agent

10 rules. 0 are common, 4 are distinctive, and 6 are very specific to this project.

  • 0

    Common

    Most of the 5 edited versions we read keep these.

  • 4

    Distinctive

    This author's own choices. Worth a look.

  • 6

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use the selected TanStack libraries for their specific data and routing contracts.

    line 9
  2. Distinctive:

    Prefer Query or Router for shared server data.

    line 17
  3. Very specific:

    Use stable, structured query keys (['todos', { status }]).

    line 22
  4. Very specific:

    Import queryOptions and useQuery from @tanstack/react-query.

    line 35
  5. Very specific:

    Treat search params as state — Router validates/serializes them (great for filters, pagination, tabs).

    line 67
  6. Distinctive:

    Use Start when you need SSR/streaming, server functions, and shared Query hydration between server and client.

    line 72
  7. Very specific:

    Virtual: use useVirtualizer when measured list or table rendering costs justify windowing.

    line 79
  8. Very specific:

    Do: server data in Query, URL state in Router search params, UI state in useState.

    line 84
  9. Distinctive:

    Avoid redundant copies of shared server data.

    line 85
  10. Very specific:

    Don't omit data dependencies from query keys.

    line 86

“Common” is measured: kept by at least 6 in 10 of the 5 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

Use the selected TanStack libraries for their specific data and routing contracts. Avoid maintaining an accidental second copy of shared server state in component state.

Apply the libraries already chosen by the project. This skill does not require migrating a working framework loader or adding the entire TanStack stack. Form drafts may intentionally start from server data and diverge while the user edits.

The core mental model

  • Server state ≠ client state. Data owned by the server (lives in a DB, can change, is shared) belongs in TanStack Query, not useState.
  • Reserve useState/useReducer for true UI state (open/closed, input draft, selection).
  • Prefer Query or Router for shared server data. Preserve justified effect-based integrations with appropriate race handling and cleanup.

TanStack Query (server state)

  • useQuery for reads; it handles caching, dedup, background refetch, loading/error states.
  • Use stable, structured query keys (['todos', { status }]). Keys are the cache identity.
  • Set staleTime intentionally — how long data is "fresh" before background refetch. Default 0 refetches often; raise it for stable data.
  • Co-locate query options in a factory so keys/fns stay consistent and reusable across components and route loaders.
const todosQuery = (status: string) => queryOptions({
  queryKey: ['todos', { status }],
  queryFn: ({ signal }) => fetchTodos(status, signal), // pass signal for cancellation
  staleTime: 60_000,
});
useQuery(todosQuery(status));

Import queryOptions and useQuery from @tanstack/react-query; queryOptions preserves inference for the query function context. Include every data-changing parameter in the key. Inline arrays and query functions are supported: keys are hashed by value, not object identity.

Mutations + optimistic updates

  • useMutation for writes. After success, invalidate affected queries to refetch truth.
  • Optimistic update via onMutate: cancel in-flight queries, snapshot, write the optimistic value; roll back in onError using the snapshot; reconcile in onSettled by invalidating.
const key = todosQuery(status).queryKey; // the same filtered list used by useQuery
useMutation({
  mutationFn: updateTodo,
  onMutate: async (next) => {
    await qc.cancelQueries({ queryKey: key, exact: true });
    const prev = qc.getQueryData(key);
    qc.setQueryData(key, (old) => old === undefined ? old : applyOptimistic(old, next));
    return { prev };
  },
  onError: (_e, _next, ctx) => {
    if (ctx?.prev !== undefined) qc.setQueryData(key, ctx.prev);
  },
  onSettled: () => qc.invalidateQueries({ queryKey: ['todos'] }),     // reconcile
});

This snapshot pattern assumes mutations to that list are serialized and the key remains fixed for the mutation's lifetime. Concurrent writes need mutation-aware reconciliation or optimistic UI derived from pending variables; restoring an old snapshot can erase a newer update. Make applyOptimistic respect the list's filter and leave uncached lists to refetch.

  • Prefetch on intent (hover/route enter) with queryClient.prefetchQuery to kill waterfalls.
  • React 19 note: useOptimistic + Actions give transient optimistic UI for a single form/mutation; Query's onMutate updates the shared cache so every component reading that key reflects it. Use Query's approach when the optimistic value must persist across components/navigation.

TanStack Router (routing + data)

  • File/code-based routes are fully type-safe: typed params, search params, and links.
  • Treat search params as state — Router validates/serializes them (great for filters, pagination, tabs). Don't duplicate them in useState.
  • Load data in route loaders and integrate with Query (ensureQueryData) so navigation prefetches and avoids component-mount waterfalls.

TanStack Start (SSR/full-stack)

  • Use Start when you need SSR/streaming, server functions, and shared Query hydration between server and client.
  • Prefetch in loaders on the server, dehydrate, and hydrate on the client so the first paint has data and no refetch flash.
  • For pure SPA (no SSR needs), Router + Query alone is enough.

TanStack Table / Form / Virtual

  • Table: headless — you own markup/styling; it manages sorting/filtering/pagination/grouping. Keep columns referentially stable (define outside render or useMemo).
  • Virtual: use useVirtualizer when measured list or table rendering costs justify windowing. Preserve keyboard focus and accessible navigation.
  • Form: type-safe, headless form state + validation (pairs with a schema lib). Avoids re-rendering the whole form on each keystroke.

Do / Don't

  • Do: server data in Query, URL state in Router search params, UI state in useState.
  • Avoid redundant copies of shared server data; form drafts and external integrations may intentionally diverge from the cache.
  • Don't omit data dependencies from query keys. Keep Table columns and data stable where required; Query queryFn does not need memoization solely to prevent refetches.

Reference

  • TanStack docs: Query keys, Query options, Query mutations, Router, Start, Table, Form, Virtual.
  • TkDodo's blog "Practical React Query" (the canonical Query best-practices series).

Download now (ZIP)

  • Other versions5 projects use a version of this.

    Word for word · 0

    None found.

    Edited · 0

    None found.

    Wrote their own version · 5

    1. compozy/compozy★ 2.8ksame name
    2. pedronauck/skills★ 641same name
    3. tenequm/skills★ 40same name
    4. FelipeAngeli/skills★ 2same name
    5. barisariburnu/skills-collection★ 1same name

    How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.

  • Used alongsideProjects with it also use app-renderer-systems, refactoring-analysis and 6 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.
    • pedronauckSkill

      app-renderer-systems

      Create, extend, or debug frontend domain modules organized under systems/. Covers adapters, Query hooks, local state, and public exports; excludes generic components and backend implementation.

      Also in 3 projects that use this

    • pedronauckSkill

      refactoring-analysis

      Audit code quality and architectural health or plan refactoring using Fowler code smells and techniques; write prioritized findings to docs/_refacs/. Excludes formatting, performance, and security audits.

      Also in 3 projects that use this

    • jander99Skill

      typescript-advanced

      Design, implement, refactor, and debug advanced TypeScript patterns including generics, utility types, mapped types, conditional types, type guards, discriminated unions, and strict mode configuration. Use when writing type-safe code, fixing type errors, or improving type inference.

      Also in 3 projects that use this

    • crafter-stationSkill

      tech-logos

      Install official tech brand logos from the Elements registry. Use when user needs logos for tech companies (Clerk, Vercel, GitHub, etc.), AI providers (OpenAI, Anthropic, Claude), social platforms, or any brand assets. Triggers on "logo", "brand", "icon for [company]", "add [company] logo", placeholder logo detection, or when building landing pages, auth UIs, or integrations showcases.

      Also in 3 projects that use this

    • azlekovSkill

      tailwindcss

      This skill should be used when the user asks to "style with Tailwind", "add CSS", "configure theme", "use @theme", "add custom colors", "implement dark mode", "use container queries", "add responsive design", "use OKLCH colors", or discusses styling, theming, or visual design. Always use the latest Tailwind CSS version and modern patterns.

      Also in 3 projects that use this

    • Kastalien-ResearchSkill

      effect-ts

      Comprehensive guide for Effect-TS, the functional TypeScript library. Use when building Effect applications, especially MCP servers. Covers correct APIs, common misconceptions, and MCP-specific patterns.

      Also in 3 projects that use this

  • In this repository21 other files it gives its agents.

Does it work?

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

Reviews can't be read right now.

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.