tanstack-query-patterns

tanstack-query-patterns is a skill for Claude Code, Codex from 2428424081cn/Skill-mcp. It costs 36 tokens per session (511 once invoked), scanned A, original, MIT.

A guide to TanStack Query v5, a React library for fetching, caching, and updating server data in web applications.

In plain words
What is it for?
Designing React data-fetching code, cache invalidation, optimistic changes, and SSR prefetching.
Why use it?
It provides patterns for consistent cache keys, optimistic updates, rollback after errors, and server-side rendering.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/2428424081cn/skill-mcp/tanstack-query-patterns
Any agent
npx skills add 2428424081cn/Skill-mcp --skill tanstack-query-patterns
Clone the repo
git clone --depth 1 https://github.com/2428424081cn/Skill-mcp

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for tanstack-query-patterns

README.md
[![agentmods](https://agentmods.dev/badge/skills/2428424081cn/skill-mcp/tanstack-query-patterns.svg)](https://agentmods.dev/skills/2428424081cn/skill-mcp/tanstack-query-patterns)
Your own site
<a href="https://agentmods.dev/skills/2428424081cn/skill-mcp/tanstack-query-patterns"><img src="https://agentmods.dev/badge/skills/2428424081cn/skill-mcp/tanstack-query-patterns.svg" alt="Measured on agentmods" height="20"></a>
Per session 36 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 511 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00036 $0.00511
Opus 5 $0.00018 $0.00255
Sonnet 5 $0.00007 $0.00102
Haiku 4.5 $0.00004 $0.00051

Measured 4d ago against content hash 78975aee8b15, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

tanstack-query-patterns scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 4d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/frontend/tanstack-query-patterns/SKILL.md · 52 lines

What it actually says

TanStack Query v5 (React Query) 最佳实践

1. 统一 Query Key Factory 模式

绝不在组件内随意手写散装数组作为 Query Key,必须通过统一工厂对象维护,确保类型安全与精准缓存失效:

export const userKeys = {
  all: ['users'] as const,
  lists: () => [...userKeys.all, 'list'] as const,
  list: (filters: UserFilters) => [...userKeys.lists(), { filters }] as const,
  details: () => [...userKeys.all, 'detail'] as const,
  detail: (id: string) => [...userKeys.details(), id] as const,
};

2. 乐观更新 (Optimistic Updates) 标准模式

在执行点赞、修改、删除等操作时,先立即更新本地 UI,若网络失败则自动回滚:

export function useUpdateTodo() {
  const queryClient = useQueryClient();

  return useMutation({
    mutationFn: updateTodoApi,
    onMutate: async (newTodo) => {
      // 1. 取消正在发起的并发请求,防止覆盖乐观状态
      await queryClient.cancelQueries({ queryKey: todoKeys.detail(newTodo.id) });
      // 2. 备份快照
      const previousTodo = queryClient.getQueryData<Todo>(todoKeys.detail(newTodo.id));
      // 3. 乐观写入新数据
      queryClient.setQueryData<Todo>(todoKeys.detail(newTodo.id), (old) => ({ ...old, ...newTodo }));
      return { previousTodo };
    },
    onError: (err, newTodo, context) => {
      // 4. 发生错误时回滚到快照
      if (context?.previousTodo) {
        queryClient.setQueryData(todoKeys.detail(newTodo.id), context.previousTodo);
      }
    },
    onSettled: (data, err, newTodo) => {
      // 5. 最终刷新服务端最新数据
      queryClient.invalidateQueries({ queryKey: todoKeys.detail(newTodo.id) });
    },
  });
}
Files

What ships with it

1 file beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 4d ago First seen · 52 lines · 36 tokens per session scan A 78975aee8b15

Subscribe to this mod's changes

tanstack-query-patterns is a skill published in the GitHub repository 2428424081cn/Skill-mcp (1 stars, last pushed 11d ago), licensed MIT. It adds 36 tokens to every session and 511 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

react-patterns

React 18/19 patterns including hooks discipline, server/client component boundaries, Suspense + error boundaries, form actions, data fetching, state management decision trees, and accessibility-first composition. Use when writing or reviewing React components.

affaan-m/ECC · 49 tokens

chakra-ui-builder

Build responsive, accessible UI components and layouts using Chakra UI v3, install or configure Chakra UI in new and existing projects, and design scalable themes using tokens, semantic tokens, recipes, and slot recipes. Use this skill whenever a user asks to build, create, or generate any UI component, page, form…

chakra-ui/chakra-ui · 214 tokens

material-ui-tailwind

Integrates Material UI with Tailwind CSS v4 using cascade layers (enableCssLayer, @layer order) and documents Tailwind v3 interoperability (preflight, important, injectFirst, portals). Use when combining MUI with Tailwind utilities, slotProps className, or theme token bridges.

mui/material-ui · 67 tokens

verify

Use when you want to validate changes before committing, or when you need to check all React contribution requirements.

react/react · 23 tokens

r3f-best-practices

React Three Fiber (R3F) and Poimandres ecosystem best practices. Use when writing, reviewing, or optimizing R3F code. Triggers on tasks involving @react-three/fiber, @react-three/drei, zustand, @react-three/postprocessing, @react-three/rapier, or leva.

zebbern/claude-code-guide · 74 tokens

assistant-ui-primitives

Guide for assistant-ui UI primitives - ThreadPrimitive, ComposerPrimitive, MessagePrimitive. Use when customizing chat UI components.

compozy/compozy · 28 tokens