tanstack-query
Manage data fetching and caching in Svelte apps.
Install
mkdir -p .claude/skills/tanstack-query && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/1100" && unzip -o skill.zip -d .claude/skills/tanstack-query && rm skill.zipInstalls to .claude/skills/tanstack-query
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
Use this skill when fetching data, managing server state, or handling API mutations in the Svelte frontend. Covers createQuery, createMutation, query keys, cache invalidation, optimistic updates, and WebSocket-driven refetching. Apply when adding API calls, managing loading/error states, or coordinating cache updates after mutations.Key capabilities
- →Implement query keys for consistent cache management
- →Execute mutations with automatic cache invalidation
- →Perform optimistic UI updates for responsiveness
- →Sync state using WebSocket-driven invalidation
- →Manage dependent queries with enabled conditions
How it works
It centralizes API logic into feature-specific files, using query key factories to ensure cache consistency across queries and mutations.
Inputs & outputs
When to use tanstack-query
- →Setup query keys and cache invalidation
- →Implement optimistic UI updates
- →Manage WebSocket-driven data synchronization
About this skill
TanStack Query
Centralize API calls in each feature's api.svelte.ts, using @tanstack/svelte-query and @exceptionless/fetchclient.
Use the current organization and webhook implementations under src/Exceptionless.Web/ClientApp/src/lib/features/ as examples. Preserve their response/error types and signal handling.
- Share a feature's
queryKeysfactory across queries, mutations, and invalidation. - Name operations
get{Resource}Query,post{Resource}Mutation,patch{Resource}Mutation, anddelete{Resource}Mutation. - Gate queries on required authentication or identifiers.
- Pass the query cancellation signal through the fetch client.
- For optimistic updates, cancel competing queries, snapshot the cache, restore on failure, and reconcile with server state after completion.
- Wire WebSocket changes through the feature's invalidation helper. Match invalidation scope to the message identifiers.
Verify failure recovery and relevant cache interactions, not just the successful response.
Mutation and cache lifecycle
Keep reactive query options in the factory passed to createQuery or createMutation, following the current feature implementation. Include identifiers and relevant query parameters in its key factory so distinct results do not share a cache entry.
For an optimistic mutation, onMutate cancels affected in-flight queries and saves the previous value before updating the cache. onError uses that context to roll back; completion reconciles affected queries with server state, commonly through onSettled. Preserve unrelated cache entries and consider overlapping mutations before restoring an older snapshot.
Await invalidation or refetching when the calling UI depends on it before closing or navigating. Match the existing feature's FetchClientResponse and ProblemDetails handling instead of assuming every request throws or every mutation returns an unwrapped model.
WebSocket invalidation must use the same key factories as queries. Inspect both the feature helper and its caller when changing message handling; verify identifier-specific and collection updates.
When not to use it
- →When simple fetch calls are sufficient
- →When state is purely local and non-server-driven
Prerequisites
Limitations
- →Requires consistent use of query key factories
How it compares
It provides a structured, type-safe way to handle server state and cache synchronization compared to manual fetch management.
Compared to similar skills
tanstack-query side by side with the closest alternatives in the catalog.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| tanstack-query (this skill) | 7 | 3mo | No flags | Intermediate |
| svelte-migrate | 2 | 8mo | No flags | Intermediate |
| shopify-development | 12 | 8mo | Review | Intermediate |
| nuxt | 19 | 8mo | No flags | Intermediate |
Try saying
Example prompts that trigger this skill in your AI assistant.
More by exceptionless
View all by exceptionless →You might also like
svelte-migrate
temporalio
Migrate a Svelte 4 component to Svelte 5 runes syntax. Use when asked to migrate, convert, or upgrade a .svelte file to Svelte 5.
shopify-development
davila7
Build Shopify apps, extensions, themes using GraphQL Admin API, Shopify CLI, Polaris UI, and Liquid. TRIGGER: "shopify", "shopify app", "checkout extension", "admin extension", "POS extension", "shopify theme", "liquid template", "polaris", "shopify graphql", "shopify webhook", "shopify billing", "app subscription", "metafields", "shopify functions"
nuxt
antfu
Nuxt full-stack Vue framework with SSR, auto-imports, and file-based routing. Use when working with Nuxt apps, server routes, useFetch, middleware, or hybrid rendering.
telegram-dev
2025Emma
Telegram 生态开发全栈指南 - 涵盖 Bot API、Mini Apps (Web Apps)、MTProto 客户端开发。包括消息处理、支付、内联模式、Webhook、认证、存储、传感器 API 等完整开发资源。
yjs
EpicenterHQ
Yjs CRDT patterns, shared types, conflict resolution, and meta data structures. Use when building collaborative apps with Yjs, handling Y.Map/Y.Array/Y.Text, implementing drag-and-drop reordering, or optimizing document storage.
bun-development
davila7
Modern JavaScript/TypeScript development with Bun runtime. Covers package management, bundling, testing, and migration from Node.js. Use when working with Bun, optimizing JS/TS development speed, or migrating from Node.js to Bun.