tanstack-router-best-practices
π―Skillfrom deckardger/tanstack-agent-skills
Provides AI-guided best practices and coding recommendations for implementing type-safe, performant routing in React applications using TanStack Router.
Installation
npx skills add https://github.com/deckardger/tanstack-agent-skills --skill tanstack-router-best-practicesSkill Details
Overview
# TanStack Agent Skills
Comprehensive best practices for building applications with the TanStack ecosystem. These skills provide AI coding agents with structured guidelines for TanStack Query, TanStack Router, and TanStack Start.
Available Skills
[tanstack-query](./skills/tanstack-query/)
Best practices for data fetching, caching, mutations, and server state management with TanStack Query (React Query).
32+ rules across 8 categories:
- Query Keys (CRITICAL) β Proper key structure and organization
- Caching (CRITICAL) β staleTime, gcTime, and invalidation patterns
- Mutations (HIGH) β Optimistic updates, error handling
- Error Handling (HIGH) β Error boundaries, retry logic
- Prefetching (MEDIUM) β Intent-based and route prefetching
- Infinite Queries (MEDIUM) β Pagination patterns
- SSR Integration (MEDIUM) β Hydration and dehydration
- Performance (LOW) β Select transforms, memoization
[tanstack-router](./skills/tanstack-router/)
Best practices for type-safe routing, data loading, search params, and navigation with TanStack Router.
30+ rules across 8 categories:
- Type Safety (CRITICAL) β Router registration, type narrowing
- Route Organization (CRITICAL) β File-based routing, route trees
- Data Loading (HIGH) β Loaders, Query integration
- Search Params (HIGH) β Validation, type inheritance
- Navigation (MEDIUM) β Link component, active states
- Code Splitting (MEDIUM) β Lazy routes, critical path
- Preloading (MEDIUM) β Intent-based preloading
- Route Context (LOW) β Dependency injection
[tanstack-start](./skills/tanstack-start/)
Best practices for full-stack React applications with TanStack Start, including server functions, middleware, SSR, and authentication.
29+ rules across 8 categories:
- Server Functions (CRITICAL) β createServerFn patterns
- Security (CRITICAL) β Input validation, CSRF protection
- Middleware (HIGH) β Request/function middleware
- Authentication (HIGH) β Sessions, route protection
- SSR (MEDIUM) β Hydration safety, streaming
- Error Handling (MEDIUM) β Server errors, redirects
- File Organization (LOW) β Code separation patterns
- Deployment (LOW) β Environment config
[tanstack-integration](./skills/tanstack-integration/)
Best practices for integrating TanStack Query with TanStack Router and TanStack Start together.
13 rules across 4 categories:
- Setup (CRITICAL) β QueryClient context, provider wrapping
- Data Flow (HIGH) β Loader + Query patterns
- Caching (MEDIUM) β Single source of truth
- SSR (LOW) β Dehydration/hydration
Installation
```bash
npx add-skill tanstack-agent-skills
```
Or manually add to your project's .cursor/ or Claude Code configuration.
Usage
Skills activate automatically when AI agents detect relevant contexts:
- Building data-driven React applications
- Setting up routing for React apps
- Creating full-stack applications with SSR
- Implementing authentication flows
- Optimizing data fetching patterns
Skill Format
Each skill follows the [Agent Skills](https://agentskills.io/) standard:
```
skills/
βββ tanstack-query/
β βββ SKILL.md # Main skill instructions
β βββ rules/ # Individual rule files
β βββ qk-array-structure.md
β βββ cache-stale-time.md
β βββ ...
βββ tanstack-router/
β βββ SKILL.md
β βββ rules/
βββ tanstack-start/
β βββ SKILL.md
β βββ rules/
βββ tanstack-integration/
βββ SKILL.md
βββ rules/
```
Rule File Structure
Each rule file contains:
- Priority β CRITICAL, HIGH, MEDIUM, or LOW
- Explanation β Why this pattern matters
- Bad Example β Anti-pattern to avoid with explanation
- Good Example β Recommended implementation
- Context β When to apply or skip the rule
Contributing
Contributions welcome! Please ensure:
- Rules are practical and battle-tested
- Examples are clear and runnable
- Priority levels are appropriate
- Context helps agents decide applicability
Resources
- [TanStack Query Docs](https:/
More from this repository3
Provides AI-guided best practices and coding guidelines for implementing server functions, security, middleware, and full-stack architecture in TanStack Start applications.
Provides AI-guided best practices and rules for optimizing data fetching, caching, mutations, and server state management using TanStack Query in React applications.
Provides AI-guided best practices for seamlessly integrating TanStack Query, Router, and Start across full-stack React applications, ensuring optimal data management and routing patterns.