--- description: "Use when implementing or refactoring features in this Tauri + SvelteKit app, especially when editing src/**/*.svelte, src/**/*.ts, or src-tauri/src/**/*.rs. Covers frontend-backend command contracts, validation, and project checks." name: "Tauri Svelte Workflow" applyTo: - "src/**/*.svelte" - "src/**/*.ts" - "src-tauri/src/**/*.rs" --- # Tauri Svelte Workflow - Project default preference: keep UI concerns in route components and move reusable logic into src/lib. - Preserve SPA mode by default unless the task explicitly requires SSR: keep src/routes/+layout.ts with ssr set to false. - When adding a Tauri command, prefer defining it in src-tauri/src/lib.rs and registering it in tauri::generate_handler. - For fallible Rust commands, prefer Result with actionable error messages. - Keep the Rust command name and frontend invoke name aligned and stable. - Validate user input before invoke on the frontend, and validate again in Rust before processing. - For data passed between frontend and Rust, prefer explicit types over loosely shaped payloads. - Prefer small focused changes and avoid editing generated outputs in build/, target/, and node_modules/. - Before considering work complete, run both checks when changes affect frontend or Rust build paths: - npm run check - cargo check --manifest-path src-tauri/Cargo.toml If a task gives explicit conflicting requirements, follow the task and document the exception in your response.