Cursor TanStack 编码规范

Model: qwen-max | ¥0.15/call
AI工具GPT-4.1智能助手CursorTanStack

Cursor TanStack 编码规范:来自 PatrickJS/awesome-cursorrules (40k stars) 的 tan,适用于各类文档与内容的智能化处理。

Calls: 1

Skill Documentation

Cursor TanStack 编码规范

摘要

Cursor TanStack 编码规范:来自 PatrickJS/awesome-cursorrules (40k stars) 的 tan,适用于各类文档与内容的智能化处理。

**文件来源:** PatrickJS/awesome-cursorrules → `rules/tanstack-start-cursorrules-prompt-file.mdc`

**原仓库:** https://github.com/PatrickJS/awesome-cursorrules

**评分:** ⭐ 仓库 40k stars (社区最权威 Cursor rules 合集)

这个 skill 是干什么的?

把 `tanstack-start-cursorrules-prompt-file.mdc` 这条 Cursor 编码规则打包成可调用的 AI skill,帮你把代码生成统一到一致的标准上。

> Cursor rules for TanStack Start full-stack React framework including server functions, API routes, streaming with defer(), SSR, and multi-platform deployment.

🤖 Agent 使用说明

👤 用户需要做什么?

适用场景

原始规则内容

globs: **/*
alwaysApply: false
---
You are an expert in TanStack Start, TanStack Router, React, TypeScript, Vinxi, and full-stack type-safe web applications.

# TanStack Start Guidelines

## What is TanStack Start
TanStack Start is a full-stack React framework built on top of TanStack Router and Vinxi (Vite + Nitro). It provides SSR, streaming, server functions, and API routes with end-to-end type safety.

## Core Principles
- TanStack Start is file-based routing via TanStack Router — all routing conventions apply
- Server Functions (`createServerFn`) are the primary way to run server-side logic
- Full-stack type safety: server function inputs/outputs are typed end-to-end
- Streaming and Suspense are first-class — use them for progressive rendering
- Start is NOT an API-first framework — server functions replace REST endpoints for most use cases

## Project Structure

src/

routes/

__root.tsx ← Root layout with HTML shell

index.tsx ← Home route

posts/

index.tsx

$postId.tsx

server/

functions/ ← Server functions (recommended organization)

posts.ts

auth.ts

lib/

db.ts ← Database client

auth.ts ← Auth utilities

app.config.ts ← TanStack Start / Vinxi config


## app.config.ts

import { defineConfig } from '@tanstack/start/config'

import tsConfigPaths from 'vite-tsconfig-paths'

export default defineConfig({

vite: {

plugins: [tsConfigPaths()],

},

server: {

preset: 'node-server', // or 'vercel', 'netlify', 'bun', 'cloudflare-pages'

},

})


## Root Route Setup

// src/routes/__root.tsx

import { createRootRoute, ScrollRestoration, Scripts, Outlet } from '@tanstack/react-router'

import { ReactQueryDevtools } from '@tanstack/react-query-devtools'

import { TanStackRouterDevtools } from '@tanstack/router-devtools'

export const Route = createRootRoute({

component: RootComponent,

})

function RootComponent() {

return (

<html lang="en">

<head />

<body>

<Outlet />

<ScrollRestoration />

<Scripts />

{process.env.NODE_ENV === 'development' && (

<>

<TanStackRouterDevtools />

<ReactQueryDevtools />

</>

)}

</body>

</html>

)

}


## Server Functions
- Use `createServerFn` to define functions that always run on the server
- Validate inputs with Zod using `.validator()`
- Use `.handler()` for the implementation
- Server functions are called like regular async functions from components or loaders

// src/server/functions/posts.ts

import { createServerFn } from '@tanstack/start'

import { z } from 'zod'

export const getPost = createServerFn()

.validator(z.object({ id: z.string() }))

.handler(async ({ data }) => {

const post = await db.post.findUnique({ where: { id: data.id } })

if (!post) throw new Error('Post not found')

return post

})

export const createPost = createServerFn()

.va

...(完整内容在原仓库)...


## 数据来源

- 仓库: PatrickJS/awesome-cursorrules (40,581 stars, 257 个 .mdc 规则)
- 抓取时间: 2026-08-17
- License: 跟随原仓库(MIT)

## 联系方式

有问题或建议,在本 skill 下留言。

FAQ

这个 skill 是干什么的?

把 `tanstack-start-cursorrules-prompt-file.mdc` 这条 Cursor 编码规则打包成可调用的 AI skill,帮你把代码生成统一到一致的标准上。

> Cursor rules for TanStack Start full-stack React framework including server functions, API routes, streaming with defer(), SSR, and multi-platform deployment.

👤 用户需要做什么?
  • [ ] 知道这条规则适合用在什么场景(参考下面"适用场景")
  • [ ] 把规则原文内容应用到 IDE 项目的 `.cursor/rules/` 目录(直接复制 .mdc 文件)
  • [ ] 调本 skill 时说清楚你的代码任务(语言/框架/目标)
  • [ ] 输出后人工 review 风格是否符合预期