AGENT SKILL

tanstack

Comprehensive guide for the TanStack ecosystem in React — Query (caching, mutations, prefetching, SSR), DB (collections, live queries, optimistic updates), Form (state, validation, fields), Router (file-based, type-safe navigation, search params, loaders), and Start (server functions, middleware, auth, SSR). Use when working with any TanStack library in a React/full-stack project. Don't use for non-TanStack data libraries (SWR, Apollo, RTK Query), non-React TanStack ports (Solid, Svelte), or backend-only work.

License 许可
MIT
最近更新
2026-07-16
Stars
★ 0
Forks
0

01 前言 Front Matter

name
tanstack
metadata
{ "author": "Pedro Nauck", "github": "https://github.com/pedronauck", "repository": "https://github.com/pedronauck/skills" }
description
Comprehensive guide for the TanStack ecosystem in React — Query (caching, mutations, prefetching, SSR), DB (collections, live queries, optimistic updates), Form (state, validation, fields), Router (file-based, type-safe navigation, search params, loaders), and Start (server functions, middleware, auth, SSR). Use when working with any TanStack library in a React/full-stack project. Don't use for non-TanStack data libraries (SWR, Apollo, RTK Query), non-React TanStack ports (Solid, Svelte), or backend-only work.
allowed-tools
Read, Grep, Glob

02 资源文件 5

03 SKILL.md 正文

TanStack Developer Guide

