一键导入
update-backend
Guide for making changes to the Rust backend of the Tauri template, covering the engine crate, CLI harness, Tauri commands, and testing patterns.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Guide for making changes to the Rust backend of the Tauri template, covering the engine crate, CLI harness, Tauri commands, and testing patterns.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Interview the user, inspect this Tauri desktop template, run headless setup and rename, and prune unused systems so a new Tauri (Rust + Bun/React) project gets running quickly.
Instructions for using prek as a replacement for pre-commit.
Instructions for running code quality checks and maintaining standards in the Tauri-Template project.
| name | update-backend |
| description | Guide for making changes to the Rust backend of the Tauri template, covering the engine crate, CLI harness, Tauri commands, and testing patterns. |
Use this skill whenever you are modifying Rust backend logic - adding commands, probes, traits, or configuration in crates/engine, crates/cli, or src-tauri.
The backend is split into three layers:
| Layer | Path | Role |
|---|---|---|
| engine | crates/engine/ | All real backend logic. No Tauri dependency - runs in CLI, tests, and WASM. |
| appctl CLI | crates/cli/ | Headless test harness that drives engine for VM/CI compatibility testing. |
| src-tauri | src-tauri/ | Tauri host: wraps engine commands as Tauri #[tauri::command] handlers. |
crates/engine.FilesystemOps, NetworkOps, ClipboardOps. Inject real platform or headless stubs via AppContext.CommandResult with run_id, status, error, timing_ms, and env_summary.SKIP or UNSUPPORTED error codes.snake_case for functions/modules/variablesPascalCase for structs/enumscargo fmt before committing; pass cargo clippy with no warningscrates/engine/src/commands/:fn cmd_my_command(args: Value, ctx: &AppContext) -> Result<Value, CommandError> {
let input = args.get("key").and_then(|v| v.as_str())
.ok_or_else(|| CommandError::InvalidInput("missing 'key'".into()))?;
Ok(serde_json::json!({ "result": input }))
}
CommandRegistry::new():reg.register("my_command", cmd_my_command);
src-tauri as a Tauri command (if the GUI needs it):#[tauri::command]
fn my_command(args: serde_json::Value, ctx: tauri::State<AppContext>) -> CommandResult {
ctx.registry.execute("my_command", args, &ctx)
}
appctl:cargo build -p appctl
appctl call my_command --args '{"key": "value"}' --json
Implement the relevant trait from crates/engine/src/traits.rs:
use engine::traits::{ClipboardOps, CapResult, CapError};
struct MyClipboard;
impl ClipboardOps for MyClipboard {
fn read_text(&self) -> CapResult<String> {
Err(CapError::Unsupported("not available".into()))
}
fn write_text(&self, _text: &str) -> CapResult<()> {
Err(CapError::Unsupported("not available".into()))
}
}
Inject via AppContext - real platform in src-tauri, headless stubs in tests and appctl.
Source of truth: src-tauri/global_config.yaml (.env overrides).
Access in Rust:
let config = crate::global_config::get_config();
println!("Model: {}", config.default_llm.default_model);
Config is loaded in src-tauri/src/global_config.rs and not imported by crates/engine (keep engine config-agnostic unless needed).
The appctl CLI drives engine without a running Tauri process:
# Build
cargo build -p appctl
# Diagnostics
appctl doctor --json
# Call a command
appctl call ping --json
appctl call read_file --args '{"path": "/etc/hostname"}' --json
# Run a capability probe
appctl probe filesystem --json
appctl probe network --json
# Run a YAML scenario
appctl run-scenario scenario.yaml --json
Write scenario files for regression tests:
name: my feature smoke test
steps:
- call: "my_command"
args:
key: "value"
expect_status: "pass"
Every command result has this stable JSON schema:
{
"run_id": "uuid",
"command": "call|probe|doctor|run-scenario",
"target": "<cmd or probe name>",
"status": "pass|fail|skip|error",
"error": { "code": "ERROR_CODE", "message": "..." },
"timing_ms": { "total": 1234 },
"env_summary": { "os": "linux|macos", "arch": "x86_64|aarch64", "headless": true },
"data": {}
}
Error codes: INVALID_INPUT, UNSUPPORTED, UNIMPLEMENTED, DEPENDENCY_MISSING,
PERMISSION_DENIED, NETWORK_ERROR, IO_ERROR, TIMEOUT, EXTERNAL_INTERFERENCE, INTERNAL_ERROR.
cargo fmt appliedcargo clippy passes (no warnings)cargo test passesappctl call <cmd> --jsonengine crate has no Tauri imports