Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

lov-install-tanstack-query

БесплатноБез исполняемых скриптовНе проверен

为前端项目接入 TanStack Query 作为统一服务端状态层,迁移零散的 fetch/invoke 请求。Use when the user mentions "初始化 TanStack Query", "重构网络请求", "统一请求缓存", "useInvokeQuery".

lovstudioот lovstudio★ 72 звезды на GitHub

Об этом скилле

TanStack Query 接入 · TanStack Query Setup

Use this skill to add TanStack Query to a project or refactor existing request state into a shared query/mutation layer.

Triggers

Activate when

  • “初始化 TanStack Query”“重构网络请求”“统一请求缓存”“把 useEffect 里的请求迁到 React Query”
  • "install-tanstack-query", "TanStack Query refactor", or a request for useInvokeQuery-style wrappers.
  • The user asks to install or initialize TanStack Query / React Query, set up query infrastructure, or standardize query keys.
  • The project has repeated useEffect + useState + fetch/invoke request code.
  • The user wants all network-backed reads to share cache, refetch, invalidation, and loading/error behavior.
  • A Tauri app uses many invoke() reads that should be treated as server state.
  • The user mentions RTK Query but the project already uses, or prefers, TanStack Query.

Do not activate when

  • The project deliberately uses RTK Query, SWR, or Apollo and the user does not ask to migrate.
  • The work is only imperative side effects (terminal I/O, file open, clipboard, relaunch, installer progress); they stay command-driven.
  • A whole app is being generated or standardized: use lov-app-generator, which calls this Skill when the app has server state.
  • The Tauri Rust command surface or the frontend invoke adapter is being restructured: use lov-optimize-tauri-backend.

Skill Group Composition

Read references/skill-composition.md before routing to or extending an adjacent Skill.

Workflow

Step 1: Read Local Rules First

Before changing files, inspect local instructions and project shape:

pwd
find .. -name AGENTS.md -print
rg -n "@tanstack/react-query|react-query|@reduxjs/toolkit|createApi|useQuery|useMutation|fetch\\(|invoke\\(" package.json src app pages components 2>/dev/null

Honor project-specific constraints. If local instructions say not to run build, do not run it. Prefer rg and inspect existing patterns before adding new abstractions.

Step 2: Classify Request Code

Separate code into three buckets:

Bucket Examples TanStack Query?
Server state reads list/get/search/version/status/catalog/settings loaded from network or Tauri backend Yes, useQuery
Server state writes save/delete/toggle/install request, followed by cache changes Yes, useMutation
Imperative side effects terminal I/O, file open, clipboard, app relaunch, installer progress events, streaming channels Usually no

Do not force command-style effects into Query just to make the code look uniform. The goal is unified server state, not hiding every side effect.

Step 3: Install Only If Needed

Check package.json first. If TanStack Query is absent, detect package manager from lockfiles and install:

pnpm add @tanstack/react-query
npm install @tanstack/react-query
yarn add @tanstack/react-query
bun add @tanstack/react-query

Only add persistence or devtools when the project already uses them or the user explicitly asks:

pnpm add @tanstack/react-query-persist-client @tanstack/query-sync-storage-persister
pnpm add -D @tanstack/react-query-devtools

Step 4: Add Provider

Add one top-level QueryClientProvider near the app root. Keep it consistent with the existing architecture.

Recommended defaults:

import { QueryClient, QueryClientProvider } from "@tanstack/react-query";

const queryClient = new QueryClient({
  defaultOptions: {
    queries: {
      staleTime: Infinity,
      refetchOnWindowFocus: false,
      retry: false,
    },
  },
});

root.render(
  <QueryClientProvider client={queryClient}>
    <App />
  </QueryClientProvider>,
);

Adjust defaults for product needs. Data that changes frequently should use a shorter staleTime, polling, streaming, or explicit invalidation.

Step 5: Create Shared Query Infrastructure

Prefer small local wrappers over scattering raw useQuery calls everywhere.

For Tauri apps:

import { invoke } from "@tauri-apps/api/core";
import {
  useMutation,
  useQuery,
  useQueryClient,
  type QueryKey,
  type UseQueryOptions,
  type UseMutationOptions,
} from "@tanstack/react-query";

type InvokeQueryOptions<TQueryFnData, TData> = Omit<
  UseQueryOptions<TQueryFnData, Error, TData, QueryKey>,
  "queryKey" | "queryFn"
>;

export function useInvokeQuery<TQueryFnData, TData = TQueryFnData>(
  queryKey: QueryKey,
  command: string,
  args?: Record<string, unknown>,
  options?: InvokeQueryOptions<TQueryFnData, TData>,
) {
  return useQuery<TQueryFnData, Error, TData, QueryKey>({
    queryKey,
    queryFn: () => invoke<TQueryFnData>(command, args),
    staleTime: Infinity,
    refetchOnMount: false,
    refetchOnWindowFocus: false,
    ...options,
  });
}

type InvokeMutationOptions<T, V> = Omit<UseMutationOptions<T, Error, V>, "mutationFn">;

export function useInvokeMutation<T, V = void>(
  command: string,
  invalidateKeys?: QueryKey[],
  options?: InvokeMutationOptions<T, V>,
) {
  con
Полный SKILL.md на GitHub

Установить lov-install-tanstack-query в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

.gitignoreCHANGELOG.mdLICENSEREADME.mdreferences/skill-composition.mdskill.yaml

FAQ

Что делает скилл lov-install-tanstack-query?

为前端项目接入 TanStack Query 作为统一服务端状态层,迁移零散的 fetch/invoke 请求。Use when the user mentions "初始化 TanStack Query", "重构网络请求", "统一请求缓存", "useInvokeQuery".

Как установить скилл lov-install-tanstack-query?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл lov-install-tanstack-query запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить lov-install-tanstack-query с