tauri

A set of coding rules for Tauri desktop applications, where a web frontend communicates with a Rust backend. It defines patterns for commands, events, shared state, data serialization, and security settings.

In plain words
What is it for?
Use it while building or reviewing Tauri commands, frontend-to-backend communication, event notifications, shared application state, database connections, and configuration security.
Why use it?
It gives developers consistent boundaries between the frontend and Rust code and helps avoid unsafe error handling, untyped interfaces, and incorrect state management.

Cursor rule

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/nedcodes-ok/cursorrules-collection/tauri
Clone the repo
git clone --depth 1 https://github.com/nedcodes-ok/cursorrules-collection
Per session 513 This file is loaded in full into every session.
When invoked 513 The same file — it is already loaded in full.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00513 $0.00513
Opus 5 $0.00257 $0.00257
Sonnet 5 $0.00103 $0.00103
Haiku 4.5 $0.00051 $0.00051

Measured 2d ago against content hash 3d341f5d4721, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

tauri scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

rules-mdc/frameworks/tauri.mdc · 48 lines

How it starts

The opening of the file, as written. The whole thing — 48 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Tauri Cursor Rules

You are an expert Tauri developer. Follow these rules:

Architecture

  • Frontend is a web app (React/Svelte/Vue). Backend logic in Rust (src-tauri/)
  • Use Tauri commands (#[tauri::command]) for frontend→backend communication
  • Use events (app.emit/app.listen) for backend→frontend push notifications
  • Keep frontend framework-agnostic where possible — @tauri-apps/api abstracts the bridge

Commands

  • #[tauri::command] functions are the API boundary. Type inputs and outputs carefully
  • Return Result<T, String> from commands. Never panic in command handlers
  • Use State parameter for shared app state (managed via app.manage())
  • Async commands with async keyword — Tauri runs them on a thread pool
  • Serialize/deserialize with serde. All command inputs/outputs must impl Serialize + Deserialize

State Management

  • App state via tauri::State<Mutex> or tauri::State<RwLock> for thread safety
  • Initialize state in setup() callback, not in main()
  • Use Arc<Mutex> only when state needs to be shared outside command handlers
  • Database connections: use connection pools (r2d2/deadpool) in managed state

Security

  • Allowlist in tauri.conf.json — only enable APIs you actually use
  • Validate all inputs from frontend in command handlers. Frontend is untrusted
  • Use tauri::scope for file system and shell access restrictions
  • Never expose shell commands directly. Wrap in typed Rust functions
  • CSP configured in tauri.conf.json. No unsafe-eval

Events

  • app.emit_all() to broadcast to all windows. app.emit_to() for specific windows
  • Frontend listens via listen()/once() from @tauri-apps/api/event
  • Use typed event payloads. Define shared types in a types module
  • Clean up listeners in frontend component unmount/destroy

Build & Packaging

  • tauri.conf.json for app metadata, window config, security settings
  • Use Tauri's updater for auto-updates with signing
  • Platform-specific code via cfg attributes: #[cfg(target_os = "macos")]
  • Test Rust backend independently: cargo test in src-tauri/

Read the full file on GitHub · 48 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 48 lines · 513 tokens per session scan A 3d341f5d4721

Subscribe to this mod's changes

tauri is a cursor rule published in the GitHub repository nedcodes-ok/cursorrules-collection (37 stars, last pushed 6mo ago), licensed MIT. It adds 513 tokens to every session, about $0.0026 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.