Agent skill

Tanstack Router

by Mindrally in Mindrally/skills

Type-safe, file-based routing for React with TanStack Router.

Apache-2.0Auto-check passedDevelopment

Install Tanstack Router

skills CLI
$ npx skills add Mindrally/skills --skill tanstack-router -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install Mindrally/skills tanstack-router --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/Mindrally/skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/tanstack-router .claude/skills/tanstack-router && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
tanstack-router
GitHub stars
267
Token cost
~1.9k tokens
SKILL.md length
649 words
Files
1
Skills in repo
34
Repo updated
First seen
Licence
Apache-2.0

At a glance

Type-safe, file-based routing for React with TanStack Router.

  • Works in 7 steps: Create the route file — Add a file under… → Define the route — Export Route from… → Validate search params — If the route… → …
  • Defining routes with createFileRoute
  • SKILL.md covers Workflow for Adding a New Route, Core Principles, File-Based Route Conventions and Route Definition, plus 7 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

Tanstack Router is an agent skill from Mindrally/skills. Type-safe, file-based routing for React with TanStack Router. Use when defining routes with createFileRoute, validating search params with Zod, writing route loaders, setting up auth guards with beforeLoad, integrating TanStack Query into loaders, or configuring router context and preloading.

Its SKILL.md is about 1.9k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Development, covering Type safety and Forms and validation. It works with TanStack, Zod, React and Vite. The repository describes itself as: 255+ Claude Code skills converted from Cursor rules. Expert coding guidelines for every major framework and language. The licence is Apache-2.0.

When your agent uses it

  • Defining routes with createFileRoute
  • Validating search params with Zod
  • Writing route loaders
  • Setting up auth guards with beforeLoad

Example prompts

  • “/tanstack-router”

Workflow steps

7 steps, taken from the first numbered list in SKILL.md.

  1. Create the route file — Add a file under src/routes/ following the file-based routing convention (see below).
  2. Define the route — Export Route from createFileRoute('/path')({...}) with component, and optionally loader, validateSearch, beforeLoad…
  3. Validate search params — If the route reads query params, define a Zod schema and pass it as validateSearch.
  4. Load data — Fetch data in loader, not in a component useEffect; integrate with TanStack Query via queryClient.ensureQueryData when caching…
  5. Guard access — Add beforeLoad checks (e.g. auth) that throw redirect({ to: '/login' }) when a precondition fails.
  6. Link to the route — Navigate with so the compiler validates params and search at every call site.
  7. Regenerate the route tree — Ensure routeTree.gen.ts is regenerated (automatic under the Vite plugin's dev server / build) before running…

What it can do on your machine

Read from SKILL.md and the folder at commit 9718410. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are typescript).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Tanstack Router loads about 1.9k tokens when it runs. Until then it costs about 77 tokens; SKILL.md has 649 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~77
When it runs · the whole SKILL.md, loaded when a task matches
~1.9k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from Mindrally/skills at commit 9718410, republished under its Apache-2.0 licence (© Mindrally). 649 words, ~1,881 tokens.

Download SKILL.mdSave it as .claude/skills/tanstack-router/SKILL.md (or your agent's skills folder).
name
tanstack-router
description
Type-safe, file-based routing for React with TanStack Router. Use when defining routes with createFileRoute, validating search params with Zod, writing route loaders, setting up auth guards with beforeLoad, integrating TanStack Query into loaders, or configuring router context and preloading.

TanStack Router

TanStack Router is a fully type-safe router for React that treats routes, loaders, params, and search params as first-class typed data rather than untyped strings.

Workflow for Adding a New Route

  1. Create the route file — Add a file under src/routes/ following the file-based routing convention (see below).
  2. Define the route — Export Route from createFileRoute('/path')({...}) with component, and optionally loader, validateSearch, beforeLoad, errorComponent, and pendingComponent.
  3. Validate search params — If the route reads query params, define a Zod schema and pass it as validateSearch.
  4. Load data — Fetch data in loader, not in a component useEffect; integrate with TanStack Query via queryClient.ensureQueryData when caching is needed.
  5. Guard access — Add beforeLoad checks (e.g. auth) that throw redirect({ to: '/login' }) when a precondition fails.
  6. Link to the route — Navigate with <Link to="/path" params={...} search={...}> so the compiler validates params and search at every call site.
  7. Regenerate the route tree — Ensure routeTree.gen.ts is regenerated (automatic under the Vite plugin's dev server / build) before running or building the app.

Core Principles

  • TanStack Router is 100% type-safe — lean on TypeScript generics for params, search params, and loader data instead of manual casting.
  • Prefer file-based routing with @tanstack/router-vite-plugin (or @tanstack/router-plugin/vite) for scalability over manually constructed route trees.
  • Always define routes with createFileRoute (leaf/nested routes) or createRootRoute / createRootRouteWithContext (root).
  • Route data loading belongs in loader functions, not in component useEffect — this enables preloading, parallel loading, and pending/error states.
  • Search params are first-class state — always define their schema with Zod (or another standard-schema validator) so they are typed and validated on every read.

File-Based Route Conventions

src/routes/
  __root.tsx          ← Root layout
  index.tsx           ← / route
  posts/
    index.tsx         ← /posts
    $postId.tsx       ← /posts/:postId (dynamic segment)
    _layout.tsx       ← Layout route (no path segment)
  _auth/               ← Pathless auth layout group
    dashboard.tsx
  • A leading underscore on a segment (_layout, _auth) creates a pathless layout route used purely for grouping/shared UI.
  • A $ prefix ($postId) marks a dynamic path segment, matching Route.useParams().
  • index.tsx inside a folder matches the folder's own path with no additional segment.

Route Definition

tsx
export const Route = createFileRoute('/posts/$postId')({
  loader: async ({ params }) => fetchPost(params.postId),
  component: PostComponent,
  errorComponent: ({ error }) => <ErrorBanner message={error.message} />,
  pendingComponent: () => <PostSkeleton />,
})

function PostComponent() {
  const post = Route.useLoaderData()     // type-safe
  const { postId } = Route.useParams()   // type-safe
  return <div>{post.title}</div>
}
  • errorComponent renders when the loader throws; pendingComponent renders while the loader is in flight (subject to defaultPendingMs).
  • Loader return values and thrown errors are both fully typed and flow into useLoaderData() and errorComponent respectively.

Type-Safe Search Params

  • Always define search params with Zod and validateSearch.
  • Access them with Route.useSearch() — never read window.location.search or URLSearchParams directly, which bypasses type safety and validation.
tsx
const searchSchema = z.object({
  page: z.number().int().min(1).default(1),
  q: z.string().optional(),
})

export const Route = createFileRoute('/search')({
  validateSearch: searchSchema,
  component: SearchPage,
})

function SearchPage() {
  const { page, q } = Route.useSearch()
  const navigate = Route.useNavigate()

  return (
    <button onClick={() => navigate({ search: (prev) => ({ ...prev, page: page + 1 }) })}>
      Next page
    </button>
  )
}

Navigation

  • Use <Link> for internal navigation — never a raw <a href>, which triggers a full page reload and loses client-side routing state.
  • Always pass typed params and search; the TypeScript compiler catches missing or mistyped route params at build time.
tsx
<Link to="/posts/$postId" params={{ postId: '123' }}>View Post</Link>
<Link to="/search" search={{ page: 1, q: 'react' }}>Search</Link>
Show full SKILL.md (241 more words)Show less

Loaders + TanStack Query Integration

  • Put the QueryClient in router context so loaders can prefetch and cache through TanStack Query rather than duplicating fetch logic.
  • Use ensureQueryData (not fetchQuery) in loaders so an already-cached query is reused instead of refetched.
tsx
export const Route = createFileRoute('/posts')({
  loader: ({ context: { queryClient } }) =>
    queryClient.ensureQueryData(postsQueryOptions()),
  component: PostsPage,
})

function PostsPage() {
  const { data: posts } = useSuspenseQuery(postsQueryOptions())
  return <PostList posts={posts} />
}

Router Context for Dependency Injection

tsx
// __root.tsx
interface RouterContext {
  queryClient: QueryClient
  auth: AuthState
}

export const Route = createRootRouteWithContext<RouterContext>()({
  component: RootLayout,
})

// main.tsx
const router = createRouter({ routeTree, context: { queryClient, auth } })
  • Router context flows down to every route's loader and beforeLoad via the context argument, giving each route typed access to shared dependencies without prop drilling or global singletons.

Auth Guards

tsx
export const Route = createFileRoute('/_auth/dashboard')({
  beforeLoad: ({ context }) => {
    if (!context.auth.isAuthenticated) throw redirect({ to: '/login' })
  },
  component: Dashboard,
})
  • beforeLoad runs before the loader and before the component renders, making it the right place for auth checks, feature flag gates, and redirects.
  • Prefer throw redirect(...) over imperative navigation inside components — it works during SSR, preloading, and client navigation alike.

Performance

  • Set defaultPreload: 'intent' on the router so links prefetch their route's data on hover/focus, making navigation feel instant.
  • Use React.lazy (or the router's built-in code-splitting via .lazy() route files) for route component code splitting on large apps.
  • Install @tanstack/router-devtools and render <TanStackRouterDevtools /> in development to inspect route matches, pending states, and cache.

Common Mistakes

  • Fetching data with useEffect inside a route component instead of a loader, which loses preloading and creates render-then-fetch waterfalls.
  • Reading raw window.location.search instead of Route.useSearch(), bypassing the search param schema and type safety.
  • Performing auth checks only inside components (useEffect redirect) instead of beforeLoad, allowing a flash of protected content before redirecting.
  • Forgetting to add new route params/search fields to <Link> call sites — let the compiler catch it rather than testing manually.

© Mindrally, Apache-2.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in tanstack-router of Mindrally/skills.

Open the folder on GitHubat commit 9718410

Compare with similar skills

Tanstack Router next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Tanstack Router compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Tanstack Router this skillMindrally/skills267—~1.9kAutomated safety check: PassApache-2.0
Olore Tanstack Form Latestolorehq/olore103—~1.1kAutomated safety check: PassMIT
Tanstack Routersecondsky/claude-skills227—~1.9kAutomated safety check: NotesMIT
Wagmi Feature Developmentwevm/wagmi6.8k—~3.8kAutomated safety check: PassMIT
Zodjasonjgardner/blockbench-mcp-plugin4883 repos~1.4kAutomated safety check: PassGPL-3.0
Buzzformbuildnbuzz/buzzform101—~1.5kAutomated safety check: PassMIT

Similar skills

  • Local TanStack Form documentation reference (latest, v1.33.5).

    103 GitHub stars~1.1k tokensUpdated today
    MobileAuto-check passed
  • Tanstack Router

    secondsky/claude-skills

    TanStack Router type-safe file-based routing for React. An agent skill from secondsky/claude-skills.

    227 GitHub stars~1.9k tokensUpdated 9 days ago
    DevelopmentAuto-check: notes
  • Walks through adding a Wagmi feature across its layers: a Viem-based core action, TanStack Query options, and React and Vue bindings.

    6.8k GitHub stars~3.8k tokensUpdated 6 days ago
    DevelopmentAuto-check passed
  • Zod

    jasonjgardner/blockbench-mcp-plugin

    Zod schema validation best practices for type safety, parsing, and error handling.

    488 GitHub starsUsed in 3 repos~1.4k tokens
    DevelopmentAuto-check passed
  • Buzzform

    buildnbuzz/buzzform

    A skill your agent uses when working with BuzzForm schema-driven forms, @buildnbuzz/form-core, @buildnbuzz/form-react, or any related APIs like defineSchema, InferType, FormProvider, useDataField…

    101 GitHub stars~1.5k tokensUpdated 4 mo ago
    Frontend & DesignAuto-check passed
  • Sets the conventions for the Opik React frontend: TanStack Query for data, Zustand for shared state, one-way layer imports and a fix for Google Translate crashes.

    22k GitHub stars~1.1k tokensUpdated today
    Frontend & DesignAuto-check passed

More from Mindrally/skills

All 34 skills in this repo
  • Analytics Data Analysis

    Mindrally/skills

    Best practices for analytics, data analysis, and visualization using Python, pandas, matplotlib, seaborn, and Jupyter notebooks.

    267 GitHub stars~1.6k tokensUpdated 1 mo ago
    Auto-check passed
  • Best practices for AutoML and hyperparameter search with Optuna, Ray Tune, and PyCaret, covering search-space design, validation splits, and leakage prevention.

    267 GitHub stars~2.4k tokensUpdated 1 mo ago
    Auto-check passed
  • Blender Python Addon

    Mindrally/skills

    Best practices for writing Blender Python add-ons using the bpy API, covering operators, panels, properties, registration, and API-safe scripting.

    267 GitHub stars~2.2k tokensUpdated 1 mo ago
    Auto-check passed
  • Expert guidelines for Chrome extension development with Manifest V3, covering security, performance, and best practices.

    267 GitHub stars~1.7k tokensUpdated 1 mo ago
    Auto-check passed
  • Clean Code

    Mindrally/skills

    Clean, maintainable, human-readable code principles combined with anti-over-engineering discipline: naming, single responsibility, DRY, and scoping changes to exactly what was requested.

    267 GitHub stars~1.8k tokensUpdated 1 mo ago
    Auto-check passed
  • Design Systems

    Mindrally/skills

    Comprehensive design system guidelines for building consistent, accessible, and scalable component libraries.

    267 GitHub stars~1.8k tokensUpdated 1 mo ago
    Auto-check passed

Questions about Tanstack Router

What does Tanstack Router do?

Type-safe, file-based routing for React with TanStack Router. Tanstack Router is an agent skill from Mindrally/skills. Type-safe, file-based routing for React with TanStack Router.

When should I use Tanstack Router?

Tanstack Router fits situations like: defining routes with createFileRoute; validating search params with Zod; writing route loaders; setting up auth guards with beforeLoad.

How do I install Tanstack Router in Claude Code?

Run `npx skills add Mindrally/skills --skill tanstack-router -a claude-code`. Or copy the skill folder (tanstack-router in Mindrally/skills) into .claude/skills/tanstack-router in your project. Claude Code loads it when a task matches its description.

How do I install Tanstack Router in Codex?

Run `npx skills add Mindrally/skills --skill tanstack-router -a codex`. Or copy the skill folder (tanstack-router in Mindrally/skills) into .agents/skills/tanstack-router in your project. Codex loads it when a task matches its description.

Can I use Tanstack Router in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add Mindrally/skills --skill tanstack-router -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/tanstack-router, .gemini/skills/tanstack-router, .github/skills/tanstack-router and .opencode/skills/tanstack-router in your project.

What does Tanstack Router need to run?

SKILL.md names no scripts, command-line tools or credentials: Tanstack Router is instructions for the agent only.

Does Tanstack Router access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Tanstack Router safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Tanstack Router use?

Tanstack Router is published under the Apache-2.0 licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Tanstack Router use?

About 1.9k tokens (SKILL.md is roughly 7.5k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Tanstack Router?

Skills that share tags, products or a category with Tanstack Router: Olore Tanstack Form Latest (olorehq/olore, 103 stars), Tanstack Router (secondsky/claude-skills, 227 stars), Wagmi Feature Development (wevm/wagmi, 6.8k stars) and Zod (jasonjgardner/blockbench-mcp-plugin, 488 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Tanstack Router?

Mindrally (a GitHub organization) maintains it in Mindrally/skills, which has 267 GitHub stars. The repository holds 34 skills in this directory. The repository was last updated on September 3, 2026.

Source: Mindrally/skills on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.