From harness-claude
Inspects TanStack Query cache state, query status, and network activity using React Query DevTools panel. Debugs unexpected refetching, verifies cache data and mutations, tunes staleTime/gcTime.
npx claudepluginhub intense-visions/harness-engineering --plugin harness-claudeThis skill uses the workspace's default tool permissions.
> Inspect cache state, query status, and network activity using the React Query DevTools panel
Optimizes TanStack Query v5 performance with 40 rules across query keys, caching, mutations, prefetching, infinite queries, Suspense, errors, and rendering.
Implements TanStack Query v5 in React apps for API data fetching, server state caching, mutations, optimistic updates, infinite scroll, streaming AI responses, and tRPC v11 integration.
Provides expertise in TanStack Query for React/Next.js data fetching, caching (staleTime/gcTime), mutations, optimistic updates, cache invalidation, and App Router SSR hydration.
Share bugs, ideas, or general feedback.
Inspect cache state, query status, and network activity using the React Query DevTools panel
staleTime, gcTime, and observer counts for performance tuning@tanstack/react-query-devtools as a dev dependency — never ship it to production accidentally.<ReactQueryDevtools> inside your QueryClientProvider — it mounts a floating panel in the browser.initialIsOpen={false} (default) to keep the panel collapsed at startup — it opens on demand via the TanStack logo button.buttonPosition to move the toggle button away from UI elements: 'top-left', 'top-right', 'bottom-left', 'bottom-right'.fresh, stale, fetching, paused), staleTime, gcTime, observer count, and cached data.// app/providers.tsx — QueryClientProvider with DevTools
'use client';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import { ReactQueryDevtools } from '@tanstack/react-query-devtools';
import { useState } from 'react';
export function QueryProvider({ children }: { children: React.ReactNode }) {
const [queryClient] = useState(() => new QueryClient({
defaultOptions: {
queries: { staleTime: 60 * 1000 },
},
}));
return (
<QueryClientProvider client={queryClient}>
{children}
{/* DevTools only loads in development — tree-shaken in production */}
<ReactQueryDevtools initialIsOpen={false} buttonPosition="bottom-right" />
</QueryClientProvider>
);
}
// Alternative: dynamic import to guarantee no production bundle impact
import dynamic from 'next/dynamic';
const ReactQueryDevtools =
process.env.NODE_ENV === 'development'
? dynamic(() =>
import('@tanstack/react-query-devtools').then(mod => ({
default: mod.ReactQueryDevtools,
}))
)
: () => null;
The React Query DevTools panel has three main areas:
Query panel (left sidebar): Lists all cached queries with color-coded status indicators. Green = fresh, yellow = stale, gray = inactive, blue = fetching, red = error. The number in parentheses is the observer count — how many components are currently subscribed to that query.
Query details (right panel): Clicking a query shows its full key, current status, staleTime, gcTime, last updated timestamp, observer count, and the raw cached data in an expandable JSON tree. This is the primary tool for debugging key mismatches and stale data issues.
Actions: Each query entry has actions: Refetch (triggers an immediate background refetch), Invalidate (marks stale and refetches active), Reset (removes cached data), and Remove (evicts from cache). These allow debugging cache behavior without modifying code.
Status meanings:
fresh: data is within staleTime — will not refetch on mountstale: staleTime expired — will refetch on next mount or window focusfetching: active network request in progresspaused: query is paused (offline or network issue)inactive: no components are subscribed — GC timer is runningerror: last fetch failedObserver count: An observer count of 0 means no component is mounted that uses this query — the GC timer is running. Once it hits 0 and gcTime expires, the entry is removed. Multiple observers on the same query means multiple components share one cache entry.
Production safety: @tanstack/react-query-devtools is automatically excluded from production builds when using Next.js or Vite's tree-shaking if imported conditionally. The process.env.NODE_ENV === 'development' guard ensures zero bundle impact.
https://tanstack.com/query/latest/docs/framework/react/devtools