32-data-fetch-patterns

32-data-fetch-patterns is a cursor rule for Cursor from ryoha000/launcherg. It costs 0 tokens per session (1,469 once invoked), scanned A, original, Unlicense.

A coding rule for using TanStack Query, a library for managing data loaded by an application, with Tauri and SQLite. It requires the user interface to use shared query and mutation functions instead of calling the desktop backend directly.

In plain words
What is it for?
Use it when adding or changing SQLite-backed reads, writes, caching, or data-loading code in the Svelte/Tauri app.
Why use it?
It keeps data access in one predictable layer and helps avoid inconsistent query keys, cache settings, and backend calls. A query reads data; a mutation changes it.

Cursor rule for Cursor

Written for Cursor: installed under .cursor/.

Good fit Use it when adding or changing SQLite-backed reads, writes, caching, or data-loading code in the Svelte/Tauri app.

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/ryoha000/launcherg/32-data-fetch-patterns
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/ryoha000/launcherg

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 32-data-fetch-patterns

README.md
[![agentmods](https://agentmods.dev/badge/rules/ryoha000/launcherg/32-data-fetch-patterns/github.svg)](https://agentmods.dev/rules/ryoha000/launcherg/32-data-fetch-patterns)
Your own site
<a href="https://agentmods.dev/rules/ryoha000/launcherg/32-data-fetch-patterns"><img src="https://agentmods.dev/badge/rules/ryoha000/launcherg/32-data-fetch-patterns/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 32-data-fetch-patterns

Your own site · 80×15
<a href="https://agentmods.dev/rules/ryoha000/launcherg/32-data-fetch-patterns"><img src="https://agentmods.dev/badge/rules/ryoha000/launcherg/32-data-fetch-patterns.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,469 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.01469
Opus 5 $0.00000 $0.00734
Sonnet 5 $0.00000 $0.00294
Haiku 4.5 $0.00000 $0.00147

Measured today against content hash ead51118fce6, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-13, from the pricing page.

Security

Grade A, and why

32-data-fetch-patterns 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 today.

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/32-data-fetch-patterns.mdc · 125 lines

How it starts

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

Data Fetch パターン(TanStack Query + Tauri)

このルールは、SQLite/Tauri コマンド連携を TanStack Query で統一するための運用規約です。UI 層は直接 invoke を呼ばず、データ層(Query/Mutation)を経由します。

コア設計

  • QueryClient は単一インスタンスを QueryClientProvider でアプリ全体に提供。
    • 実装: src/lib/data/queryClient.ts
    • 既定オプション(staleTime 等)はここで集中管理。例外のみクエリ側で上書き。
  • クエリキーは安定・最小の粒度で queryKeys に集約。
  • リソース別に Query/Mutation を src/lib/data/queries/* に定義。
  • UI 層からはコマンドを直接呼ばず、Query/Mutation のみ使用。

ディレクトリ構成(要点)

  • src/lib/data/queryClient.ts … QueryClient の生成・既定オプション
  • src/lib/data/queryKeys.ts … 安定キー(例: denyList.all()games(), game(id)
  • src/lib/data/queries/*.ts … リソース毎の useXxxQuery/useXxxMutation

Provider(アプリ組み込み)

App.svelteQueryClientProvider をルートに設置。

<script lang="ts">
  import { QueryClientProvider } from '@tanstack/svelte-query'
  import { queryClient } from '@/lib/data/queryClient'
</script>

<QueryClientProvider client={queryClient}>
  <!-- App content -->
</QueryClientProvider>

クエリ定義(読み取り系)

  • 命名は useXxxQuery。返り値は Svelte ストア(CreateQueryResult)。
  • queryKeyqueryKeys を使用。
  • 既定オプションは queryClient に寄せ、特殊な場合のみクエリ側で指定。
// src/lib/data/queries/denyList.ts
import { createQuery } from '@tanstack/svelte-query'
import { commandDenyListAll } from '@/lib/command'
import { queryKeys } from '@/lib/data/queryKeys'

export function useDenyListQuery() {
  return createQuery({
    queryKey: queryKeys.denyList.all(),
    queryFn: () => commandDenyListAll(),
  })
}

ミューテーション定義(更新系)

  • 命名は useXxxMutation。成功時に関連クエリをピンポイントで invalidate。
  • 必要に応じて楽観的更新(onMutate)→ ロールバック(onError)を使用。
// src/lib/data/queries/denyList.ts
import { createMutation } from '@tanstack/svelte-query'
import { commandDenyListAdd, commandDenyListRemove } from '@/lib/command'
import { queryClient } from '@/lib/data/queryClient'
import { queryKeys } from '@/lib/data/queryKeys'

export function useAddDenyListMutation() {
  return createMutation<unknown, Error, { storeType: number, storeId: string, name: string }>({
    mutationFn: input => commandDenyListAdd(input.storeType, input.storeId, input.name),
    onSuccess: async () => {
      await queryClient.invalidateQueries({ queryKey: queryKeys.denyList.all() })
    },
  })
}

export function useRemoveDenyListMutation() {
  return createMutation<unknown, Error, { storeType: number, storeId: string }>({
    mutationFn: input => commandDenyListRemove(input.storeType, input.storeId),
    onSuccess: async () => {
      await queryClient.invalidateQueries({ queryKey: queryKeys.denyList.all() })
    },
  })
}

Read the full file on GitHub · 125 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. today First seen · 125 lines · 0 tokens per session scan A ead51118fce6

Subscribe to this mod's changes

32-data-fetch-patterns is a cursor rule published in the GitHub repository ryoha000/launcherg (37 stars, last pushed 5mo ago), licensed Unlicense. It costs nothing until one of its globs matches a file; then it loads 1,469 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-12.