skills/tauri-v2/SKILL.md
Tauri v2 项目开发助手 - 提供 CLI 项目管理、最佳实践指导和代码生成。适用于 (1) 创建和管理 Tauri v2 项目 (2) 开发桌面和移动应用 (3) 配置构建和分发流程 (4) 实现安全的前后端通信 (5) 应用架构设计和性能优化。
npx skillsauth add cruldra/skills tauri-v2Install this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
本技能提供 Tauri v2 项目的全面开发支持,包括 CLI 操作、架构设计、安全实践和部署策略。
create-tauri-app 或手动初始化新项目# 创建项目 (自动化环境中必须使用非交互式命令)
# 注意:在使用自动化工具(如 Agent)创建项目时,请先向用户收集以下参数:
# 1. 项目名称 (<PROJECTNAME>)
# 2. 包管理器 (--manager: pnpm, npm, yarn, cargo 等)
# 3. UI 模板 (--template: react-ts, vue-ts, vanilla, svelte-ts 等)
# 4. 唯一标识符 (--identifier: com.your.app)
# 收集完毕后,使用如下非交互式命令创建:
pnpm create tauri-app@latest <项目名称> --manager <包管理器> --template <UI模板> --identifier <唯一标识符> -y
# 开发 (建议在项目根目录下使用包管理器运行)
npm run tauri dev
# 若使用 pnpm 则为: pnpm tauri dev
# 构建
npm run tauri build
# 添加官方插件
npx tauri add fs
project/
├── src/ # 前端代码
├── src-tauri/ # Rust 后端
│ ├── src/
│ │ ├── main.rs # 入口
│ │ ├── commands.rs # 命令
│ │ ├── state.rs # 状态
│ │ └── error.rs # 错误
│ ├── capabilities/ # 权限配置
│ └── tauri.conf.json # 配置
参考 cli-management.md 获取完整的 CLI 使用指南:
dev, android dev, ios dev)build, android build, ios build)bundle)参考 config-reference.md 获取 tauri.conf.json 的详细解析与指南:
build 节点)app 节点)bundle 节点)plugins 节点)参考 best-practices.md 获取架构和安全指南:
use tauri::State;
use serde::{Deserialize, Serialize};
#[derive(Deserialize)]
pub struct Request {
data: String,
}
#[derive(Serialize)]
pub struct Response {
result: String,
}
#[tauri::command]
pub async fn my_command(
request: Request,
state: State<'_, AppState>,
) -> Result<Response, AppError> {
Ok(Response {
result: format!("Processed: {}", request.data),
})
}
import { invoke } from '@tauri-apps/api/core';
export async function myCommand(data: string): Promise<string> {
try {
const response = await invoke<{ result: string }>('my_command', { data });
return response.result;
} catch (error) {
console.error('Command failed:', error);
throw new Error(`操作失败: ${error}`);
}
}
use thiserror::Error;
use serde::{Deserialize, Serialize};
#[derive(Error, Debug, Serialize, Deserialize)]
pub enum AppError {
#[error("IO 错误: {0}")]
IoError(String),
#[error("权限被拒绝")]
PermissionDenied,
#[error("无效的输入")]
InvalidInput,
}
{
"identifier": "default",
"permissions": [
"core:default",
{
"identifier": "fs:allow-read",
"allow": [{"path": "$APPDATA/*"}]
}
]
}
rustup updatecargo cleannpm installTAURI_DEV_HOST 环境变量opt-level = "s"__cmd__ 宏重复定义 (E0255)症状: 编译报错 the name '__cmd__greet' is defined multiple times (E0255)
原因: #[tauri::command] 宏和 generate_handler! 宏都会生成 __cmd__<fn_name> 内部宏。当 command 函数直接定义在 lib.rs 或 main.rs 中,且同一文件调用了 generate_handler! 时,两者在同一 crate root 作用域内产生命名冲突。这是 Tauri 已知的架构限制(所有版本 1.x ~ 2.x 均受影响)。
解决方案: 将所有 #[tauri::command] 函数移到子模块中(如 commands.rs),在 generate_handler! 中使用完整路径引用:
// src-tauri/src/lib.rs (或 main.rs)
mod commands;
pub fn run() {
tauri::Builder::default()
.invoke_handler(tauri::generate_handler![
commands::greet,
commands::open_link,
])
.run(tauri::generate_context!())
.expect("error while running tauri application");
}
注意: 即使函数不加
pub,只要它带有#[tauri::command]并且与generate_handler!在同一文件,就会产生此冲突。务必始终将命令函数放在独立子模块中。
testing
智能体 UAT 验收测试技能。用于验证智能体在真实场景下的表现是否满足预期。支持任意智能体框架(langchain、langgraph、deepagents、crewai 等)。触发词:测试智能体、验收测试、agent test、UAT
tools
Use when you need to create a Gitea issue, update its spec/plan markers, read or merge an issue's state JSON, or post a PR review comment in a repo that uses the spx CLI (superpowers-vscode workflow).
development
Use when implementing, modifying, refactoring, or reviewing code and the agent must follow explicit coding standards for simplicity, readability, maintainability, testability, project conventions, and minimal safe changes.
development
Use when integrating the deepagents SDK into a Python project — creating agents, configuring backends, adding subagents, middleware, memory, or skills. Also use when debugging deepagents agents or choosing between StateBackend, FilesystemBackend, and LocalShellBackend.