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.
npx agentmods add rules/kensaurus/cursor-kenji/data-fetchinggit clone --depth 1 https://github.com/kensaurus/cursor-kenjiWrote 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.
[](https://agentmods.dev/rules/kensaurus/cursor-kenji/data-fetching)<a href="https://agentmods.dev/rules/kensaurus/cursor-kenji/data-fetching"><img src="https://agentmods.dev/badge/rules/kensaurus/cursor-kenji/data-fetching.svg" alt="Measured on agentmods" height="20"></a>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.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5 | $0.00000 | $0.00563 |
| Opus 5 | $0.00000 | $0.00282 |
| Sonnet 5 | $0.00000 | $0.00113 |
| Haiku 4.5 | $0.00000 | $0.00056 |
Grade A, and why
data-fetching 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 yesterday.
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.
How it starts
The opening of the file, as written. The whole thing — 78 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Data Fetching Conventions
Decision Matrix
| Context | Pattern |
|---|---|
| Server Component (initial load) | Direct Supabase/Prisma query |
| Client Component (read) | TanStack Query useQuery |
| Client Component (mutation) | TanStack Query useMutation or Server Action |
| Form submission | Server Action with useActionState |
| Real-time updates | Supabase Realtime subscription |
| URL-driven state | nuqs useQueryStates |
TanStack Query Patterns
// Query with proper key factory
const queryKeys = {
all: ['features'] as const,
lists: () => [...queryKeys.all, 'list'] as const,
list: (filters: Filters) => [...queryKeys.lists(), filters] as const,
details: () => [...queryKeys.all, 'detail'] as const,
detail: (id: string) => [...queryKeys.details(), id] as const,
}
// Hook
export function useFeatures(filters: Filters) {
return useQuery({
queryKey: queryKeys.list(filters),
queryFn: () => fetchFeatures(filters),
staleTime: 5 * 60 * 1000, // 5 minutes
})
}
Next.js 16 caching
Caching is explicit: 'use cache' + cacheComponents (static shell / dynamic
holes). Do not assume implicit fetch caching. Turbopack is default for
dev and build. React Compiler: reactCompiler: true.
Server Component Prefetching
// Prefetch in Server Component, hydrate in Client
import { HydrationBoundary, dehydrate } from '@tanstack/react-query'
export default async function Page() {
const queryClient = new QueryClient()
await queryClient.prefetchQuery({
queryKey: ['features'],
queryFn: fetchFeatures,
})
return (
<HydrationBoundary state={dehydrate(queryClient)}>
<FeatureList />
</HydrationBoundary>
)
}
Error Handling
- Always handle
errorstate fromuseQuery - Show
<ErrorState>component with retry button - Mutations: use
onSuccessfor cache invalidation,onErrorfor toast
Caching
- Set
staleTimebased on data freshness needs - Use
queryClient.invalidateQueriesafter mutations - Use
revalidatePath/revalidateTagin Server Actions
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.
- yesterday First seen · 78 lines · 0 tokens per session scan A 12601761439d
data-fetching is a cursor rule published in the GitHub repository kensaurus/cursor-kenji (9 stars, last pushed 7d ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 563 tokens. 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-09-03.
Other cursor rules, from other repositories
component-patterns
Frontend component architecture and patterns. Apply when creating or editing UI components.
state-management
Frontend state management patterns and best practices. Apply when managing client state.
performance
Frontend performance optimization rules. Apply when optimizing UI or bundle.
solana-transaction-safety
Safe Solana transaction submission patterns using Helius Sender.
nextjs
Rules for Next.js projects (App Router and Pages Router).
react
Rules for React component files (any framework).