技能 pitfalls-tanstack-query

pitfalls-tanstack-query

安全 🌐 網路存取📁 檔案系統存取⚙️ 外部命令

Debug TanStack Query Issues

TanStack Query v5 introduces breaking changes and subtle caching behaviors that cause bugs. This skill provides proven patterns and anti-patterns for correct data fetching, mutations, and cache invalidation.

支援: Claude Code(CC)
📊 71 充足
1

下載技能 ZIP

2

在 Claude 中上傳

前往 設定 → 功能 → 技能 → 上傳技能

3

開啟並開始使用

測試它

正在使用「pitfalls-tanstack-query」。 Review my useQuery implementation for TanStack Query v5

預期結果:

  • QueryKey uses full URL path for proper deduplication
  • queryFn correctly fetches from matching endpoint
  • StaleTime configured appropriately for your use case
  • Consider adding refetchOnWindowFocus if needed for live data

正在使用「pitfalls-tanstack-query」。 Why is my data stale after mutations?

預期結果:

  • Missing queryClient.invalidateQueries in onSuccess handler
  • Add onSuccess callback to invalidate relevant queries
  • Verify queryKey matches exactly between fetch and invalidation

安全審計

安全
v5 • 1/16/2026

This is a documentation-only skill containing markdown and TypeScript code examples. All 16 static findings are false positives: TypeScript template literals were misidentified as shell commands, API patterns were misidentified as cryptographic code, and metadata fields were misidentified as network/filesystem access. No executable code, network calls, or file system operations exist.

2
已掃描檔案
276
分析行數
3
發現項
5
審計總數
審計者: claude 查看審計歷史 →

品質評分

38
架構
100
可維護性
85
內容
30
社群
100
安全
91
規範符合性

你能建構什麼

Debug Data Fetching

Fix data fetching bugs in React components using TanStack Query

Review Code Quality

Review pull requests that use TanStack Query for common mistakes

Migrate to v5

Identify v4 patterns that need updating to v5

試試這些提示

Basic Review
Review this useQuery implementation for correct TanStack Query v5 patterns. Check queryKey structure, queryFn, and options:
Mutation Check
Check this useMutation for proper cache invalidation. Does it invalidate the correct queries on success?
Optimistic Update
Show me the correct pattern for optimistic updates with rollback in TanStack Query v5. Include onMutate, onError, and onSettled handlers.
Migration Guide
Identify all v4 patterns in this code that need updating to v5. Specifically look for isLoading that should be isPending.

最佳實務

  • Use full URL paths in queryKeys like ['/api/strategies', id] for proper deduplication
  • Always invalidate relevant queries in onSuccess of useMutation to keep cache fresh
  • Use isPending instead of isLoading for mutation state checks in v5

避免

  • Short queryKeys like ['strategy'] that prevent proper deduplication across components
  • Forgetting to call queryClient.invalidateQueries after mutations causing stale data
  • Using isLoading instead of isPending for mutation state checks in v5

常見問題

What TanStack Query versions are supported?
This skill focuses on TanStack Query v5. Some v4 patterns are covered for migration guidance.
What are the limits of this skill?
It provides pattern guidance and code review but does not execute or modify your actual codebase.
Does this skill integrate with other tools?
It works with any React project using TanStack Query. No additional setup required.
Is my data safe?
Yes. This is a prompt-based skill that never accesses your files or makes network calls.
Why is my data stale after mutations?
Likely missing queryClient.invalidateQueries in onSuccess. The skill can identify and fix this pattern.
How does this compare to React Query v4?
v5 renamed isLoading to isPending and changed some default behaviors. This skill identifies v4 patterns needing updates.

開發者詳情

檔案結構

📄 SKILL.md