tanstack-start-optimizer
Skill1 starsChanged 8 days agoMITView on GitHub
Audit and optimize TanStack Start apps (Start 1.x with TanStack Router, Vite 8 or Rsbuild, React 18/19) for route-loader waterfalls and over-fetching, router cache and preload settings, server-function boundaries/auth/validation, SSR vs data-only vs SPA vs prerender choices, code splitting and bundle size, deployment cold starts, and Core Web Vitals, with real before/after measurement. Always produces a written findings report and a fix plan for approval before touching code. Use this whenever the user mentions a slow TanStack Start app, route loaders or beforeLoad, staleTime/preload/invalidate, createServerFn, server routes, SSR or data-only rendering, SPA mode, prerender, autoCodeSplitting, TanStack Query SSR, hydration mismatches, Vite 8/Rsbuild, Cloudflare/Nitro deployment, or upgrading from the Vinxi/beta era -- even if they never say "audit" or "optimize".
In this repository44 other files it gives its agents.
- AGENTS.mdAGENTS.md
- architecture-optimizerSkill
- csharp-optimizerSkill
- cpp-optimizerSkill
- c-optimizerSkill
- go-optimizerSkill
- node-service-optimizerSkill
- ruby-optimizerSkill
- rust-optimizerSkill
- docker-optimizerSkill
- kubernetes-optimizerSkill
- terraform-optimizerSkill
- animate-cssSkill
- animejsSkill
- auto-animateSkill
- gsapSkill
- lenisSkill
- magicuiSkill
- motionSkill
- react-moveSkill
- react-springSkill
- react-three-fiberSkill
- theatrejsSkill
- threejsSkill
- optimizer-routerSkill
- bootstrap-optimizerSkill
- pandacss-optimizerSkill
- sass-scss-optimizerSkill
- stylex-optimizerSkill
- tailwindcss-optimizerSkill
- twind-optimizerSkill
- unocss-optimizerSkill
- vanilla-extract-optimizerSkill
- angular-optimizerSkill
- astro-optimizerSkill
- ui-components-optimizerSkill
- nextjsSkill
- node-optimizerSkill
- nuxt-optimizerSkill
- react-optimizerSkill
- remix-optimizerSkill
- solid-optimizerSkill
- svelte-optimizerSkill
- vue-optimizerSkill
The file
We split this skill into the rules it gives an agent
6 rules. About 0 are common, 2 are distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 15
Run python <skill-dir>/scripts/audit.py <project-root> -- static scan of package.json, vite.config.*, src/start.ts, src/router.tsx, …
- Very specific: line 17
Read references/tooling.md once: what can be measured here (production build, router devtools, bundle analyzer, server timing, load tests).
- Very specific: line 43
Use plan mode: EnterPlanMode (load with ToolSearch if deferred), write the plan, present with ExitPlanMode.
- Distinctive: line 63
Validate every boundary: Search params, server-function input and server-route bodies all cross the network.
- Distinctive: line 66
Code splitting is on, but exports defeat it: Do not export route components/options.
- Very specific: line 68
Docs move: Start v1 (Oct 2026) uses Vite 8, validator() and build plugins.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
TanStack Start Optimizer
Audit a TanStack Start codebase, report what is slow or fragile and why, agree a plan with the user, then fix it. Order: evidence, approval, edits. Start's performance model is route loaders plus selective SSR, and its security model is server functions as public endpoints; changing either silently changes correctness, so nothing is edited before approval.
Workflow
1. Scope (quick)
- Find the root (
package.jsonwith@tanstack/react-start). Record: Start version, TanStack Router version, build tool (Vite 8+/Rsbuild), React 18/19, Node runtime (Start requires >=22.12), rendering mode (SSR by default, selectivessr, SPA, prerender), TanStack Query integration, and deployment target (Nitro/Cloudflare/Netlify/Node). - Run
python <skill-dir>/scripts/audit.py <project-root>-- static scan ofpackage.json,vite.config.*,src/start.ts,src/router.tsx, root/route files and server functions for legacy Vinxi, loader leakage, cache/preload defaults, server-function validation/CSRF, code-splitting blockers and bundle risks, with file:line evidence. Use--jsonto post-process. - Classify the pain: slow initial load (SSR/bundle), slow navigation (loaders/cache), slow mutations (server functions), hydration/CLS, deployment cold start, or code health/security. Ask which hurts if unclear.
- Read
references/tooling.mdonce: what can be measured here (production build, router devtools, bundle analyzer, server timing, load tests).
2. Audit
The script finds cheap leads; you find the rest by reading. Read package.json, vite.config.*, src/router.tsx, src/routes/__root.tsx, the 3-5 routes the user cares about, and the server functions they call. Load only what applies:
| Area | Reference |
| File routes, loaders/beforeLoad, search params, preloading | references/routing-loaders.md |
| Server functions, middleware, auth, server routes, env | references/server-functions.md |
| SSR, selective SSR, SPA mode, prerender, hydration | references/rendering-ssr.md |
| Router cache, staleTime/gcTime, invalidation, TanStack Query | references/data-caching.md |
| Code splitting, bundle size, Vite/Rsbuild, deployment | references/bundle-build.md |
| Auth boundaries, XSS, secrets, types, tests, migrations | references/safety-quality.md |
| Production measurement and honest reporting | references/tooling.md |
Measure, never guess. Build and run the production start command (Nitro/Node output, vite preview for plugin-based hosts, or the Cloudflare preview), then measure that. Record route-level JS, loader timing, SSR TTFB, hydration cost and LCP/INP/CLS. Dev mode and the Vite dev server are not evidence.
Mark each finding Confirmed (build output, network/profiler, code evidence) or Suspected (needs measuring).
3. Report
Fill assets/report-template.md, save it as TANSTACK_START_OPTIMIZATION_REPORT.md in the project root, and show the user. Five-line summary, findings table by impact/effort, then per-finding detail (evidence, why it hurts, fix, risk, behavior impact). Group near-duplicates.
4. Plan -- then stop for approval
Use plan mode: EnterPlanMode (load with ToolSearch if deferred), write the plan, present with ExitPlanMode; if unavailable show it in chat and wait for an explicit "go". Structure:
- Quick wins --
defaultPreload: 'intent', per-routestaleTime, remove fetch-in-effect, parallelize independent loader calls, set body/cache headers, lazy-load heavy widgets, delete dead route exports. Low risk. - Structural -- move data into loaders/server functions, batch N+1 calls with
loaderDeps, split slow routes, choosessr: 'data-only'/falsewhere justified, adopt Query integration with a per-router client, validate search/server input. Name each behavior change. - Heavy -- Vinxi/beta to Vite 8 Start 1.x, Rsbuild adoption, SPA/prerender migration, server-function architecture, framework/RSC adoption. Separately approved. Each step: files touched, expected effect, how to verify, how to roll back.
5. Fix
Only approved items, in small groups. After each: tsc --noEmit, lint, tests, vite build (or rsbuild build), then start the production server. A break must trace to one change. Do not mix a Start/Router/Vite major upgrade with optimization edits. If an approved change moves an auth check out of a server function, exposes server-only code to the client, or changes SSR output, stop and ask.
6. Verify and wrap up
Re-measure the same routes and scenario: route JS (raw/gzip), SSR TTFB, loader duration, navigation time, LCP/INP/CLS, and server-function latency. State plainly what could not be measured. End with deferred items and one suggested next step.
Principles
- Loaders are the data boundary. Fetch in a loader (or server function), not in
useEffect; component fetching creates waterfalls and layout shift. - Loaders are isomorphic. They run on the server for the first request and in the browser on navigation; database, filesystem and secrets belong in
createServerFn. - Server functions are public endpoints. Enforce auth inside the handler or middleware; route
beforeLoadis UX, not a security boundary. - Validate every boundary. Search params, server-function input and server-route bodies all cross the network; use Zod/Standard Schema.
- Cache deliberately. Router
staleTimedefaults to 0 and preload data is fresh for 30s, retained for 5 minutes; set per-route freshness andloaderDeps, and invalidate after mutations. - SSR is per-route. Full SSR by default;
data-onlyfor browser-only markup,falsefor client-only screens, SPA/prerender only with a reason. - Code splitting is on, but exports defeat it. Do not export route components/options; check actual chunks, not the config.
- One QueryClient per router. A module-scope client leaks one user's cache into another user's SSR HTML.
- Docs move. Start v1 (Oct 2026) uses Vite 8,
validator()and build plugins; Vinxi-era advice is stale. Check the installed version.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

