# Agent Standards

This repository should favor durable backend code over fast patches. The baseline is:

## Core rules

- For the TypeScript/Vite/Tauri frontend toolchain, use `bun` as the package manager and script runner. Treat `bun.lock` as the source of truth.
- Keep Tauri commands thin. Input validation, orchestration, and state changes belong in backend services, not in command handlers.
- Do not leave dead code or disconnected module trees in the crate. If Rust cannot compile it, it is not part of the backend.
- Prefer explicit types and narrow module boundaries over convenience abstractions that hide behavior.
- Avoid shortcuts such as `unwrap`, `expect`, silent fallbacks, or placeholder logic in production paths.
- Every backend behavior change should preserve `cargo check` and add or update tests when logic changes.

## Rust patterns

- Use conventional Rust module layout: `mod.rs` or flat sibling modules, not nested filename patterns that Cargo will ignore.
- Return typed errors from backend services and convert them at the Tauri boundary only when required by the command interface.
- Keep shared mutable state behind a narrow API. Do not let command handlers reach directly into ad hoc maps or storage.
- Add doc comments to public types and functions. Add inline comments only when explaining why a constraint exists.
- Prefer small, composable functions over commented blocks of procedural logic.

## Review bar

- No partially wired backend folders.
- No mock or template code left in the active backend path.
- No new public API without documentation.
- No new stateful logic without at least focused unit coverage.
- No structural change without verifying the crate still compiles.
