Coding Standards
Core Invariants
These rules are non-negotiable and must be preserved across all changes:
- Terminal runtimes survive UI changes -- switching tabs, changing focus, or resizing layout must never restart a running PTY session
- Single runtime owner --
RuntimeApplicationServiceis the sole owner of runtime lifecycle. All start/stop/replace/restart flows go through it - Port-adapter isolation -- application services depend on port traits (
ports.rs), never on concrete Tauri or plugin imports - Domain purity -- domain crates depend on
tabby-kernelonly, never ontabby-contractsor each other - DTO boundary -- generated DTOs (
tauri-bindings.ts) appear only in transport clients and snapshot-mappers, never in stores or components - Thin commands -- Tauri IPC handlers only deserialize, delegate, and return. No business logic
- Projection-based publishing --
ProjectionPublisherPortaccepts domain types, not DTOs. Infrastructure adapters handle mapping
TypeScript
- Strict mode enabled
- Prefer immutable patterns -- create new objects instead of mutating
- Functions under 50 lines, files under 800 lines
- No
console.login committed code - No hardcoded values -- use constants or configuration
Rust
- Use
tracingfor diagnostics, notprintln! - No
.unwrap()or.expect()in production code - Run
cargo fmtandcargo clippybefore committing - Keep Tauri command handlers thin -- delegate to application services
Frontend Architecture
- Each feature owns its
domain/,application/, andcomponents/directories - Features do not import from other features' internals
- Zustand stores use internal read models derived from snapshots
- Shared UI components live in
src/components/
Rust Architecture
- Domain crates are pure -- no framework dependencies
- Application services define behavior through port traits
- Infrastructure adapters implement ports and live in
infrastructure/ - Cross-context coordination goes through
AppShell, not direct service-to-service calls
Dependency Direction
Presentation -> Application -> Domain
|
(port traits)
|
InfrastructureNever invert this direction. Domain code must not know about the presentation layer or infrastructure details.
