Skip to content
Back to skills

Tanstack React Query Best Practices

ASecurity

TanStack Query conventions for cache-backed React server state. Use when creating or reviewing React queries, mutations, query keys, or cache updates.

  • 12 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added September 6, 2026
securityreactexpressgitdocumentation

Security analysis

A100/100

Pro scans all 16 files and shows the line behind each finding

Scanned September 6, 2026

npx -y skills add Casper-Studios/casper-marketplace --skill tanstack-react-query-best-practices --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Tanstack React Query Best Practices?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Tanstack React Query Best Practices
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/casper-studios-tanstack-react-query-best-practices/badge)](https://www.skillsdirectory.com/skills/casper-studios-tanstack-react-query-best-practices)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: tanstack-react-query-best-practices
description: TanStack Query conventions for cache-backed React server state. Use when creating or reviewing React queries, mutations, query keys, or cache updates.
license: MPL-2.0
metadata:
  author: 'Basti Ortiz <ortiz@bastidood.dev>'
  source: 'https://github.com/BastiDood/skills'
---

# TanStack React Query Best Practices

Treat server data as cache-backed asynchronous state with an explicit owner, identity, and view boundary; the outcome is reliable loading and error handling plus focused updates after writes.

## Library Sources

- GitHub repository ID: `TanStack/query`
- Context7 library ID: `/tanstack/query`
- DeepWiki repository ID: `TanStack/query`

Use Context7 for current documentation and DeepWiki for implementation details.

## References

Read the references that apply to the current task before writing or reviewing TanStack Query code.

1. Let TanStack Query own server-request lifecycle and cache identity.
   - [Let TanStack Query own request lifecycle](./references/request-ownership.md) rather than duplicating it with effects and local state.
   - [Put every response-changing request input in cache identity](./references/cache-identity.md) so distinct results never reuse one entry.
   - [Read request inputs exclusively from the query function's context argument](./references/query-function-inputs.md), never from captured request variables.
   - [Preserve absent identifiers and disable the request](./references/absent-identifiers.md) instead of fabricating a record key.
   - [Partition visibility-sensitive cached data by actor identity](./references/actor-identity-and-secrets.md) without exposing credentials in keys.
2. Resolve query status before presentation consumes data.
   - [Resolve query status at a Loader and Inner boundary](./references/loader-and-inner.md), keeping presentation free of optional data and transport state.
   - [Publish query identity through loader prop contracts](./references/loader-prop-contracts.md) while resolved components receive non-null data.
   - [Destructure only consumed query fields](./references/result-destructuring.md) so dependencies and props express semantic needs.
3. Keep mutation data, callbacks, and cache updates scoped to each operation.
   - [Consume named mutation result fields](./references/mutation-result-destructuring.md) because the complete `useMutation` result is not referentially stable.
   - [Pass changing operation input through mutation variables](./references/mutation-variables.md), not a mutation hook's construction closure.
   - [Parse user-controlled values before mutation invocation](./references/mutation-form-integration.md).
   - [Separate mutation callback lifecycles](./references/mutation-callback-lifecycle.md) by putting every-invocation policy in the definition and mounted UI consequences at the call site instead of aggregate-status effects.
   - [Invalidate the narrow stale entry identified by successful variables](./references/mutation-invalidation.md).

Files in this skill

  • LICENSE.txt16.3 KB
  • SKILL.md3 KB
  • agents/openai.yaml133 B
  • references/absent-identifiers.md1.6 KB
  • references/actor-identity-and-secrets.md1016 B
  • references/cache-identity.md1.7 KB
  • references/loader-and-inner.md1.8 KB
  • references/loader-prop-contracts.md1000 B
  • references/mutation-callback-lifecycle.md1.7 KB
  • references/mutation-form-integration.md1.2 KB
  • references/mutation-invalidation.md979 B
  • references/mutation-result-destructuring.md1.4 KB
  • references/mutation-variables.md916 B
  • references/query-function-inputs.md1.8 KB
  • references/request-ownership.md2 KB
  • references/result-destructuring.md1.3 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.