react-query-mutations
Installation
SKILL.md
react-query-mutations
Implements TanStack Query mutations correctly — focused on the optimistic update lifecycle, which is where almost all real mistakes happen.
Phase 1 — Discover
Before writing any mutation:
- Does this mutation need optimistic updates? (Instant UI feedback before API confirms.) If no, the implementation is trivial — skip to Phase 3B.
- What query key holds the data being mutated? (Needed for cancel, snapshot, and invalidation.)
- Is the cache entry a list (add/remove item) or a single record (update in place)? The optimistic update logic differs.
- Should the UI reflect only the mutation's loading state, or also per-item loading states? (The latter requires storing mutation variables in local state alongside the cache update.)