lov-optimize-tauri-backend
БесплатноБез исполняемых скриптовНе проверен优化 Tauri 2 后端:拆分过大的 lib.rs、收敛 command 数量、集中 invoke、处理长 IPC 与开发期重启。Use when the user mentions "lib.rs 太大", "commands 太多", "Tauri 后端优化", "Tauri dev reload".
от lovstudio★ 72 звезды на GitHubОб этом скилле
Tauri 后端调优 · Tauri Backend Tuner
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.
Triggers
Activate when
- “lib.rs 太大”“commands 太多”“降低到 100 个以内”“Tauri 后端优化”
- "optimize-tauri-backend", "Tauri backend refactor", "Tauri dev reload", or a question about Tauri hot reload and Rust-side restarts.
- The user is developing with
pnpm tauri dev/npm run tauri devand Rust file changes keep closing and reopening the app. src-tauri/src/lib.rshas become a God file.- The app exposes 100+ or 200+
#[tauri::command]functions. - Frontend code scatters raw
invoke("command_name")strings across many components. - Long-running
invoke/Channelcalls cause stale callback warnings after reload or HMR. - The user wants backend modularization, command consolidation, better dev scripts, or restart-state recovery.
Do not activate when
- The issue is frontend-only Vite/React HMR with no Rust or Tauri backend change.
- A running app is slow, drains battery, or grows memory: use
lov-app-optimizer. - The request is only to move frontend reads onto a shared query cache: use
lov-install-tanstack-query. - Release builds, signing, or auto update: use
lov-app-releaseorlov-app-delta-updater.
Skill Group Composition
Read references/skill-composition.md before routing to or extending an
adjacent Skill.
Core Position
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.
Workflow
Step 1: Read Local Rules First
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.
Step 2: Baseline the Backend
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.rsline count.- Largest Rust files.
- Number of Tauri commands.
- Whether command registration lives inside startup code.
- Whether frontend uses a centralized invoke adapter.
- Known long IPC streams or background tasks.
Step 3: Classify the Problem
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 |
Step 4: Improve the Dev Loop
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.
Step 5: Modularize the Rust Backend
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:
- Prefer real
modmodules over long-terminclude!. - During l
Установить lov-optimize-tauri-backend в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл lov-optimize-tauri-backend?
优化 Tauri 2 后端:拆分过大的 lib.rs、收敛 command 数量、集中 invoke、处理长 IPC 与开发期重启。Use when the user mentions "lib.rs 太大", "commands 太多", "Tauri 后端优化", "Tauri dev reload".
Как установить скилл lov-optimize-tauri-backend?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл lov-optimize-tauri-backend запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic