tauri-dev
2
总安装量
2
周安装量
#65095
全站排名
安装命令
npx skills add https://github.com/zef-computers/drivers --skill tauri-dev
Agent 安装分布
trae
2
gemini-cli
2
claude-code
2
codex
2
kiro-cli
2
cursor
2
Skill 文档
Tauri v2 Development
Comprehensive development guide for Tauri v2 desktop and mobile applications. Contains 24 rules across 8 categories prioritized by impact, plus 9 deep-dive reference guides. Tauri apps use Rust backends with web frontends rendered in OS-native webviews. Binary sizes 2.5-6 MB.
When to Apply
Reference these guidelines when:
- Creating new Tauri v2 projects or adding features
- Implementing Rust commands and frontend IPC
- Configuring permissions, capabilities, or CSP
- Installing or creating Tauri plugins
- Customizing windows, system tray, or menus
- Building for mobile (Android/iOS)
- Distributing apps (bundling, signing, updating)
- Optimizing binary size, build speed, or runtime performance
- Debugging or testing Tauri applications
Rule Categories by Priority
| Priority | Category | Impact | Prefix |
|---|---|---|---|
| 1 | Commands & IPC | CRITICAL | ipc- |
| 2 | State Management | CRITICAL | state- |
| 3 | Error Handling | HIGH | error- |
| 4 | Security | HIGH | security- |
| 5 | Window Management | MEDIUM | window- |
| 6 | Plugin Usage | MEDIUM | plugin- |
| 7 | Performance | MEDIUM | perf- |
| 8 | Distribution | LOW-MEDIUM | dist- |
Quick Reference
1. Commands & IPC (CRITICAL)
ipc-async-commands– Use async commands with owned types (String not &str)ipc-invoke-error-handling– Always handle invoke() rejections on frontendipc-batch-operations– Batch IPC calls to reduce round-tripsipc-binary-response– Use tauri::ipc::Response for large binary dataipc-channels-streaming– Use Channel for streaming/progress updates
2. State Management (CRITICAL)
state-mutex-not-arc– Use Mutex without Arc (Tauri wraps in Arc internally)state-lock-scope– Minimize lock scope, never hold across .awaitstate-rwlock-reads– Use RwLock for read-heavy state
3. Error Handling (HIGH)
error-typed-errors– Use thiserror with manual Serialize for structured errorserror-frontend-handling– Propagate error context with kind/message to frontend
4. Security (HIGH)
security-deny-by-default– Configure capabilities before production deploymentsecurity-scope-filesystem– Scope filesystem access to app directoriessecurity-platform-capabilities– Use platform-specific capability filessecurity-csp-config– Configure Content Security Policy properly
5. Window Management (MEDIUM)
window-async-creation– Create windows asynchronously to avoid deadlockswindow-custom-titlebar– Implement custom title bars with drag regionswindow-hide-to-tray– Hide window to system tray on close
6. Plugin Usage (MEDIUM)
plugin-four-step-install– Complete all 4 plugin installation stepsplugin-clipboard-permissions– Clipboard has no default permissionsplugin-sql-execute– SQL default excludes write operations
7. Performance (MEDIUM)
perf-release-profile– Optimize Cargo release profile for small binariesperf-dev-build-speed– Separate rust-analyzer target directoryperf-unused-commands– Remove unused commands from binary (Tauri 2.4+)
8. Distribution (LOW-MEDIUM)
dist-code-signing– Configure code signing for all target platforms
How to Use
Read individual rule files for detailed explanations and code examples:
rules/ipc-async-commands.md
rules/security-deny-by-default.md
rules/perf-release-profile.md
Each rule file contains:
- Brief explanation of why it matters
- Incorrect code example with explanation
- Correct code example with explanation
- Impact rating and tags
Deep-Dive References
For comprehensive documentation beyond rules, load these as needed:
| Reference | Content |
|---|---|
| references/getting-started.md | Prerequisites, project creation, Vite setup, v1âv2 migration |
| references/commands-ipc.md | All command patterns, events, channels, state, serialization |
| references/plugins.md | All ~35 official plugins, custom plugin creation |
| references/security.md | Permissions (TOML), capabilities (JSON), CSP, ACL, isolation |
| references/windows-webview.md | WindowConfig, effects/vibrancy, tray, menus, WebView API |
| references/mobile.md | Android/iOS setup, mobile plugins, signing, app stores |
| references/distribution.md | Bundling, signing, updater, sidecars, CI/CD |
| references/config-testing.md | tauri.conf.json schema, env vars, mockIPC, WebDriver |
| references/performance.md | Binary size, memory, startup, IPC speed, build optimization |
Essential Patterns
Project Structure
my-app/
âââ src-tauri/
â âââ Cargo.toml # Rust dependencies
â âââ tauri.conf.json # Main config
â âââ capabilities/ # ACL capability files (JSON)
â â âââ default.json
â âââ src/
â â âââ lib.rs # Builder, plugins, commands
â â âââ main.rs # Entry point
â âââ icons/
âââ src/ # Frontend (React/Vue/Svelte)
âââ package.json
âââ vite.config.ts
Minimal Command + Invoke
#[tauri::command]
async fn greet(name: String) -> Result<String, String> {
Ok(format!("Hello, {}!", name))
}
// lib.rs
tauri::Builder::default()
.invoke_handler(tauri::generate_handler![greet])
.run(tauri::generate_context!())
import { invoke } from '@tauri-apps/api/core';
const greeting = await invoke<string>('greet', { name: 'World' });
Plugin Installation (4 Steps)
cargo add tauri-plugin-fs --manifest-path src-tauri/Cargo.toml
bun add @tauri-apps/plugin-fs
// lib.rs
tauri::Builder::default().plugin(tauri_plugin_fs::init())
// capabilities/default.json â permissions array
"fs:default", "fs:allow-read-text-file"
Capability File
{
"$schema": "../gen/schemas/desktop-schema.json",
"identifier": "default",
"windows": ["main"],
"permissions": [
"core:default",
"fs:default",
{ "identifier": "fs:scope", "allow": [{ "path": "$APPDATA/**" }] }
]
}
Decision Tables
IPC Method
| Need | Use |
|---|---|
| Request/response | Command (invoke) |
| Notify frontend | Event (emit) |
| Stream data | Channel (Channel<T>) |
| Large binary | tauri::ipc::Response |
State Wrapper
| Pattern | Use |
|---|---|
| Read-heavy | RwLock<T> |
| Balanced | Mutex<T> |
Across .await |
tokio::sync::Mutex<T> |
Full Compiled Document
For the complete guide with all rules expanded: AGENTS.md