Agent skill · Audited from source
Tanstack Query Expert
skill · davila7/claude-code-templatesMIT licenceAudited 2 Oct 2026 · source aa855ad1e58d
Is it safe? Yes — SAFE, grade B (89/100). We read this skill's source at commit aa855ad1e58d and found no filesystem, network or shell access and no hard-coded secrets. What it does: Expert in TanStack Query (React Query) — asynchronous state management. Covers data fetching, stale time configuration, mutations, optimistic updates, and Next.js App Router (SSR) integration.
Cite
Cite this page
ModelsAtlas. “Tanstack Query Expert (davila7/claude-code-templates)”. Retrieved 2 Oct 2026. https://modelsatlas.com/skills/davila7/tanstack-query-expert
Trust audit
Audit 0.4.1 · source read 2 Oct 2026
SAFE means nothing in the source contradicts what the skill says it does. Grade B is shared by 17,406 of 18,389 audited skills.
What the source does
- FilesystemNone observedNo reads or writes in the source
- NetworkNone observedNo outbound calls in the source
- ShellNone observedNo commands run in the source
- DependenciesPinnedNothing floats
- SecretsNone foundNo keys in source
Five audit layers
| Layer | What we check | Result | Findings |
|---|---|---|---|
L0 Provenance | Repo owner, licence, archive status, activity | PASS | 0 |
L1 Static source | Secrets, path traversal, supply chain, hidden code | NA | 0 |
L2 Instructions | Prompt injection, authority framing, hidden directives | PASS | 0 |
L3 Inventory | The files and declarations match the source | PASS | 0 |
L4 Sandbox | Run in isolation and watch behaviour | SKIPPED why | 0 |
Gates applied: no behavioural pass.
Findings (0)
No findings at any severity. We re-audit when the source changes.
Audit 0.4.1 · source sha aa855ad1e58d · 2 Oct 2026Report an issue or request a re-scan
Provenance
Who published it, and what the verdict is pinned to
- Publisherdavila7 GitHub userOwner of the repository this skill is read from
- Source folderdavila7/claude-code-templates/cli-tool/components/skills/web-development/tanstack-query-expertThe exact folder we audited
- LicenceMITAs the repository states it
- Commit pinned for this verdictaa855ad1e58dA new audit runs when the source changes
- Repository statusNot archivedPushed today
- Sandboxed runNot runSkills are read, not executed; layer L4 is skipped
What it tells the agent
Full source on GitHub ↗Its description: Expert in TanStack Query (React Query) — asynchronous state management. Covers data fetching, stale time configuration, mutations, optimistic updates, and Next.js App Router (SSR) integration.
---
name: tanstack-query-expert
description: "Expert in TanStack Query (React Query) — asynchronous state management. Covers data fetching, stale time configuration, mutations, optimistic updates, and Next.js App Router (SSR) integration."
risk: safe
source: community
date_added: "2026-03-07"
---
# TanStack Query Expert
You are a production-grade TanStack Query (formerly React Query) expert. You help developers build robust, performant asynchronous state management layers in React and Next.js applications. You master declarative data fetching, cache invalidation, optimistic UI updates, background syncing, error boundaries, and server-side rendering (SSR) hydration patterns.
## When to Use This Skill
- Use when setting up or refactoring data fetching logic (replacing `useEffect` + `useState`)
- Use when designing query keys (Array-based, strictly typed keys)
- Use when configuring global or query-specific `staleTime`, `gcTime`, and `retry` behavior
- Use when writing `useMutation` hooks for POST/PUT/DELETE requests
- Use when invalidating the cache (`queryClient.invalidateQueries`) after a mutation
- Use when implementing Optimistic Updates for instant UX feedback
- Use when integrating TanStack Query with Next.js App Router (Server Components + Client Boundary hydration)
## Core Concepts
### Why TanStack Query?
TanStack Query is not just for fetching data; it's an **asynchronous state manager**. It handles caching, background updates, deduplication of multiple requests for the same data, pagination, and out-of-the-box loading/error states.
**Rule of Thumb:** Never use `useEffect` to fetch data if TanStack Query is available in the stack.
## Query Definition Patterns
### The Custom Hook Pattern (Best Practice)
Always abstract `useQuery` calls into custom hooks to encapsulate the fetching logic, TypeScript types, and query keys.
```typescript
import { useQuery } from '@tanstack/react-query';
// 1. Define strict types
type User = { id: string; name: string; status: 'active' | 'inactive' };
// 2. Define the fetcher function
const fetchUser = async (userId: string): Promise<User> => {
const res = await fetch(`/api/users/${userId}`);
if (!res.ok) throw new Error('Failed to fetch user');
return res.json();
};
// 3. Export a custom hook
export const useUser = (userId: string) => {
return useQuery({
queryKey: ['users', userId], // Array-based query key
queryFn: () => fetchUser(userId),
staleTime: 1000 * 60 * 5, // Data is fresh for 5 minutes (no background refetching)
enabled: !!userId, // Dependent query: only run if userId exists
});
};
```
### Advanced Query Keys
Query keys uniquely identify the cache. They must be arrays, and order matters.
```typescript
// Filtering / Sorting
useQuery({
queryKey: ['issues', { status: 'open', sort: 'desc' }],
queryFn: () => fetchIssues({ status: 'open', sort: 'desc' })
});
// Factory pattern for query keys (Highly recommended for large apps)
export const issueKeys = {
all: ['issues'] as const,
lists: () => [...issueKeys.all, 'list'] as const,
list: (filters: string) => [...issueKeys.lists(), { filters }] as const,
details: () => [...issueKeys.all, 'detail'] as const,
detail: (id: number) => [...issueKeys.details(), id] as const,
};
```
## Mutations & Cache Invalidation
### Basic Mutation with Invalidation
When you modify data on the server, you must tell the client cache that the old data is now stale.
```typescript
import { useMutation, useQueryClient } from '@tanstack/react-query';
export const useCreatePost = () => {
const queryClient = useQueryClient();
return useMutation({
mutationFn: async (newPost: { title: string }) => {
const res = await fetch('/api/posts', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(newPost),
});
return res.json();
},
// On success, invalidate the 'posts' cache to trigger a background refetch
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: ['posts'] });
},
});
};
```
### Optimistic Updates
Give the user instant feedback by updating the cache *before* the server responds, and rolling back if the request fails.
```typescript
export const useUpdateTodo = () => {
const queryClient = useQueryClient();
return useMutation({
mutationFn: updateTodoFn,
// 1. Triggered immediately when mutate() is called
onMutate: async (newTodo) => {
// Cancel any outgoing refetches so they don't overwrite our optimistic update
await queryClient.cancelQueries({ queryKey: ['todos'] });
// Snapshot the previous value
const previousTodos = queryClient.getQueryData(['todos']);
// Optimistically update to the new value
queryClient.setQueryData(['todos'], (old: any) =>
old.map((todo: any) => todo.id === newTodo.id ? { ...todo, ...newTodo } : todo)
);
// Return a context object with the snapshotted value
return { previousTodos };
},
// 2. If the mutation fails, use the context returned from onMutate to roll back
onError: (err, newTodo, context) => {
queryClient.setQueryData(['todos'], context?.previousTodos);
},
// 3. Always refetch after error or success to ensure server sync
onSettled: () => {
queryClient.invalidateQueries({ queryKey: ['todos'] });
},
});
};
```
## Next.js App Router Integration
### Initializing the Provider
```typescript
// app/providers.tsx
'use client'
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
import { useState } from 'react'
export default function Providers({ children }: { children: React.ReactNode }) {
const [queryClient] = useState(
() =>
new QueryClient({
defaultOptions: {
queries: {
staleTime: 60 * 1000, // 1 minute
refetchOnWindowFocus: false, // Prevents aggressive refetching on tab switch
},
},
Excerpt, first 6,000 characters of SKILL.md, verbatim from the audited commit. It is text from someone else’s repository, quoted so you can judge it before your agent reads it.
Install
Pinned to the audited commit aa855ad
git clone https://github.com/davila7/claude-code-templates git -C claude-code-templates checkout aa855ad1e58d
The author documents no install command, so this uses the repository directly. Our verdict covers commit aa855ad1e58d only.
Works in
The author has not said which agents this skill supports, and we have not tested it in any.
Audit history
Every audit, every source change
- ✓SAFE B 89 / 100
first audit · source
aa855ad1e58d
README badge
For maintainers · shows the latest audit
[](https://modelsatlas.com/skills/davila7/tanstack-query-expert/)
The badge shows our verdict and grade for this skill, and links back to this page. It changes when the audit does.
Similar skills
hesreallyhim/awesome-claude-code
A hand-picked collection of the finest of resources for the most awesome of agents, Claude Code, the undisputed champion of coding companions, from the unstoppable team at Anthropic PBC. A delectable showcase of top…
davila7/claude-code-templates
Generate descriptive commit messages by analyzing git diffs. Use when the user asks for help writing commit messages or reviewing staged changes.
davila7/claude-code-templates
Use this skill whenever the user wants to do anything with PDF files. This includes reading or extracting text/tables from PDFs, combining or merging multiple PDFs into one, splitting PDFs apart, rotating pages, adding…
davila7/claude-code-templates
Create high-quality git commits: review/stage intended changes, split into logical commits, and write clear commit messages (including Conventional Commits). Use when the user asks to commit, craft a commit message,…
davila7/claude-code-templates
Semantic search, similar content discovery, and structured research using Exa API
davila7/claude-code-templates
Generative Engine Optimization for AI search engines (ChatGPT, Claude, Perplexity).
Add this badge to your README
[](https://modelsatlas.com/skills/davila7/tanstack-query-expert/)
<a href="https://modelsatlas.com/skills/davila7/tanstack-query-expert/"><img src="https://modelsatlas.com/skills/davila7/tanstack-query-expert/badge.svg" alt="ModelsAtlas: SAFE B"></a>
Questions about Tanstack Query Expert
What does the Tanstack Query Expert skill do?
Is Tanstack Query Expert safe to install?
What can Tanstack Query Expert access on my machine?
How current is this page?
Sources
- github.com/davila7/claude-code-templates/tree/main/cli-tool/comp — the audited source at commit aa855ad1e58d and every finding aboveObserved · 2 Oct 2026
Spotted something wrong? Report a correction · Methodology
Keep going in your AI
Opens with this page as the source. We add nothing else to the prompt.
- What does the Tanstack Query Expert skill do?
- Is Tanstack Query Expert safe to install?
- What can Tanstack Query Expert access on my machine?