Token导航 LogoToken导航TokenDH.com
研究检索需要联网github未标认证来源可访问许可证需确认审计提醒

grey-haven-tanstack-patterns灰色天堂 tanstack 模式

Agent Skill

grey-haven-tanstack-patterns 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

210

周安装

9

GitHub Stars

24

下载量

73
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:grey-haven-tanstack-patterns(灰色天堂 tanstack 模式)
来源仓库:https://github.com/greyhaven-ai/claude-code-config
仓库路径:skills/grey-haven-tanstack-patterns
安装命令:
npx skills add https://github.com/greyhaven-ai/claude-code-config --skill grey-haven-tanstack-patterns
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/greyhaven-ai/claude-code-config --skill grey-haven-tanstack-patterns

简介

用于查找、检索和筛选相关信息。grey-haven-tanstack-patterns 属于研究检索类 Skill,可作为该场景下的辅助能力补充。

  • 适合根据关键词或任务场景快速定位候选结果。
  • 使用时需结合来源仓库和原始 README 核验具体用法。
  • 安装前建议确认权限范围和维护状态。
  • 注意是否会触发联网、命令执行或文件读写操作。

SKILL.md

Grey Haven TanStack Patterns

Follow Grey Haven Studio's patterns for TanStack Start, Router, and Query in React 19 applications.

TanStack Stack Overview

Grey Haven uses the complete TanStack ecosystem:

  • TanStack Start: Full-stack React framework with server functions
  • TanStack Router: Type-safe file-based routing with loaders
  • TanStack Query: Server state management with caching
  • TanStack Table (optional): Data grids and tables
  • TanStack Form (optional): Type-safe form handling

Critical Patterns

1. File-Based Routing Structure

src/routes/
├── __root.tsx              # Root layout (wraps all routes)
├── index.tsx               # Homepage (/)
├── _authenticated/         # Protected routes group (underscore prefix)
│   ├── _layout.tsx        # Auth layout wrapper
│   ├── dashboard.tsx      # /dashboard
│   └── settings/
│       └── index.tsx      # /settings
└── users/
    ├── index.tsx          # /users
    └── $userId.tsx        # /users/:userId (dynamic param)

Key conventions:

  • __root.tsx - Root layout with QueryClient provider
  • _authenticated/ - Protected route groups (underscore prefix)
  • _layout.tsx - Layout wrapper for route groups
  • $param.tsx - Dynamic route parameters

2. TanStack Query Defaults

const queryClient = new QueryClient({
  defaultOptions: {
    queries: {
      staleTime: 60000, // 1 minute default
      retry: 1,
      refetchOnWindowFocus: false,
    },
  },
});

3. Query Key Patterns

// ✅ CORRECT - Specific to general
queryKey: ["user", userId]
queryKey: ["users", { tenantId, page: 1 }]
queryKey: ["organizations", orgId, "teams"]

// ❌ WRONG
queryKey: [userId]                    // Missing resource type
queryKey: ["getUser", userId]        // Don't include function name
queryKey: [{ id: userId }]           // Object first is confusing

4. Server Functions with Multi-Tenant

// ALWAYS include tenant_id parameter
export const getUserById = createServerFn("GET", async (
  userId: string,
  tenantId: string
) => {
  const user = await db.query.users.findFirst({
    where: and(
      eq(users.id, userId),
      eq(users.tenant_id, tenantId) // Multi-tenant isolation!
    ),
  });

  if (!user) throw new Error("User not found");
  return user;
});

5. Route Loaders

export const Route = createFileRoute("/_authenticated/dashboard")({
  // Loader fetches data on server before rendering
  loader: async ({ context }) => {
    const tenantId = context.session.tenantId;
    return await getDashboardData(tenantId);
  },
  component: DashboardPage,
});

function DashboardPage() {
  const data = Route.useLoaderData(); // Type-safe loader data
  return <div>...</div>;
}

6. Mutations with Cache Invalidation

const mutation = useMutation({
  mutationFn: (data: UserUpdate) => updateUser(userId, data),
  // Always invalidate queries after mutation
  onSuccess: () => {
    queryClient.invalidateQueries({ queryKey: ["user", userId] });
  },
});

Caching Strategy

Grey Haven uses these staleTime defaults:

Data TypestaleTimeUse Case
Auth data5 minutesUser sessions, tokens
User profiles1 minuteUser details
Lists1 minuteData tables, lists
Static/config10 minutesSettings, configs
Realtime0 (always refetch)Notifications
const STALE_TIMES = {
  auth: 5 * 60 * 1000,        // 5 minutes
  user: 1 * 60 * 1000,        // 1 minute
  list: 1 * 60 * 1000,        // 1 minute
  static: 10 * 60 * 1000,     // 10 minutes
  realtime: 0,                // Always refetch
};

Supporting Documentation

All supporting files are under 500 lines per Anthropic best practices:

- router-patterns.md - File-based routing, layouts, navigation - query-patterns.md - Queries, mutations, infinite queries - server-functions.md - Creating and using server functions - advanced-patterns.md - Dependent queries, parallel queries, custom hooks - INDEX.md - Examples navigation

- router-config.md - Router setup and configuration - query-config.md - QueryClient configuration - caching-strategy.md - Detailed caching patterns - multi-tenant.md - Multi-tenant patterns with RLS - INDEX.md - Reference navigation

- root-route.tsx - Root layout template - auth-layout.tsx - Protected layout template - page-route.tsx - Basic page route template - server-function.ts - Server function template - custom-hook.ts - Custom query hook template

- tanstack-checklist.md - TanStack patterns checklist

When to Apply This Skill

Use this skill when:

  • Building TanStack Start applications
  • Implementing routing with TanStack Router
  • Managing server state with TanStack Query
  • Creating server functions for data fetching
  • Optimizing query performance with caching
  • Implementing multi-tenant data access
  • Setting up authentication flows with route protection
  • Building data-heavy React applications

Template Reference

These patterns are from Grey Haven's production template:

  • cvi-template: TanStack Start + Router + Query + React 19

Critical Reminders

  1. staleTime: Default 60000ms (1 minute) for queries
  2. Query keys: Specific to general (["user", userId], not [userId])
  3. Server functions: Always include tenant_id parameter
  4. Multi-tenant: Filter by tenant_id in all server functions
  5. Loaders: Use for server-side data fetching before render
  6. Mutations: Invalidate queries after successful mutation
  7. Prefetching: Use for performance on hover/navigation
  8. Error handling: Always handle error state in queries
  9. RLS: Server functions use RLS-enabled database connection
  10. File-based routing: Underscore prefix (_) for route groups/layouts

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Claude

32.25%
按下载量换算24

Codex

32.14%
按下载量换算23

Cursor

17.97%
按下载量换算13

Gemini CLI

9.24%
按下载量换算7

安全审计

Gen Agent Trust Hub

通过

Socket

可疑

Snyk

通过

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在 warning/failed 结果,不能写成本站确认安全。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills