Skip to main content
skill Claude Code CX Codex Cursor GitHub Copilot

router-core — Claude Code skill: what it does, how to install

Entry skill for TanStack Router that points a task at the right sub-skill and pins the type-inference and client-first rules agents keep breaking.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add TanStack/router --skill router-core -a claude-code
Open on GitHub

What router-core does

The skill is the entry point to the TanStack Router set. It sorts a task into one sub-skill: search params, path params, navigation, data loading, auth guards, code splitting, 404 and errors, type safety, SSR. A table and a decision tree do that work, so the agent opens a single file. A second sub-skill comes in only when a task genuinely crosses a boundary, such as an authenticated loader that needs both auth-and-guards and data-loading.

The core is framework-agnostic; React and Solid bindings sit on top. Two rules come with it. Router types are inferred end to end, so casts and hand-written annotations break things fast. Loaders run on the client by default rather than server-only as in Next.js or Remix, and the APIs are not interchangeable. The skill also states that the createFileRoute path string belongs to the plugin, not to your editor.

It is written for @tanstack/router-core v1.171.15, where splats use $ and the * alias disappears in v2. A checklist covers route refactors and response schema changes: rename the file, regenerate routeTree.gen.ts, fix links, then run a production build, because typecheck alone proves little. The Register declaration is what keeps links typed. Drop it and Link and useNavigate go quiet, which is a reason to wire it up on day one instead of hunting empty autocomplete later.

What it helps with

  • pick the right sub-skill for a routing task
  • wire up Register so Link and useNavigate autocomplete again
  • regenerate routeTree.gen.ts after moving a route file
  • catch a createFileRoute path that drifted from its file location
  • settle whether loaders run on the client or the server

Example prompts for the agent

  • Set up TanStack Router: add `__root.tsx`, a `/posts/$postId` route and `createRouter` with `routeTree`
  • Autocomplete is dead in `Link` — check the `Register` block using the router-core skill
  • I renamed a route file, regenerate `routeTree.gen.ts` and update the links

How to install router-core

1Skills CLI (Vercel)

npx skills add TanStack/router --skill router-core -a claude-code

2Manually: put the files in place

~/.claude/skills/router-core/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/router-core/

From the same set2

The whole set →

Similar

cli-anything-anygen HKUDS Provides a CLI wrapper around the AnyGen OpenAPI to build slides and diagrams. Useful when automating document workflows in AI agents. Claude Code CX Codex Cursor +1 465installs architect backnotprop Sketches types, signatures, and module boundaries before coding to prevent locking in the wrong shape on non-trivial tasks. Claude Code CX Codex Cursor +1 5,300installs arena backnotprop Runs several parallel attempts at the same task, scores them against a rubric, then grafts the best pieces of the losers into the winning base. Claude Code CX Codex Cursor +1 5,300installs figure-it-out backnotprop A skill for work with no ready-made playbook: it designs the plan and a pass/fail predicate first, then runs a hypothesis loop and keeps a decision trail the reviewer can read. Claude Code CX Codex Cursor +1 5,100installs gpt-image wuyoscar Type a prompt, get an image file back. The skill resolves the model first, then runs a packaged CLI for generation, reference edits or inpainting. Claude Code CX Codex Cursor +1 553installs principle-redesign-from-first-principles backnotprop A skill that makes the agent rebuild an existing design as if the new requirement had been there from day one. Use it when a change ripples through types, docs, and examples. Claude Code CX Codex Cursor +1 5,000installs setup-matt-pocock-skills Matt Pocock This skill configures a repository for Matt Pocock's engineering skills by setting its issue tracker, triage labels, and domain docs layout. Run it before using the other skills. Claude Code 1,052,851installs to-tickets Matt Pocock Turns a plan, spec, or conversation into small end-to-end tickets with explicit blockers. Use it to agree on the work breakdown before tickets go to a tracker. Claude Code 711,230installs

Questions about router-core

How do I install router-core in Claude Code?

Run npx skills add TanStack/router --skill router-core -a claude-code. The skill lands at ~/.claude/skills/router-core/SKILL.md.

What does router-core do?

It is the entry point to the TanStack Router skills. It tells the agent which sub-skill to load for a given task and repeats the ground rules: types are inferred, loaders are client-first.

Does the skill work for a Next.js or React Router project?

No, it covers TanStack Router only. Loaders here run on the client by default instead of the server as in Next.js or Remix, so those APIs do not carry over.

Source text

SKILL.md · MIT
---
name: router-core
description: >-
  Framework-agnostic core concepts for TanStack Router: route trees,
  createRouter, createRoute, createRootRoute, createRootRouteWithContext,
  addChildren, Register type declaration, route matching, route sorting,
  file naming conventions. Entry point for all router skills.
metadata:
  type: core
  library: tanstack-router
  library_version: '1.171.15'
---

# TanStack Router Core

TanStack Router is a type-safe router for React and Solid with built-in SWR caching, JSON-first search params, file-based route generation, and end-to-end type inference. The core is framework-agnostic; React and Solid bindings layer on top.

