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/nedcodes-ok/cursorrules-collection/swrgit clone --depth 1 https://github.com/nedcodes-ok/cursorrules-collectionWhat 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.00704 | $0.00704 |
| Opus 5 | $0.00352 | $0.00352 |
| Sonnet 5 | $0.00141 | $0.00141 |
| Haiku 4.5 | $0.00070 | $0.00070 |
Grade A, and why
swr scanned grade A with 1 finding 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 2d ago.
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.
Makes network callslowCapability
Not a fault in itself. Listed so you know the mod talks to something, and to what.
- Always define a typed fetcher: const fetcher = (url: string) => fetch(url).then(r => r.json()) as Promise<T> How it starts
The opening of the file, as written. The whole thing — 54 lines — stays where its author put it; the contents beside it link to each section on GitHub.
SWR Cursor Rules
You are an expert in SWR (stale-while-revalidate). Follow these rules:
Basic Usage
- Always define a typed fetcher: const fetcher = (url: string) => fetch(url).then(r => r.json()) as Promise
- Pass a stable key — string or array. Null/undefined/falsy key skips the request
- Destructure fully: const { data, error, isLoading, isValidating, mutate } = useSWR(key, fetcher)
- Distinguish isLoading (no data yet) from isValidating (revalidating with existing data)
Key Patterns
- Use array keys for parameterized requests: useSWR(['/api/users', page], fetcher)
- Conditional fetching: useSWR(userId ?
/api/users/${userId}: null, fetcher) - Use useSWR(() =>
/api/users/${userId}) — function keys throw to pause on missing deps - Keep keys deterministic — same params = same key = shared cache
Configuration
- Set global config via SWRConfig at app root for shared fetcher and options
- Set revalidateOnFocus: false for data that rarely changes (settings, profiles)
- Use refreshInterval for polling: useSWR(key, fetcher, { refreshInterval: 5000 })
- Use dedupingInterval (default 2s) to prevent duplicate requests from multiple components
Mutations
- Use the bound mutate for local mutations: const { mutate } = useSWR(key, fetcher)
- Optimistic updates: mutate(newData, { optimisticData: newData, rollbackOnError: true, revalidate: true })
- Use useSWRMutation for triggered mutations (POST/PUT/DELETE): const { trigger } = useSWRMutation(key, sendRequest)
- Global mutate for cross-component invalidation: import { mutate } from 'swr'; mutate('/api/users')
Error Handling
- Check error before rendering data — errors can coexist with stale data
- Use onErrorRetry in config to customize retry logic (or disable for 4xx)
- Display stale data with an error banner rather than replacing content with an error page
- Set errorRetryCount to limit retries: { errorRetryCount: 3 }
Performance
- Use useSWRInfinite for paginated/infinite scroll data
- Preload data: preload(key, fetcher) on hover or route prefetch
- Use the keepPreviousData option to prevent loading flicker during key changes
- Avoid waterfalls: fetch independent data in parallel with separate useSWR calls
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.
- 2d ago First seen · 54 lines · 704 tokens per session scan A 79a045463ba9
swr is a cursor rule published in the GitHub repository nedcodes-ok/cursorrules-collection (37 stars, last pushed 6mo ago), licensed MIT. It adds 704 tokens to every session, about $0.0035 per session on Opus 5. A static security scan graded it A with 1 finding (makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.