Skip to main content
skill CX Codex

tanstack-start-best-practices — Claude Code skill: how to install

Best practice rules for full-stack React apps built with TanStack Start. Guides server functions, middleware, and session security.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add DeckardGer/tanstack-agent-skills --skill tanstack-start-best-practices -a claude-code
npx skills add DeckardGer/tanstack-agent-skills --skill tanstack-start -a claude-code
Open on GitHub

What tanstack-start-best-practices does

A curated set of conventions for full-stack React applications built with TanStack Start. The skill guides data mutations with createServerFn and route guards using the beforeLoad hook. It also addresses hydration mismatches.

Rules include clear explanations alongside good and bad code examples. The guidelines cover critical areas like schema validation and cookie security, down to file separation using .functions.ts and deployment adapters.

Because the guidance relies directly on TanStack Start primitives, using it in a plain client-side SPA creates needless overhead.

What it helps with

  • implement server functions with schema validation using createServerFn
  • protect routes and manage user sessions with middleware
  • prevent hydration mismatches and configure streaming SSR
  • separate server and client code using .functions.ts files

Example prompts for the agent

  • Review this server function against TanStack Start patterns and add input validation
  • Set up auth middleware using the beforeLoad hook for protected routes
  • Configure streaming SSR and static prerendering for this route

How to install tanstack-start-best-practices

1Skills CLI (Vercel)

npx skills add DeckardGer/tanstack-agent-skills --skill tanstack-start-best-practices -a claude-code
npx skills add DeckardGer/tanstack-agent-skills --skill tanstack-start -a claude-code

2Manually: put the files in place

~/.claude/skills/tanstack-start/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/tanstack-start/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about tanstack-start-best-practices

How do I install tanstack-start-best-practices in Claude Code?

Run npx skills add DeckardGer/tanstack-agent-skills --skill tanstack-start-best-practices -a claude-code in your terminal.

What does tanstack-start-best-practices do?

It provides coding rules for server functions, auth middleware, SSR hydration safety, and full-stack project structure in TanStack Start.

How does the skill recommend organizing server code?

It advises separating client and server code by isolating server logic into dedicated .functions.ts files.

Source text

SKILL.md · MIT
---
name: tanstack-start-best-practices
description: TanStack Start best practices for full-stack React applications. Server functions, middleware, SSR, authentication, and deployment patterns. Activate when building full-stack apps with TanStack Start.
---

# TanStack Start Best Practices

Comprehensive guidelines for implementing TanStack Start patterns in full-stack React applications. These rules cover server functions, middleware, SSR, authentication, and deployment.

## When to Apply

- Creating server functions for data mutations
- Setting up middleware for auth/logging
- Configuring SSR and hydration
- Implementing authentication flows
- Handling errors across client/server boundary
- Organizing full-stack code
- Deploying to various platforms

## Rule Categories by Priority

| Priority | Category | Rules | Impact |
|----------|----------|-------|--------|
| CRITICAL | Server Functions | 5 rules | Core data mutation patterns |
| CRITICAL | Security | 4 rules | Prevents vulnerabilities |
| HIGH | Middleware | 4 rules | Request/response handling |
| HIGH | Authentication | 4 rules | Secure user sessions |
| MEDIUM | API Routes | 1 rule | External endpoint patterns |
| MEDIUM | SSR | 5 rules | Server rendering patterns |
| MEDIUM | Error Handling | 3 rules | Graceful failure handling |
| MEDIUM | Environment | 1 rule | Configuration management |
| LOW | File Organization | 3 rules | Maintainable code structure |
| LOW | Deployment | 2 rules | Production readiness |

## Quick Reference

### Server Functions (Prefix: `sf-`)

- `sf-create-server-fn` — Use createServerFn for server-side logic
- `sf-input-validation` — Always validate server function inputs
- `sf-method-selection` — Choose appropriate HTTP method
- `sf-error-handling` — Handle errors in server functions
- `sf-response-headers` — Customize response headers when needed

### Security (Prefix: `sec-`)

- `sec-validate-inputs` — Validate all user inputs with schemas
- `sec-auth-middleware` — Protect routes with auth middleware
- `sec-sensitive-data` — Keep secrets server-side only
- `sec-csrf-protection` — Implement CSRF protection for mutations

### Middleware (Prefix: `mw-`)

- `mw-request-middleware` — Use request middleware for cross-cutting concerns
- `mw-function-middleware` — Use function middleware for server functions
- `mw-context-flow` — Properly pass context through middleware
- `mw-composability` — Compose middleware effectively

### Authentication (Prefix: `auth-`)

- `auth-session-management` — Implement secure session handling
- `auth-route-protection` — Protect routes with beforeLoad
- `auth-server-functions` — Verify auth in server functions
- `auth-cookie-security` — Configure secure cookie settings

### API Routes (Prefix: `api-`)

- `api-routes` — Create API routes for external consumers

### SSR (Prefix: `ssr-`)

- `ssr-data-loading` — Load data appropriately for SSR
- `ssr-hydration-safety` — Prevent hydration mismatches
- `ssr-streaming` — Implement streaming SSR for faster TTFB
- `ssr-selective` — Apply selective SSR when beneficial
- `ssr-prerender` — Configure static prerendering and ISR

### Environment (Prefix: `env-`)

- `env-functions` — Use environment functions for configuration

### Error Handling (Prefix: `err-`)

- `err-server-errors` — Handle server function errors
- `err-redirects` — Use redirects appropriately
- `err-not-found` — Handle not-found scenarios

### File Organization (Prefix: `file-`)

- `file-separation` — Separate server and client code
- `file-functions-file` — Use .functions.ts pattern
- `file-shared-validation` — Share validation schemas

### Deployment (Prefix: `deploy-`)

- `deploy-env-config` — Configure environment variables
- `deploy-adapters` — Choose appropriate deployment adapter

## How to Use

Each rule file in the `rules/` directory contains:
1. **Explanation** — Why this pattern matters
2. **Bad Example** — Anti-pattern to avoid
3. **Good Example** — Recommended implementation
4. **Context** — When to apply or skip this rule

## Full Reference

See individual rule files in `rules/` directory for detailed guidance and code examples.

© DeckardGer · MIT · DeckardGer/tanstack-agent-skills

Similar skills

Everything for Frontend and UI →

From the same set3

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