Best for
- The user is developing with pnpm tauri dev / npm run tauri dev and Rust
- src-tauri/src/lib.rs has become a God file.
- The app exposes 100+ or 200+ [tauri::command] functions.
lovstudio/skills/skills/optimize-tauri-backend/SKILL.md
Use it for engineering and operations tasks; the detail page covers purpose, installation, and practical steps.
Decision brief
Use this skill to turn a growing Tauri backend into a smaller, more stable, more pleasant development surface. The goal is not magical Rust HMR. The goal is to reduce how often Rust changes are needed, make Rust restarts less disruptive, and keep the Tauri command boundary small…
Compatibility matrix
| Platform | Status | Evidence | What to check |
|---|---|---|---|
| Codex | Not declared | No explicit evidence | Portability before use |
| Claude Code | Not declared | No explicit evidence | Portability before use |
| Cursor | Not declared | No explicit evidence | Portability before use |
| Gemini CLI | Not declared | No explicit evidence | Portability before use |
Installation
The source command is displayed only when detected. A safe inspection prompt is always available so your agent can explain every action before execution.
npx skills add https://github.com/lovstudio/skills --skill "skills/optimize-tauri-backend"Inspect the Agent Skill "lov-optimize-tauri-backend" from https://github.com/lovstudio/skills/blob/8f250b126bb7e7eb6db0203c97d8279f75ae152d/skills/optimize-tauri-backend/SKILL.md at commit 8f250b126bb7e7eb6db0203c97d8279f75ae152d. List every install step, command, network request, credential, file read/write, external action, and rollback step. Explain whether it fits my task. Do not install or execute anything until I approve.
Workflow
Before changing files, inspect project instructions and config:
Before changing files, inspect project instructions and config:
Collect objective numbers before proposing or editing:
Review the “Step 3: Classify the Problem” section in the pinned source before continuing.
Add scripts without removing the existing full dev command:
Permission review
The documentation asks the agent to run terminal commands or scripts.
rg -n "beforeDevCommand|devUrl|frontendDist|tauri dev|--no-watch|invoke\\(|#\\[tauri::command\\]|generate_handler" package.json src-tauri src 2>/dev/nullThe documentation asks the agent to run terminal commands or scripts.
| Invoke sprawl | raw command strings everywhere | frontend invoke adapter / API layer |Evidence record
| Signal | Value | Evidence type | Meaning |
|---|---|---|---|
| Quality score | 93/100 | Computed | Documentation, specificity, maintenance, and trust rules |
| Repository stars | 64 | Source | Repository attention, not individual Skill quality |
| Compatibility | 0 platforms | Source | Declared in the catalog source record |
| Usage guide | automated source guide | Editorial | Generated or reviewed according to the visible evidence level |
Pinned source
Use this skill to turn a growing Tauri backend into a smaller, more stable, more pleasant development surface. The goal is not magical Rust HMR. The goal is to reduce how often Rust changes are needed, make Rust restarts less disruptive, and keep the Tauri command boundary small, typed, and auditable.
pnpm tauri dev / npm run tauri dev and Rust
file changes keep closing and reopening the app.src-tauri/src/lib.rs has become a God file.#[tauri::command] functions.invoke("command_name") strings across many
components.invoke / Channel calls cause stale callback warnings after
reload or HMR.State this clearly when asked about hot reload:
| Surface | Dev behavior |
|---|---|
| Frontend Vite / React | real HMR |
| Rust / Tauri backend | recompile + restart native process |
| Best optimization | separate stable Tauri shell from volatile domain logic, then make restarts cheap |
Do not promise Rust backend HMR inside Tauri. Tauri's Rust-side "hot reload" means watch, rebuild, and restart.
Before changing files, inspect project instructions and config:
pwd
find .. -name AGENTS.md -print
find .. -name CLAUDE.md -print
rg -n "beforeDevCommand|devUrl|frontendDist|tauri dev|--no-watch|invoke\\(|#\\[tauri::command\\]|generate_handler" package.json src-tauri src 2>/dev/null
Honor local constraints. If the repo says not to run pnpm build, do not run
it. Prefer rg and small file reads. Do not revert unrelated user changes.
Collect objective numbers before proposing or editing:
wc -l src-tauri/src/lib.rs 2>/dev/null
find src-tauri/src -maxdepth 3 -type f -name "*.rs" -print0 | xargs -0 wc -l | sort -n | tail
rg -n "#\\[tauri::command\\]" src-tauri/src | wc -l
rg -n "generate_handler!|invoke\\(" src-tauri/src src 2>/dev/null
Report:
lib.rs line count.Use these buckets:
| Bucket | Symptom | Preferred fix |
|---|---|---|
| Dev loop | Rust edits restart the app during UI work | add no-watch dev script |
| God module | lib.rs has thousands of lines | split into real Rust modules |
| Command sprawl | 100+ command functions | consolidate by domain with typed routers |
| Invoke sprawl | raw command strings everywhere | frontend invoke adapter / API layer |
| Long IPC | stale callback warnings after reload | stream id + cancel + send-error stop |
| Restart pain | route/session lost after app restart | dev resume state + flush pending saves |
| Compile pain | small domain edits rebuild huge surfaces | move volatile logic out of Tauri shell |
Add scripts without removing the existing full dev command:
{
"scripts": {
"dev:web": "vite",
"dev:app": "tauri dev",
"dev:app:no-watch": "tauri dev --no-watch"
}
}
Document usage:
dev:app: full Tauri development with Rust watcher.dev:app:no-watch: frontend-focused development; Vite HMR stays active and
Rust file changes do not restart the app.dev:web: pure web frontend when the app supports browser-only work.Keep the existing pnpm tauri dev route working unless the user explicitly
asks to remove it.
Goal: src-tauri/src/lib.rs should be a thin entrypoint.
Target shape:
mod app;
mod diagnostics;
mod pty_manager;
pub use app::run;
Recommended backend shape:
src-tauri/src/
├── lib.rs
├── app/
│ ├── mod.rs
│ ├── run.rs
│ ├── command_registry.rs
│ ├── command_routers.rs
│ ├── settings_core.rs
│ ├── session_cache.rs
│ ├── session_listing.rs
│ └── ...
└── shared_runtime_modules.rs
Rules:
mod modules over long-term include!.include! split is acceptable only as
a compile-preserving checkpoint. Convert it to real modules before finishing.generate_handler! out of run.rs into command_registry.rs.run.rs focused on app lifecycle, plugins, menus, windows, and
watchers.Do not replace 200 commands with do_anything(action, payload). That removes
type and permission boundaries.
Good consolidation pattern:
#[tauri::command]
async fn settings_command(action: String, payload: serde_json::Value) -> Result<serde_json::Value, String> {
match action.as_str() {
"patch_settings" => { /* typed deserialize + validate */ }
"get_settings" => { /* typed return */ }
_ => Err(format!("unknown settings action: {action}")),
}
}
Better when possible:
#[derive(Deserialize)]
#[serde(rename_all = "camelCase", tag = "kind")]
enum SettingsPatch {
SetEnv { key: String, value: String },
DeleteEnv { key: String },
TogglePlugin { plugin_id: String, enabled: bool },
}
Recommended domains to consolidate:
| Domain | Typical router |
|---|---|
| templates / marketplace install | template_command |
| file utilities | file_command |
| PTY lifecycle | pty_command |
| workspace state | workspace_command |
| MaaS/provider settings | maas_command |
| settings/env/permissions/plugins | patch_settings or settings_command |
Keep explicit commands for:
Target: under 100 commands for medium-sized apps, lower only if domain routers stay typed and auditable.
Create one adapter such as src/lib/tauri.ts:
import { invoke as tauriInvoke, type InvokeArgs, type InvokeOptions } from "@tauri-apps/api/core";
const COMMAND_ROUTES: Record<string, { command: string; action: string }> = {
install_skill_template: { command: "template_command", action: "install_skill_template" },
pty_write: { command: "pty_command", action: "pty_write" },
};
export function invoke<T>(cmd: string, args?: InvokeArgs, options?: InvokeOptions): Promise<T> {
const route = COMMAND_ROUTES[cmd];
if (!route) return tauriInvoke<T>(cmd, args, options);
return tauriInvoke<T>(route.command, { action: route.action, payload: args ?? {} }, options);
}
Then replace component imports from @tauri-apps/api/core with the app adapter.
Use TanStack Query or a local query wrapper for server-state reads. Keep imperative side effects imperative.
When a command streams via Channel, use a request id and cancellation:
Frontend:
const streamId = crypto.randomUUID();
const channel = new Channel<Event>();
invoke("list_items_streamed", { streamId, onEvent: channel });
return () => {
invoke("cancel_items_stream", { streamId }).catch(() => {});
};
Also cancel on HMR / pagehide:
if (import.meta.hot) {
import.meta.hot.dispose(() => cancelStream("hmr-dispose"));
}
window.addEventListener("pagehide", () => cancelStream("pagehide"));
Rust:
static STREAM_CANCELS: LazyLock<Mutex<HashMap<String, Arc<AtomicBool>>>> =
LazyLock::new(|| Mutex::new(HashMap::new()));
Rules:
invoke should resolve quickly after starting a background stream.streamId.console.warn = ....Make restarts less disruptive:
pagehide, visibilitychange, and HMR
dispose.Keep this dev-oriented unless the product requires production resume semantics.
Run only checks allowed by local instructions:
cargo fmt
CARGO_TARGET_DIR=target/codex-check cargo check
pnpm exec tsc --noEmit --pretty false
Use a separate CARGO_TARGET_DIR when the user's tauri dev process holds the
normal Cargo build lock.
Report:
lib.rs line count.Final answer must include:
运行前读取本 Skill 包的 skill.yaml,由宿主提供 skill-runtime/v1 上下文。字段解析顺序为:当前请求、项目上下文、个人 Preferences、品牌 Profile、通用默认值。
required: true 字段缺失时,按 Manifest 的问题配置向用户提出一个聚焦问题;用户明确同意后再保存回答。context_id、字段路径与来源,诊断内容避开秘密、完整私人路径和原始配置。用户在 Skill 驱动任务中提出修改意见时,继续当前产物前必须执行:
task-specific(仅本次)还是 reusable(可跨任务复用)。task-specific 只修改当前任务,不改 Skill。reusable 先确定作用域:领域规则先更新对应 canonical Skill;适用于所有 Skill 的规则先更新共享规范。reusable 修改会使此前的“确认”“继续”“发吧”失效;完成当前产物修改和回读后必须停下,等待用户下一步指示,不自动进入发布、提交或其他外部写入。Frequently asked questions
Use this skill to turn a growing Tauri backend into a smaller, more stable, more pleasant development surface. The goal is not magical Rust HMR. The goal is to reduce how often Rust changes are needed, make Rust restarts less disruptive, and keep the Tauri command boundary small…
The source record exposes this install command: npx skills add https://github.com/lovstudio/skills --skill "skills/optimize-tauri-backend". Inspect the command and pinned source before running it.
Static rules flagged exec-script in the source; the page lists the matching lines and excerpts.
Alternatives
UiPath/skills
UiPath Coded Apps — scaffold, build, run, and deploy Coded Web Apps and Coded Action Apps: React/TypeScript apps that call UiPath Cloud APIs via the `@uipath/uipath-typescript` SDK and ship to Automation Cloud (push/pull to Studio Web, pack, publish, deploy, OAuth-PKCE). Also generates live analytics & governance dashboards from a plain-language request, wired to tenant data via the Insights real-time API, with edit and deploy flows. For RPA→uipath-rpa, Python agents→uipath-agents, Maestro flows
fcakyon/claude-codex-settings
Guide for implementing smooth, native-feeling animations using React's View Transition API (`<ViewTransition>` component, `addTransitionType`, and CSS view transition pseudo-elements). Use this skill whenever the user wants to add page transitions, animate route changes, create shared element animations, animate enter/exit of components, animate list reorder, implement directional (forward/back) navigation animations, or integrate view transitions in Next.js. Also use when the user mentions view
theBGuy/GitDesktop
Guide for implementing smooth, native-feeling animations using React's View Transition API (`<ViewTransition>` component, `addTransitionType`, and CSS view transition pseudo-elements). Use this skill whenever the user wants to add page transitions, animate route changes, create shared element animations, animate enter/exit of components, animate list reorder, implement directional (forward/back) navigation animations, or integrate view transitions in Next.js. Also use when the user mentions view
awslabs/agent-plugins
Build and deploy full-stack web and mobile apps with AWS Amplify Gen2 (TypeScript code-first). Covers auth (Cognito), data (AppSync/DynamoDB including schema modeling, enum types, relationships, authorization rules), storage (S3), functions, APIs, and AI (Amplify AI Kit with Bedrock). Supports React, Next.js, Vue, Angular, React Native, Flutter, Swift, and Android. Always use this skill for Amplify Gen2 topics — even for questions you think you know — it contains validated, version-specific patt