> **CRITICAL**: TanStack Router types are FULLY INFERRED. Never cast, never annotate inferred values. This is the #1 AI agent mistake.

> **CRITICAL**: TanStack Router is CLIENT-FIRST. Loaders run on the client by default, NOT server-only like Remix/Next.js. Do not confuse TanStack Router APIs with Next.js or React Router.

Use this entry skill to choose one primary sub-skill. Do not load the full catalog. Load a second sub-skill only when the task crosses a real boundary, such as an authenticated loader that needs both `auth-and-guards` and `data-loading`.

## Sub-Skills

| Task                                               | Sub-Skill                                                                    |
| -------------------------------------------------- | ---------------------------------------------------------------------------- |
| Validate, read, write, transform search params     | [router-core/search-params/SKILL.md](./search-params/SKILL.md)               |
| Dynamic segments, splats, optional params          | [router-core/path-params/SKILL.md](./path-params/SKILL.md)                   |
| Link, useNavigate, preloading, blocking            | [router-core/navigation/SKILL.md](./navigation/SKILL.md)                     |
| Route loaders, SWR caching, context, deferred data | [router-core/data-loading/SKILL.md](./data-loading/SKILL.md)                 |
| Auth guards, RBAC, beforeLoad redirects            | [router-core/auth-and-guards/SKILL.md](./auth-and-guards/SKILL.md)           |
| Automatic and manual code splitting                | [router-core/code-splitting/SKILL.md](./code-splitting/SKILL.md)             |
| 404 handling, error boundaries, notFound()         | [router-core/not-found-and-errors/SKILL.md](./not-found-and-errors/SKILL.md) |
| Inference, Register, from narrowing, TS perf       | [router-core/type-safety/SKILL.md](./type-safety/SKILL.md)                   |
| Streaming/non-streaming SSR, hydration, head mgmt  | [router-core/ssr/SKILL.md](./ssr/SKILL.md)                                   |

## Quick Decision Tree

```
Need to add/read/write URL query parameters?
  → router-core/search-params

Need dynamic URL segments like /posts/$postId?
  → router-core/path-params

Need to create links or navigate programmatically?
  → router-core/navigation

Need to fetch data for a route?
  Is it client-side only or client+server?
    → router-core/data-loading
  Using TanStack Query as external cache?
    → compositions/router-query (separate skill)

Need to protect routes behind auth?
  → router-core/auth-and-guards

Need to reduce bundle size per route?
  → router-core/code-splitting

Need custom 404 or error handling?
  → router-core/not-found-and-errors

Having TypeScript issues or performance problems?
  → router-core/type-safety

Need server-side rendering?
  → router-core/ssr
```

## Cross-Cutting Completion Checks

For route refactors:

1. Rename or move the route file; do not hand-edit the generated `createFileRoute` path.
2. Regenerate `routeTree.gen.ts` with the configured Router plugin or CLI.
3. Update links, redirects, `from` narrowing, params, and tests that reference the old route.
4. Run type tests and a production build. A typecheck alone does not prove route generation or bundling works.

For response schema changes:

1. Update the source model and shared validation schema.
2. Update the server function or API serializer so the field exists at runtime.
3. Update loader and component consumers without casts.
4. Assert the actual response payload in a unit or integration test. Typechecking cannot catch a serializer that omits the new field.

## Minimal Working Example

```tsx
// src/routes/__root.tsx
import { createRootRoute, Outlet } from '@tanstack/react-router'

export const Route = createRootRoute({
  component: () => <Outlet />,
})
```

```tsx
// src/routes/index.tsx
import { createFileRoute } from '@tanstack/react-router'

export const Route = createFileRoute('/')({
  component: () => <h1>Home</h1>,
})
```

```tsx
// src/router.tsx
import { createRouter } from '@tanstack/react-router'
import { routeTree } from './routeTree.gen'

const router = createRouter({ routeTree })

// REQUIRED for type safety — without this, Link/useNavigate have no autocomplete
declare module '@tanstack/react-router' {
  interface Register {
    router: typeof router
  }
}

export default router
```

```tsx
// src/main.tsx
import { RouterProvider } from '@tanstack/react-router'
import router from './router'

function App() {
  return <RouterProvider router={router} />
}
```

## Common Mistakes

### HIGH: createFileRoute path string must match the file path

The Vite plugin manages the path string in `createFileRoute`. Do not change it manually — it must match the file's location under `src/routes/`:

```tsx
// File: src/routes/posts/$postId.tsx
export const Route = createFileRoute('/posts/$postId')({
  // ✅ matches file path
  component: PostPage,
})

export const Route = createFileRoute('/post/$postId')({
  // ❌ silent mismatch
  component: PostPage,
})
```

The plugin auto-generates this string. If you rename a route file, the plugin updates it. Never edit the path string by hand.

## Version Note

This skill targets `@tanstack/router-core` v1.171.15. Splat routes use `$` (not `*`); the `*` compat alias will be removed in v2.

© TanStack · MIT · TanStack/router

See also

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor