Home › Tauri › Tauri 2 desktop app Windsurf rules

Tauri 2 desktop app Windsurf rules

Windsurf rules for Tauri 2 desktop/mobile apps: Rust commands, capabilities and permissions, and a web frontend.

WindsurfTauri

How to use

Save this as .windsurf/rules/tauri.md in your repository root, commit it, and your agent will pick it up automatically. Edit the commands to match your project.

.windsurf/rules/tauri.mdDownload  
---
trigger: glob
globs: src-tauri/**,src/**
---

# Tauri 2

- Frontend (`src/`) talks to Rust only through commands and events: `import { invoke } from '@tauri-apps/api/core'`.
- Commands in `src-tauri/src/commands/*.rs` with `#[tauri::command]`, registered in `tauri::generate_handler![...]`. Make them `async` for I/O and return `Result<T, AppError>` where `AppError` implements `serde::Serialize`.
- Shared state via `app.manage(State)` and `tauri::State<'_, Mutex<...>>`; never hold a lock across `.await`.
- Security model: grant only the permissions a window needs in `src-tauri/capabilities/*.json`. Don't add broad `fs:default`/scope `**` or shell permissions without a reason.
- Use official plugins (`tauri-plugin-fs`, `-dialog`, `-store`, `-http`, `-updater`) via `npm run tauri add <plugin>`, not custom unsafe code.
- Validate every argument coming from the webview in Rust; treat it as untrusted input.
- Keep a strict CSP in `tauri.conf.json`; don't load remote content into privileged windows.
- Long work runs in `tauri::async_runtime::spawn` and reports progress with events (`app.emit`).

## Don't
- Don't use Tauri 1 APIs (`@tauri-apps/api/tauri`, `allowlist`).

## Done when
`cargo clippy --manifest-path src-tauri/Cargo.toml -- -D warnings`, frontend typecheck, and `npm run tauri build -- --debug` succeed.

More: all Tauri rules · all Windsurf rules

Related rules

Tauri 2 Rust backend rules

Cursor rules for the Rust side of Tauri 2 apps: commands, typed errors, state, plugins, and capability files.

CursorTauri

Electron app Windsurf rules

Windsurf rules for secure Electron 44 apps: context isolation, preload bridges, typed IPC, and packaging.

WindsurfElectron

Electron app AGENTS.md

AGENTS.md for Electron desktop apps (Electron Forge or electron-vite): process layout, IPC contracts, and release safety.

AGENTS.mdElectron

Web accessibility (WCAG 2.2) rules

Windsurf rules for building accessible web UIs to WCAG 2.2 AA: semantics, keyboard, focus, contrast, and testing.

WindsurfAccessibility

Agent safety guardrails Windsurf rules

Always-on Windsurf rules that stop agents from running destructive, costly, or externally visible actions without approval.

WindsurfAny stack

Ansible Windsurf rules

Windsurf rules for Ansible playbooks and roles: FQCN modules, idempotency, check mode, vault secrets, and ansible-lint.

WindsurfAnsible

Get new rules weekly

One email a week: fresh rule files, agent tips, and what's changing in Cursor, Claude Code and Copilot. Free, unsubscribe anytime.

Opens the Rulestack Newsletter on beehiiv in a new tab. Or subscribe directly on beehiiv.