What problem does it solve? Building authentication, logging, and authorization logic for TanStack Start server functions requires correctly composing middleware chains, passing typed context between client and server, and avoiding security pitfalls like trusting client-sent identifiers. This Skill provides the rules, patterns, and templates to implement middleware correctly. ## Core Features & Use Cases - Middleware Composition: Chain request and server-function middleware with the enforced method order (.middleware() → .validator() → .client() → .server()) and dependency resolution. - Context & Security Patterns: Pass typed context via next({ context }), transfer data with sendContext, and enforce the rule that shape validation is not authorization. - Ready-Made Templates: Copy-paste templates for an auth + permission-based authorization factory and client-side middleware for headers, custom fetch, and telemetry. - Use Case: You need per-function permission checks in a TanStack Start app. Use the authorization factory template to compose an authMiddleware that loads the session from a trusted cookie with a parameterized permission check, then attach it to your createServerFn handlers. ## Quick Start Ask the agent to create an auth middleware with a permission-based authorization factory for your TanStack Start server functions.