tauri-create
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseTauri 项目创建
Tauri Project Creation
功能概述
Feature Overview
交互式创建 Tauri 跨平台桌面应用项目。引导用户完成模板选择、UI 框架安装、Git 初始化、端口配置等步骤。
Interactively create cross-platform desktop application projects with Tauri. Guide users through steps such as template selection, UI framework installation, Git initialization, and port configuration.
交互方式
Interaction Method
所有询问尽量使用 工具进行交互式问答。
AskUserQuestionAll inquiries should use the tool for interactive Q&A as much as possible.
AskUserQuestion快速创建流程
Quick Creation Process
步骤 1:获取项目信息
Step 1: Get Project Information
检查当前目录:执行 检查当前目录是否为空。
ls -A决定创建位置:
- 当前目录为空:使用 询问用户是在当前目录创建还是创建子目录
AskUserQuestion - 当前目录非空:告知用户将创建子目录
选择模板:使用 询问用户模板选择,默认推荐 。
AskUserQuestionvue-ts| 模板参数 | 技术栈 |
|---|---|
| Vue + TypeScript(推荐) |
| Vue |
| React + TypeScript |
| React |
| Svelte + TypeScript |
| Svelte |
| Vanilla + TypeScript |
| Vanilla JS |
执行创建:
在当前目录创建(空目录):
bash
pnpm create tauri-app . --template <模板> --yes
pnpm install创建子目录:
bash
pnpm create tauri-app <项目名> --template <模板> --yes
cd <项目名>
pnpm installCheck Current Directory: Execute to check if the current directory is empty.
ls -ADetermine Creation Location:
- If the current directory is empty: Use to ask the user whether to create in the current directory or create a subdirectory
AskUserQuestion - If the current directory is not empty: Inform the user that a subdirectory will be created
Select Template: Use to ask the user for template selection, with as the default recommendation.
AskUserQuestionvue-ts| Template Parameter | Tech Stack |
|---|---|
| Vue + TypeScript (Recommended) |
| Vue |
| React + TypeScript |
| React |
| Svelte + TypeScript |
| Svelte |
| Vanilla + TypeScript |
| Vanilla JS |
Execute Creation:
Create in current directory (empty directory):
bash
pnpm create tauri-app . --template <模板> --yes
pnpm installCreate subdirectory:
bash
pnpm create tauri-app <项目名> --template <模板> --yes
cd <项目名>
pnpm install步骤 2:Git 初始化(建议)
Step 2: Git Initialization (Recommended)
检查 Git 状态:执行 检查当前目录是否已是 git 仓库。
git rev-parse --git-dir > /dev/null 2>&1- 如已是 git 仓库:告知用户,跳过初始化,后续步骤会直接提交
- 如非 git 仓库:使用 询问用户是否需要 Git 版本管理
AskUserQuestion
告知后续每步操作都会提交一次 git,记录创建过程。
如需要初始化,立即执行:
bash
git init && git add . && git commit -m "init"Check Git Status: Execute to check if the current directory is already a git repository.
git rev-parse --git-dir > /dev/null 2>&1- If it is already a git repository: Inform the user, skip initialization, and subsequent steps will commit directly
- If it is not a git repository: Use to ask the user if they need Git version control
AskUserQuestion
Inform the user that each subsequent step will be committed to git to record the creation process.
If initialization is needed, execute immediately:
bash
git init && git add . && git commit -m "init"步骤 3:安装 UI 框架
Step 3: Install UI Framework
使用 询问用户:是否需要使用 UI 框架?
AskUserQuestion如需要,根据已选择的模板推荐合适的框架,并立即执行安装命令。
如已选择 Git,安装完成后提交:
bash
git add .
git commit -m "feat: add UI framework"Use to ask the user: Do you need to use a UI framework?
AskUserQuestionIf yes, recommend a suitable framework based on the selected template and execute the installation command immediately.
If Git is selected, commit after installation is complete:
bash
git add .
git commit -m "feat: add UI framework"步骤 4:端口配置
Step 4: Port Configuration
使用 询问用户:是否使用默认的 1420 端口?
AskUserQuestion如不是,让用户指定新端口号,立即编辑 和 修改端口。
vite.config.tstauri.conf.json如已选择 Git,修改完成后提交:
bash
git add .
git commit -m "config: change port to <新端口>"Use to ask the user: Do you want to use the default port 1420?
AskUserQuestionIf not, ask the user to specify a new port number and immediately edit and to change the port.
vite.config.tstauri.conf.jsonIf Git is selected, commit after modification is complete:
bash
git add .
git commit -m "config: change port to <新端口>"步骤 5:安装 window-state 插件
Step 5: Install window-state Plugin
使用 询问用户:是否需要窗口状态记忆功能(桌面端)?
AskUserQuestion说明好处:自动记住窗口位置和大小,下次打开保持原样。
如需要,立即执行:
bash
pnpm tauri add window-state如已选择 Git,安装完成后提交:
bash
git add .
git commit -m "feat: add window-state plugin"Use to ask the user: Do you need window state memory functionality (desktop)?
AskUserQuestionExplain the benefits: Automatically remembers window position and size, and retains them when opened next time.
If yes, execute immediately:
bash
pnpm tauri add window-stateIf Git is selected, commit after installation is complete:
bash
git add .
git commit -m "feat: add window-state plugin"步骤 6:创建 AGENTS.md
Step 6: Create AGENTS.md
提示 AI 根据项目当前情况生成一份 AGENTS.md 文件,内容需要额外包含:提醒使用 技能。
tauri-best-practices如已选择 Git,创建完成后提交:
bash
git add AGENTS.md
git commit -m "docs: add AGENTS.md"Prompt the AI to generate an AGENTS.md file based on the current project situation, with additional content including: a reminder to use the skill.
tauri-best-practicesIf Git is selected, commit after creation is complete:
bash
git add AGENTS.md
git commit -m "docs: add AGENTS.md"步骤 7:告知开发命令
Step 7: Inform Development Commands
创建完成后告知用户:
bash
pnpm dev # 纯网页开发
pnpm tauri dev # 开发模式
pnpm tauri build # 构建应用After creation is complete, inform the user of:
bash
pnpm dev # Pure web development
pnpm tauri dev # Development mode
pnpm tauri build # Build application使用示例
Usage Examples
场景 1:全新项目创建(空目录)
Scenario 1: Create a New Project (Empty Directory)
用户输入:"帮我创建一个 Tauri 应用"
交互流程:
- 检查当前目录为空
- 询问用户:在当前目录创建还是创建子目录?
- 询问模板选择(推荐 vue-ts)
- 执行创建命令
- 询问是否初始化 Git
- 询问是否需要 UI 框架(根据模板推荐)
- 询问端口配置
- 询问是否安装 window-state 插件
- 创建 AGENTS.md
- 告知开发命令
User Input: "Help me create a Tauri application"
Interaction Flow:
- Check that the current directory is empty
- Ask the user: Create in the current directory or create a subdirectory?
- Ask for template selection (recommend vue-ts)
- Execute creation command
- Ask whether to initialize Git
- Ask whether a UI framework is needed (recommended based on template)
- Ask about port configuration
- Ask whether to install the window-state plugin
- Create AGENTS.md
- Inform development commands
场景 2:指定模板创建
Scenario 2: Create with Specified Template
用户输入:"用 React 创建一个 Tauri 项目"
处理方式:
- 直接使用 react-ts 模板(推荐 TypeScript)
- 如用户明确说不使用 TS,则使用 react 模板
- 其余流程同场景 1
User Input: "Create a Tauri project with React"
Handling Method:
- Directly use the react-ts template (TypeScript recommended)
- If the user explicitly says not to use TS, use the react template
- The rest of the process is the same as Scenario 1
场景 3:快速创建(跳过交互)
Scenario 3: Quick Creation (Skip Interaction)
用户输入:"快速创建一个基础的 Tauri 项目,不需要额外配置"
处理方式:
- 使用默认模板(vue-ts)
- 创建子目录或使用当前目录(如为空)
- 跳过 Git、UI 框架、端口、插件等询问
- 仅完成基础创建和依赖安装
User Input: "Quickly create a basic Tauri project without additional configuration"
Handling Method:
- Use the default template (vue-ts)
- Create a subdirectory or use the current directory (if empty)
- Skip inquiries about Git, UI frameworks, ports, plugins, etc.
- Only complete basic creation and dependency installation
场景 4:在现有项目中创建
Scenario 4: Create in an Existing Project
用户输入:"在当前目录创建 Tauri 项目"(当前目录非空)
处理方式:
- 告知用户将创建子目录
- 询问项目名称
- 在子目录中完成创建
User Input: "Create a Tauri project in the current directory" (current directory is not empty)
Handling Method:
- Inform the user that a subdirectory will be created
- Ask for the project name
- Complete creation in the subdirectory
注意事项
Notes
- 环境要求:确保已安装 Node.js 18+ 和 pnpm
- Rust 工具链:如需编写自定义 Rust 代码,需额外安装 Rust
- 此技能范围:仅负责项目创建和初始配置,不涉及后续开发
- 插件安装限制:一次只能添加一个插件,需多次执行
pnpm tauri add - Git 提交策略:每完成一个配置步骤立即提交,记录创建过程
- 端口冲突:如 1420 端口被占用,建议用户修改端口
- 最佳实践:创建完成后提醒用户参考 技能
tauri-best-practices
- Environment Requirements: Ensure Node.js 18+ and pnpm are installed
- Rust Toolchain: If you need to write custom Rust code, you need to install Rust additionally
- Skill Scope: Only responsible for project creation and initial configuration, not subsequent development
- Plugin Installation Limit: can only add one plugin at a time, so it needs to be executed multiple times
pnpm tauri add - Git Commit Strategy: Commit immediately after each configuration step to record the creation process
- Port Conflict: If port 1420 is occupied, it is recommended that the user change the port
- Best Practices: Remind users to refer to the skill after creation is complete
tauri-best-practices