This SKILL.md is a dispatcher, not an encyclopedia. The load-bearing detail (code patterns, anti-patterns, edge cases, full checklists) lives in references/*.md. The tripwires below exist so you can detect violations during scanning — they are not the contract.

Required Reading Router

Match the task to the row. Read the listed file(s) in full before producing output. They are not appendices — they are the contract. Inline content in this SKILL.md is a pointer, not a substitute.

Task MUST read
useQuery / useMutation / prefetch / infinite list / SSR hydration / cache config references/query-patterns.md
Typed collections, live queries, optimistic collection mutations references/db-patterns.md
Forms, field components, validation, async checks references/form-patterns.md
Routes, search params, loaders, navigation, auth-protected layouts, router setup references/router-patterns.md
Server functions, middleware, sessions, SSR streaming, env, deploy adapters references/start-patterns.md
Anything that touches two or more layers (e.g. route loader + server fn + form) Each file from the relevant rows — read all before designing

Reference Index

File What you get
references/query-patterns.md Vanilla Query: key factories + queryOptions, staleTime/gcTime, placeholderData vs initialData, optimistic mutations with rollback, error boundaries, intent prefetch, infinite queries, SSR dehydrate/hydrate, useQueries, cancellation, select, network mode, persistence, testing
references/db-patterns.md DB collections: 5 critical rules, collection setup, live queries with joins, optimistic updates, shared collection instances, persistence handlers, common anti-patterns, advanced patterns (computed, aggregations, pagination)
references/form-patterns.md Form: createFormHook + useAppForm, Zod schema validation, field/form/async validators with debounce, reusable field components (TextField, SelectField, SubmitButton), array fields, error handling with a11y, performance, anti-patterns
references/router-patterns.md Router: declare module registration, router defaults, from narrowing, pathless layouts, search-param Zod validation, parallel + deferred loaders, lazy + auto code splitting, custom serializers, notFound(), route masks, integration with TanStack Query
references/start-patterns.md Start: createServerFn with Zod validator, request + function middleware, secure cookie sessions, route protection, SSR streaming + hydration safety, prerender/ISR, API routes, env split, file separation, deploy adapters

Tripwires (not the contract)

These bullets exist so you can spot likely violations during a scan. They are deliberately incomplete. The full rules, examples, and edge cases live in the reference files. If a tripwire triggers, you must consult the referenced file before fixing.

Query / DB

  • Vanilla Query and DB collections are different paradigms — never mix them on the same entity.
  • staleTime: 0 (default) refetches on every mount. Tune by data volatility.
  • Optimistic mutations without cancelQueries + rollback context will get overwritten by in-flight refetches.

STOP. Read references/query-patterns.md in full before writing a useQuery, useMutation, prefetch, or SSR hydration boundary. STOP. Read references/db-patterns.md in full before creating a collection, live query, or persistence handler. The three bullets above only flag the most common slip-ups.

Form

  • defaultValues drives type inference — manual generics fight it.
  • Async validators without asyncDebounceMs hammer the network.
  • Reuse Zod schemas across form + server function (in *.shared.ts).

STOP. Read references/form-patterns.md in full before building or modifying a form, field component, or validator. Field-level a11y attributes, createFormHook setup, and array-field patterns are not in this body.

Router

  • Without declare module '@tanstack/react-router' { interface Register { router: typeof router } }, Link/useNavigate/useParams silently degrade to unknown.
  • Sequential awaits in a loader create waterfalls — fan out with Promise.all.
  • Throw notFound() / redirect() from loaders, not generic Error.

STOP. Read references/router-patterns.md in full before adding a route, changing router setup, writing a loader, or modifying search-param validation. Defaults (defaultPreload, scrollRestoration, global error/404), pathless layouts, masks, and deferred loaders all live in the reference.

Start

  • Server logic belongs in createServerFn with a Zod validator() — not raw fetch + API routes.
  • Auth uses HTTP-only cookies. localStorage is XSS-bait.
  • SSR loaders should await only critical data; stream the rest via prefetchQuery + Suspense.

STOP. Read references/start-patterns.md in full before writing a server function, middleware, session helper, or SSR loader. Cookie settings, middleware composition order, hydration-safety pitfalls, and adapter trade-offs are not in this body.


End-of-task checklist

Each reference file has a scoped checklist with the real validation criteria. This umbrella confirms you actually consulted them:

  • [ ] For each layer you touched, the corresponding reference file was read in full, not skimmed
  • [ ] The scoped checklist in that reference file passes
  • [ ] No mixed Query/DB paradigms on the same entity
  • [ ] pnpm run typecheck and pnpm run test pass

If you cannot point to which reference file you read for a given change, the change is not done.

04 同仓库更多 Skills

haryelramalho
haryelramalho/skills

to-prompt-opus

Use when preparing or rewriting prompts for Claude Opus 4.8, Anthropic API agents, XML-structured prompts, long-context document work, coding agents, research synthesis, frontend/design tasks, or model-specific prompt optimization. Do not use for GPT/OpenAI prompts or raw context packaging without Opus-specific tuning.

★ 0
haryelramalho
haryelramalho/skills

to-prompt-gpt

Use when preparing or rewriting prompts for GPT-5.5, OpenAI API agents, Responses workflows, coding agents, research synthesis, support assistants, or model-specific prompt optimization. Do not use for Claude/Opus prompts or raw context packaging without GPT-specific tuning.

★ 0
haryelramalho
haryelramalho/skills

plan-refactor-qa

Plans and runs qa-report before executing Compozy refactor tasks. Use when the user provides a refactor or issue slug and wants Codex to inspect the matching .compozy/tasks directory, related PRD/TechSpec/ADR/task artifacts, affected code, and existing tests, then invoke $qa-report with a repository-grounded prompt. Do not use to run tests, execute qa-execution, implement code, or perform post-refactor verification.

★ 0
haryelramalho
haryelramalho/skills

multi-tool-branch-review

Orchestrates a multi-tool branch review of the current git branch against a base branch. By default it runs two independent thermo-nuclear maintainability audits, one on Codex GPT-5.5 xhigh and one on Claude Opus xhigh, then consolidates the findings into a single remediation plan via writing-plans. If the user explicitly asks for native reviews, it can add the Claude native review pass, the Codex native review pass, or both. Use when the user wants a deep cross-model review of a branch or PR before merge, or asks to review this branch with multiple tools or models. Encodes known infra failure modes and their fixes (missing Claude ACP adapter, Codex MCP auth hangs, false-positive report files, long jobs orphaned inside subagents). Do not use for reviewing a single uncommitted snippet, for non-git work, for running only one reviewer, or when the user only wants a quick lint or test run.

★ 0
haryelramalho
haryelramalho/skills

create-pr-with-template

Create a GitHub Pull Request with gh CLI and prefer repository PR templates automatically. Use this whenever the user asks to open/create a PR, especially when template compliance is needed. If multiple templates exist, ask the user which template to use.

★ 0
haryelramalho
haryelramalho/skills

ui-craft

Provides guardrails for user-facing UI work: usability heuristics, accessibility floors, design-system discipline, component states, microcopy, motion, dark mode, responsive behavior, and human-AI UX. Use when designing, generating, reviewing, or refactoring visible product surfaces such as components, pages, dashboards, forms, dialogs, loading/empty/error states, or AI interfaces. Do not use for backend-only work, infrastructure, CLI/TUI design, or pure documentation editing.

★ 0