agentleFS
jgamaraalvjgamaraalv/delivery-loop/.claude/skills/react-query/SKILL.md

react-query

Skill0 starsChanged 4 months agoMITView on GitHub

Guidelines for using React Query for data fetching, caching, and server state synchronization in React applications

2 other projects use a version of this, 1 of them edited.

Adopted by

Most recently taken up by

The file

Show its rules and text

We split this skill into the rules it gives an agent

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

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈10

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 4

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use React Query for all data fetching and caching

    line 8
  2. Very specific:

    Use React Context and useReducer for managing client-side global state

    line 10
  3. Distinctive:

    Avoid excessive API calls through proper caching strategies

    line 11
  4. Distinctive:

    Always handle loading states and errors properly

    line 12
  5. Distinctive:

    Use React Query DevTools to inspect cache and track query status

    line 38
  6. Distinctive:

    Always handle errors properly with user-friendly messages and retry options

    line 40
  7. Distinctive:

    Avoid deeply nesting queries - flatten when possible for better performance

    line 42
  8. Distinctive:

    Use local state for component-specific data, global state for shared data

    line 43
  9. Very specific:

    Do not use useEffect for data fetching

    line 48
  10. Very specific:

    Do not store server data in useState

    line 49
  11. Distinctive:

    Do not forget loading and error state handling

    line 50
  12. Distinctive:

    Do not create queries without proper cache invalidation strategies

    line 51
  13. Very specific:

    Do not skip the enabled option for conditional queries

    line 52
  14. Distinctive:

    Do not ignore TypeScript types for query responses

    line 53

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “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

Core Principles

  • Use React Query for all data fetching and caching
  • Leverage React Query's built-in state management instead of useState for server data
  • Use React Context and useReducer for managing client-side global state
  • Avoid excessive API calls through proper caching strategies
  • Always handle loading states and errors properly

Topics by Concern

ConcernReference
Client setup & file layoutreferences/setup.md
Reading datareferences/queries.md
Writing datareferences/mutations.md
Server vs. client statereferences/state-management.md
Caching speed & re-rendersreferences/performance.md
Failure handling & recoveryreferences/error-handling.md

References

Each file is loaded on demand — read one only when the task needs that depth (progressive disclosure).

  • references/setup.md — feature-based project structure plus the one-time QueryClient/QueryClientProvider configuration (staleTime, cacheTime, retry, DevTools) · read when scaffolding React Query in a project or tuning client defaults.
  • references/queries.md — query hooks: basic typed query, service-thrown user-friendly errors, dependent (enabled) queries, paginated (keepPreviousData) queries, and useInfiniteQuery · read when fetching/reading any server data.
  • references/mutations.md — mutation hooks: basic mutation with cache invalidation, and the four-callback optimistic-update pattern (onMutate/onError/onSettled) · read when creating, updating, or deleting server data.
  • references/state-management.md — the server-state vs. client-state split, integrating React Query alongside Context/Reducer or Zustand · read when deciding where a piece of state lives or wiring React Query into existing global state.
  • references/performance.md — structured query-key factories, select for selective subscriptions, and prefetching on user intent · read when invalidation is imprecise, components re-render too often, or navigation feels slow.
  • references/error-handling.md — global QueryClient onError defaults and QueryErrorResetBoundary + error boundaries with retry · read when standardizing error behavior or adding render-time error recovery.

Key Conventions

  1. Use React Query DevTools to inspect cache and track query status
  2. Group react-query hooks within feature-specific directories (feature-based organization)
  3. Always handle errors properly with user-friendly messages and retry options
  4. Fetch only required data - use API parameters to reduce data transfer
  5. Avoid deeply nesting queries - flatten when possible for better performance
  6. Use local state for component-specific data, global state for shared data
  7. Leverage React Query's built-in caching and state management capabilities

Anti-Patterns to Avoid

  • Do not use useEffect for data fetching
  • Do not store server data in useState
  • Do not forget loading and error state handling
  • Do not create queries without proper cache invalidation strategies
  • Do not skip the enabled option for conditional queries
  • Do not ignore TypeScript types for query responses

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.