tanstack-query

tanstack-query is a skill for Claude Code from rungchan2/frontend-skills. It costs 148 tokens per session (931 once invoked), scanned A, original, Apache-2.0.

A setup guide for TanStack Query, a React library for fetching and caching data from services. It defines shared cache settings, consistent query-key builders, a provider for the app, and development tools.

In plain words
What is it for?
Use it when starting a React project that needs server data, cached queries, query invalidation, and TanStack Query development tools.
Why use it?
It avoids each component choosing its own cache behaviour or using query keys that are difficult to update consistently. It also documents where the shared setup files go and how to connect the provider to the app.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin. Also seen: mentions CLAUDE.md.

Part of the project-packages plugin — 8 skills shipped together

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/rungchan2/frontend-skills/tanstack-query
Any agent
npx skills add rungchan2/frontend-skills --skill tanstack-query
Clone the repo
git clone --depth 1 https://github.com/rungchan2/frontend-skills

Made for: Claude Code.

Or install project-packages, the plugin that ships this one along with the rest of its 8 skills.

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

README.md
[![agentmods](https://agentmods.dev/badge/skills/rungchan2/frontend-skills/tanstack-query.svg)](https://agentmods.dev/skills/rungchan2/frontend-skills/tanstack-query)
Your own site
<a href="https://agentmods.dev/skills/rungchan2/frontend-skills/tanstack-query"><img src="https://agentmods.dev/badge/skills/rungchan2/frontend-skills/tanstack-query.svg" alt="Measured on agentmods" height="20"></a>
Per session 148 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 931 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.1 $0.00148 $0.00931
Opus 5 $0.00074 $0.00465
Sonnet 5 $0.00030 $0.00186
Haiku 4.5 $0.00015 $0.00093

Measured 5d ago against content hash 8b6b1ae3cfad, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, from the pricing page.

Security

Grade A, and why

tanstack-query 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 5d ago.

The scan reads SKILL.md. This mod also ships 2 executable files (assets/query-defaults.ts, assets/query-keys.ts), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

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/project-packages/skills/tanstack-query/SKILL.md · 94 lines

How it starts

The opening of the file, as written. The whole thing — 94 lines — stays where its author put it; the contents beside it link to each section on GitHub.

TanStack Query 표준 setup

새 프로젝트에 React Query 인프라 3개를 한 번에 깐다.

왜 이 3개를 묶는가

파일 역할
lib/query-defaults.ts staleTime/gcTime 같은 캐시 정책 — 컴포넌트마다 다르면 동작 예측 불가
lib/query-keys.ts 도메인별 queryKey 팩토리 — invalidate prefix 매칭 깨짐 방지
providers/query-provider.tsx QueryClient lifecycle 관리 + devtools — SSR 안전

이 셋이 합쳐져야 "캐시가 의도대로 동작하는" 환경이 된다.

워크플로우

1. 패키지 설치

pnpm add @tanstack/react-query
pnpm add -D @tanstack/react-query-devtools

2. 위치 결정

구조 파일들
src/ src/lib/query-defaults.ts, src/lib/query-keys.ts, src/providers/query-provider.tsx
루트 lib/query-defaults.ts, lib/query-keys.ts, providers/query-provider.tsx

3. 파일 생성

asset 대상 위치
query-defaults.ts lib/query-defaults.ts
query-keys.ts lib/query-keys.ts
query-provider.tsx providers/query-provider.tsx

4. 루트 layout에 Provider 적용

app/layout.tsx<QueryProvider> 래핑:

import { QueryProvider } from "@/providers/query-provider"

export default function RootLayout({ children }: { children: React.ReactNode }) {
  return (
    <html lang="ko">
      <body>
        <QueryProvider>{children}</QueryProvider>
      </body>
    </html>
  )
}

기존 layout이 있다면 안전하게 children만 감싸도록 편집한다.

5. queryKey 도메인 채우기 안내

assets/query-keys.tsusers 예시만 있고 posts는 주석. 사용자에게:

"주요 도메인이 뭔가요? (예: posts, comments, projects). 알려주시면 query-keys.ts에 미리 박아드립니다. 일단 지금은 users만 들어가 있어요."

도메인 받으면 같은 패턴으로 추가.

6. CLAUDE.md 사용 규칙 (선택)

## React Query 사용 규칙

- 모든 useQuery/useMutation은 `lib/query-keys.ts`의 키만 사용. 인라인 배열 금지.
  - 이유: invalidate 시 prefix 매칭 정합성 보장.
- staleTime/gcTime은 개별 훅에서 오버라이드하지 않는다. 짧은 캐시는 SHORT_CACHE_CONFIG, 실시간은 REALTIME_CONFIG 사용.
- 새 도메인이 생기면 query-keys.ts에 먼저 추가하고 훅 작성.

산출물

  • lib/query-defaults.ts, lib/query-keys.ts
  • providers/query-provider.tsx
  • app/layout.tsx에 Provider 적용
  • (선택) CLAUDE.md 사용 규칙

비-목표

  • 이 스킬은 개별 useQuery 훅을 만들지 않는다. 인프라만 깐다.
  • SWR과 병행 사용 권장하지 않음 — 클라이언트 캐싱 도구는 하나로 통일.

Read the full file on GitHub · 94 lines

Files

What ships with it

4 files 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. 5d ago First seen · 94 lines · 148 tokens per session scan A 8b6b1ae3cfad

Subscribe to this mod's changes

tanstack-query is a skill published in the GitHub repository rungchan2/frontend-skills (2 stars, last pushed 4mo ago), licensed Apache-2.0. It adds 148 tokens to every session and 931 once invoked, about $0.0007 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

v8-jit

V8 JIT optimization patterns for writing high-performance JavaScript in Next.js server internals. Use when writing or reviewing hot-path code in app-render, stream-utils, routing, caching, or any per-request code path. Covers hidden classes / shapes, monomorphic call sites, inline caches, megamorphic deopt, closure…

vercel/next.js · 88 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

git-safety

Git safety rules. INVOKE WHEN: git push, force push, git reset, git clean, destructive git, push force, reset hard. NEVER force push or do destructive git operations.

tamagui/tamagui · 0 tokens