Use when adding new error messages to React, or seeing "unknown error code" warnings.
npx skills add DeckardGer/tanstack-agent-skills --skill "tanstack-start-best-practices"
Install specific skill from multi-skill repository
# 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.
# SKILL.md
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 | 6 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 logicsf-input-validationβ Always validate server function inputssf-method-selectionβ Choose appropriate HTTP methodsf-error-handlingβ Handle errors in server functionssf-response-headersβ Customize response headers when needed
Security (Prefix: sec-)
sec-validate-inputsβ Validate all user inputs with schemassec-auth-middlewareβ Protect routes with auth middlewaresec-sensitive-dataβ Keep secrets server-side onlysec-csrf-protectionβ Implement CSRF protection for mutations
Middleware (Prefix: mw-)
mw-request-middlewareβ Use request middleware for cross-cutting concernsmw-function-middlewareβ Use function middleware for server functionsmw-context-flowβ Properly pass context through middlewaremw-composabilityβ Compose middleware effectively
Authentication (Prefix: auth-)
auth-session-managementβ Implement secure session handlingauth-route-protectionβ Protect routes with beforeLoadauth-server-functionsβ Verify auth in server functionsauth-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 SSRssr-hydration-safetyβ Prevent hydration mismatchesssr-streamingβ Implement streaming SSR for faster TTFBssr-selectiveβ Apply selective SSR when beneficialssr-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 errorserr-redirectsβ Use redirects appropriatelyerr-not-foundβ Handle not-found scenarios
File Organization (Prefix: file-)
file-separationβ Separate server and client codefile-functions-fileβ Use .functions.ts patternfile-shared-validationβ Share validation schemas
Deployment (Prefix: deploy-)
deploy-env-configβ Configure environment variablesdeploy-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.
# Supported AI Coding Agents
This skill is compatible with the SKILL.md standard and works with all major AI coding agents:
Learn more about the SKILL.md standard and how to use these skills with your preferred AI coding agent.