TA

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.zip

Installs 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.
335 chars✓ has a “when” triggerlonger than Claude Code's old 250-char listing cap (fine on current versions)
Intermediate

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

You give it
API endpoint and data requirements
You get back
Cached, reactive server state

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 queryKeys factory across queries, mutations, and invalidation.
  • Name operations get{Resource}Query, post{Resource}Mutation, patch{Resource}Mutation, and delete{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

TanStack QuerySvelte

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.

SkillInstallsUpdatedSafetyDifficulty
tanstack-query (this skill)73moNo flagsIntermediate
svelte-migrate28moNo flagsIntermediate
shopify-development128moReviewIntermediate
nuxt198moNo flagsIntermediate

Try saying

Example prompts that trigger this skill in your AI assistant.

Search skills

Search the agent skills registry