Apply Grey Haven's TanStack ecosystem patterns - Router file-based routing, Query data fetching with staleTime, and Start server functions. Use when building React applications with TanStack Start. Triggers: 'TanStack', 'TanStack Start', 'TanStack Query', 'TanStack Router', 'React Query', 'file-based routing', 'server functions'.
/plugin marketplace add greyhaven-ai/claude-code-config/plugin install research@grey-haven-pluginsThis skill is limited to using the following tools:
checklists/tanstack-checklist.mdexamples/INDEX.mdexamples/advanced-patterns.mdexamples/query-patterns.mdexamples/router-patterns.mdexamples/server-functions.mdreference/INDEX.mdreference/caching-strategy.mdreference/multi-tenant.mdreference/query-config.mdreference/router-config.mdtemplates/auth-layout.tsxtemplates/custom-hook.tstemplates/page-route.tsxtemplates/root-route.tsxtemplates/server-function.tsFollow Grey Haven Studio's patterns for TanStack Start, Router, and Query in React 19 applications.
Grey Haven uses the complete TanStack ecosystem:
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 parametersconst queryClient = new QueryClient({
defaultOptions: {
queries: {
staleTime: 60000, // 1 minute default
retry: 1,
refetchOnWindowFocus: false,
},
},
});
// ✅ 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
// 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;
});
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>;
}
const mutation = useMutation({
mutationFn: (data: UserUpdate) => updateUser(userId, data),
// Always invalidate queries after mutation
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: ["user", userId] });
},
});
Grey Haven uses these staleTime defaults:
| Data Type | staleTime | Use Case |
|---|---|---|
| Auth data | 5 minutes | User sessions, tokens |
| User profiles | 1 minute | User details |
| Lists | 1 minute | Data tables, lists |
| Static/config | 10 minutes | Settings, configs |
| Realtime | 0 (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
};
All supporting files are under 500 lines per Anthropic best practices:
examples/ - Complete code examples
reference/ - Configuration references
templates/ - Copy-paste ready templates
checklists/ - Pre-PR validation
Use this skill when:
These patterns are from Grey Haven's production template:
Create employment contracts, offer letters, and HR policy documents following legal best practices. Use when drafting employment agreements, creating HR policies, or standardizing employment documentation.
Implement GDPR-compliant data handling with consent management, data subject rights, and privacy by design. Use when building systems that process EU personal data, implementing privacy controls, or conducting GDPR compliance reviews.