tanstack-cli
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseOverview
概述
TanStack CLI is an interactive scaffolding tool for creating TanStack Start applications. It provides guided project creation with 30+ pre-built integrations covering authentication, databases, deployment, and developer tools. It also includes an MCP (Model Context Protocol) server for AI agent assistance and supports custom templates for team-standardized setups.
Package:
Status: Stable
@tanstack/cliTanStack CLI 是一款用于创建 TanStack Start 应用的交互式脚手架工具。它提供带引导的项目创建流程,涵盖身份验证、数据库、部署和开发者工具等领域的30+预构建集成。此外,它还包含用于AI Agent辅助的MCP(Model Context Protocol)服务器,并支持自定义模板以实现团队标准化项目配置。
包名:
状态: 稳定版
@tanstack/cliInstallation & Usage
安装与使用
bash
undefinedbash
undefinedCreate a new project (interactive)
创建新项目(交互式)
npx @tanstack/cli create my-app
npx @tanstack/cli create my-app
Create with specific integrations
使用指定集成创建项目
npx @tanstack/cli create my-app --integrations tanstack-query,clerk,drizzle
npx @tanstack/cli create my-app --integrations tanstack-query,clerk,drizzle
Global install
全局安装
npm install -g @tanstack/cli
tanstack create my-app
undefinednpm install -g @tanstack/cli
tanstack create my-app
undefinedProject Creation
项目创建
Interactive Mode
交互式模式
bash
npx @tanstack/cli create my-appbash
npx @tanstack/cli create my-appPrompts for:
会提示以下内容:
- Project name
- 项目名称
- Integration selection
- 集成选择
- Configuration options
- 配置选项
undefinedundefinedWith Integrations Flag
使用集成参数
bash
undefinedbash
undefinedMultiple integrations
多个集成
npx @tanstack/cli create my-app --integrations tanstack-query,tanstack-form,drizzle,neon,clerk
npx @tanstack/cli create my-app --integrations tanstack-query,tanstack-form,drizzle,neon,clerk
Deployment target
指定部署目标
npx @tanstack/cli create my-app --integrations vercel
npx @tanstack/cli create my-app --integrations vercel
Full stack setup
全栈配置
npx @tanstack/cli create my-app --integrations tanstack-query,tanstack-form,tanstack-table,clerk,drizzle,neon,vercel,sentry
undefinednpx @tanstack/cli create my-app --integrations tanstack-query,tanstack-form,tanstack-table,clerk,drizzle,neon,vercel,sentry
undefinedAvailable Integrations
可用集成
TanStack Libraries
TanStack 库
| Integration | Description |
|---|---|
| Async state management |
| Type-safe form management |
| Headless table/datagrid |
| Reactive data store |
| List virtualization |
| AI SDK integration |
| Client-side database |
| Debouncing/throttling utilities |
| 集成 | 描述 |
|---|---|
| 异步状态管理 |
| 类型安全的表单管理 |
| 无表头表格/数据网格 |
| 响应式数据存储 |
| 列表虚拟化 |
| AI SDK 集成 |
| 客户端数据库 |
| 防抖/节流工具 |
Authentication
身份验证
| Integration | Description |
|---|---|
| Clerk authentication |
| Better Auth integration |
| WorkOS identity management |
| 集成 | 描述 |
|---|---|
| Clerk 身份验证 |
| Better Auth 集成 |
| WorkOS 身份管理 |
Databases & ORMs
数据库与ORM
| Integration | Description |
|---|---|
| Drizzle ORM |
| Prisma ORM |
| Neon serverless Postgres |
| Convex backend platform |
| 集成 | 描述 |
|---|---|
| Drizzle ORM |
| Prisma ORM |
| Neon 无服务器Postgres |
| Convex 后端平台 |
Deployment
部署
| Integration | Description |
|---|---|
| Vercel deployment |
| Netlify deployment |
| Cloudflare Workers/Pages |
| Nitro server engine |
| 集成 | 描述 |
|---|---|
| Vercel 部署 |
| Netlify 部署 |
| Cloudflare Workers/Pages |
| Nitro 服务器引擎 |
Developer Tools
开发者工具
| Integration | Description |
|---|---|
| ESLint configuration |
| Biome linting/formatting |
| shadcn/ui component library |
| Storybook component development |
| 集成 | 描述 |
|---|---|
| ESLint 配置 |
| Biome 代码检查/格式化 |
| shadcn/ui 组件库 |
| Storybook 组件开发 |
API & Backend
API 与后端
| Integration | Description |
|---|---|
| tRPC type-safe API |
| oRPC integration |
| 集成 | 描述 |
|---|---|
| tRPC 类型安全API |
| oRPC 集成 |
Services
服务
| Integration | Description |
|---|---|
| Error monitoring |
| Internationalization (i18n) |
| Strapi CMS |
| 集成 | 描述 |
|---|---|
| 错误监控 |
| 国际化(i18n) |
| Strapi CMS |
Custom Templates
自定义模板
Creating a Template
创建模板
bash
undefinedbash
undefinedCreate a project as a template base
创建项目作为模板基础
npx @tanstack/cli create my-template --integrations tanstack-query,drizzle,clerk
npx @tanstack/cli create my-template --integrations tanstack-query,drizzle,clerk
Share as a git repository or npm package
作为Git仓库或npm包分享
undefinedundefinedUsing a Custom Template
使用自定义模板
bash
undefinedbash
undefinedFrom git repository
从Git仓库导入
npx @tanstack/cli create my-app --template https://github.com/myorg/my-template
npx @tanstack/cli create my-app --template https://github.com/myorg/my-template
From local path
从本地路径导入
npx @tanstack/cli create my-app --template ./templates/my-template
undefinednpx @tanstack/cli create my-app --template ./templates/my-template
undefinedTemplate Structure
模板结构
my-template/
├── template.config.ts # Template configuration
├── src/
│ ├── app/
│ │ ├── routes/
│ │ └── components/
│ └── lib/
├── package.json
├── tsconfig.json
├── app.config.ts
└── vite.config.tsmy-template/
├── template.config.ts # 模板配置文件
├── src/
│ ├── app/
│ │ ├── routes/
│ │ └── components/
│ └── lib/
├── package.json
├── tsconfig.json
├── app.config.ts
└── vite.config.tsMCP Server
MCP 服务器
The TanStack CLI includes an MCP (Model Context Protocol) server for AI agent integration.
TanStack CLI 包含用于AI Agent集成的MCP(Model Context Protocol)服务器。
Capabilities
功能
- Documentation Search - AI agents can query TanStack documentation
- Project Scaffolding - Guided project creation through AI assistants
- Integration Discovery - Search and recommend integrations
- Deployment Guidance - Platform-specific deployment help
- 文档搜索 - AI Agent 可查询 TanStack 文档
- 项目脚手架 - 通过AI助手引导完成项目创建
- 集成发现 - 搜索并推荐合适的集成
- 部署指导 - 针对特定平台的部署帮助
Usage with Claude
与 Claude 配合使用
The MCP server enables Claude and other AI assistants to:
- Search TanStack docs for accurate, up-to-date information
- Help scaffold new projects with appropriate integrations
- Provide context-aware recommendations
- Assist with configuration and deployment
MCP 服务器支持 Claude 及其他AI助手:
- 搜索 TanStack 文档以获取准确、实时的信息
- 协助搭建包含合适集成的新项目
- 提供上下文感知的推荐建议
- 协助完成配置与部署工作
Configuration
配置
json
// .claude/mcp.json or equivalent
{
"mcpServers": {
"tanstack": {
"command": "npx",
"args": ["@tanstack/cli", "mcp"]
}
}
}json
// .claude/mcp.json 或等效文件
{
"mcpServers": {
"tanstack": {
"command": "npx",
"args": ["@tanstack/cli", "mcp"]
}
}
}Generated Project Structure
生成的项目结构
A typical generated project looks like:
my-app/
├── src/
│ ├── app/
│ │ ├── routes/
│ │ │ ├── __root.tsx
│ │ │ └── index.tsx
│ │ ├── router.tsx
│ │ ├── routeTree.gen.ts
│ │ └── client.tsx
│ ├── lib/
│ │ ├── db.ts # (if drizzle/prisma)
│ │ ├── auth.ts # (if clerk/better-auth)
│ │ └── query.ts # (if tanstack-query)
│ └── components/
├── app.config.ts
├── vite.config.ts
├── package.json
├── tsconfig.json
└── .env.example典型的生成项目结构如下:
my-app/
├── src/
│ ├── app/
│ │ ├── routes/
│ │ │ ├── __root.tsx
│ │ │ └── index.tsx
│ │ ├── router.tsx
│ │ ├── routeTree.gen.ts
│ │ └── client.tsx
│ ├── lib/
│ │ ├── db.ts # (如果使用drizzle/prisma)
│ │ ├── auth.ts # (如果使用clerk/better-auth)
│ │ └── query.ts # (如果使用tanstack-query)
│ └── components/
├── app.config.ts
├── vite.config.ts
├── package.json
├── tsconfig.json
└── .env.exampleWeb Builder Interface
Web 构建器界面
TanStack CLI also provides an interactive web-based builder:
- Visual technology stack selection
- Preview generated files before exporting
- Integration compatibility checking
- One-click project generation
TanStack CLI 还提供交互式的基于Web的构建器:
- 可视化技术栈选择
- 导出前预览生成的文件
- 集成兼容性检查
- 一键生成项目
CLI Commands Reference
CLI 命令参考
| Command | Description |
|---|---|
| Create a new project |
| Create with specific integrations |
| Create from template |
| Start the MCP server |
| 命令 | 描述 |
|---|---|
| 创建新项目 |
| 使用指定集成创建项目 |
| 从模板创建项目 |
| 启动MCP服务器 |
Best Practices
最佳实践
- Start with minimal integrations - add more as needed rather than including everything upfront
- Use the flag for reproducible project creation in CI/docs
--integrations - Create team templates for consistent project structure across your organization
- Use the MCP server with AI assistants for guided setup
- Check after generation for required environment variables
.env.example - Review generated code before adding business logic - understand the scaffold
- Use deployment integrations to pre-configure hosting platform settings
- Combine auth + db integrations for full-stack auth scaffolding (e.g., )
clerk,drizzle,neon
- 从最少集成开始 - 按需添加集成,而非一开始就包含所有内容
- 使用参数 - 在CI/文档中实现可复现的项目创建
--integrations - 创建团队模板 - 确保组织内项目结构的一致性
- 搭配MCP服务器与AI助手 - 获得引导式的项目设置体验
- 生成后查看- 了解所需的环境变量
.env.example - 添加业务逻辑前审阅生成的代码 - 理解脚手架的结构
- 使用部署集成 - 预配置托管平台的设置
- 组合身份验证+数据库集成 - 搭建全栈身份验证脚手架(例如)
clerk,drizzle,neon
Common Pitfalls
常见陷阱
- Not setting up environment variables after project creation (check )
.env.example - Selecting incompatible integration combinations
- Not running /
npm installafter generationpnpm install - Forgetting to initialize the database when using Drizzle/Prisma integrations
- Not configuring the deployment platform's environment variables
- Using outdated CLI version (always use for latest)
npx @tanstack/cli
- 项目创建后未设置环境变量(查看)
.env.example - 选择了不兼容的集成组合
- 生成项目后未运行/
npm installpnpm install - 使用Drizzle/Prisma集成时忘记初始化数据库
- 未配置部署平台的环境变量
- 使用过时的CLI版本(始终使用获取最新版本)
npx @tanstack/cli