data-fetching

data-fetching is a cursor rule for Cursor from BetterTyped/hype-stack. It costs 0 tokens per session (1,339 once invoked), scanned A, original, MIT.

A project rule requiring the HyperFetch SDK for API and WebSocket communication in client applications. APIs let software exchange data, while WebSockets maintain a live connection for updates.

In plain words
What is it for?
Use it when implementing API or WebSocket data fetching in those client applications.
Why use it?
It keeps network communication consistent across the frontend, admin panel, mobile app, and browser extension.

Cursor rule for Cursor

Written for Cursor: installed under .cursor/.

Good fit Use it when implementing API or WebSocket data fetching in those client applications.

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/bettertyped/hype-stack/data-fetching
Install

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.

Clone the repo
git clone --depth 1 https://github.com/BetterTyped/hype-stack

Made for: Cursor.

Wrote 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.

agentmods badge for data-fetching

README.md
[![agentmods](https://agentmods.dev/badge/rules/bettertyped/hype-stack/data-fetching/github.svg)](https://agentmods.dev/rules/bettertyped/hype-stack/data-fetching)
Your own site
<a href="https://agentmods.dev/rules/bettertyped/hype-stack/data-fetching"><img src="https://agentmods.dev/badge/rules/bettertyped/hype-stack/data-fetching/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for data-fetching

Your own site · 80×15
<a href="https://agentmods.dev/rules/bettertyped/hype-stack/data-fetching"><img src="https://agentmods.dev/badge/rules/bettertyped/hype-stack/data-fetching.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 1,339 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

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.

ModelPer sessionOnce invoked
Fable 5.1 $0.00000 $0.01339
Opus 5.5 $0.00000 $0.00536
Sonnet 5.5 $0.00000 $0.00268
Haiku 4.5 $0.00000 $0.00134

Measured 1mo ago against content hash 88e4237fe8ef, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

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 1mo 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.

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.

.cursor/rules/data-fetching.mdc · 80 lines

How it starts

The opening of the file, as written. The whole thing — 80 lines — stays where its author put it; the contents beside it link to each section on GitHub.

HyperFetch Data Exchange

Applies to all client apps: apps/frontend, apps/admin, apps/mobile, and apps/extension. Each has its own sdk in src/api/sdk.ts.

All client API calls should go through the HyperFetch SDK (sdk from @/api/sdk) instead of raw fetch(), axios, or other HTTP clients.

HTTP

  • Reads: useFetch(sdk.<path>.$get) from @hyper-fetch/react.
  • Mutations: useSubmit(sdk.<path>.$post | .$put | .$delete) from @hyper-fetch/react.
  • Use onSubmitSuccess / onSubmitError callbacks for side effects (toast, refetch, navigation).
  • For file uploads, pass { payload: formData } to submit() where formData is a FormData instance.
  • The SDK is fully typed end-to-end from Hono backend routes. Bypassing it loses type safety.
  • New backend endpoints are automatically available on the SDK via the Hono-to-HyperFetch type bridge.

Responses never throw

send() and submit() always resolve. A network failure, a timeout, an abort, a 4xx or a 5xx: every one of them comes back as { data: null, error, status, success: false }. There is nothing to catch.

  • Never wrap a HyperFetch call in try/catch. It cannot throw, so the catch only hides bugs in the code around it, and it tempts you into throw new Error(...) on result.error, which turns a typed error back into an exception.
  • Branch on the result: const { data, error } = await submit(...); if (error || !data) { toast.error(...); return false; }.
  • With hooks, read error from useFetch, and use onSubmitSuccess / onSubmitError on useSubmit.
  • A hook or helper that wraps a request returns an outcome (boolean, { documentId, error: null } | { documentId: null, error }). It does not throw so that a caller can catch. Callers branch too.
  • abort() is cancellation, not failure. After an await, check signal.aborted and return quietly instead of reporting the abort as an error.
  • The one place an exception is right is a fetch-shaped adapter for a third-party library that only understands rejections (an AI SDK transport, for example). Throw response.error after the await, still without try/catch.

Read the full file on GitHub · 80 lines

Changes

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.

  1. 1mo ago Changed · +43 lines 88e4237fe8ef
  2. 1mo ago First seen · 37 lines · 0 tokens per session scan A 30d48c42ffc5

Subscribe to this mod's changes

data-fetching is a cursor rule published in the GitHub repository BetterTyped/hype-stack (12 stars, last pushed 15d ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 1,339 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-08-31.