code-quality
Production-grade code standards emphasizing correctness, crash-safety, and Rust idioms over convenience.
- Prioritizes data integrity: crash on invalid state rather than corrupt data; assert invariants aggressively; handle all errors explicitly
- Rust-specific patterns: make illegal states unrepresentable, use exhaustive pattern matching and enums over strings, minimize allocations
- Comments document why, not what; avoid temporal markers, AI conversation references, and code-repeating explanations
- Rejects over-engineering: implement only requested changes, skip error handling for impossible scenarios, avoid premature abstractions
- Index mutations require careful ordering verification against SQLite to prevent inconsistencies
Code Quality Guide
Core Principle
Production database. Correctness paramount. Crash > corrupt.
Correctness Rules
- No workarounds or quick hacks. Handle all errors, check invariants
- Assert often. Never silently fail or swallow edge cases
- Crash on invalid state if it risks data integrity. Don't continue in undefined state
- Consider edge cases. On long enough timeline, all possible bugs will happen
Rust Patterns
- Make illegal states unrepresentable
- Exhaustive pattern matching
- Prefer enums over strings/sentinels
- Minimize heap allocations
- Write CPU-friendly code (microsecond = long time)
More from tursodatabase/turso
index-knowledge
Generate hierarchical AGENTS.md knowledge base for a codebase. Creates root + complexity-scored subdirectory documentation.
659debugging
How to debug tursodb using Bytecode comparison, logging, ThreadSanitizer, deterministic simulation, and corruption analysis tools
634async-io-model
Explanations of common asynchronous patterns used in tursodb. Involves IOResult, state machines, re-entrancy pitfalls, CompletionGroup. Always use these patterns in `core` when doing anything IO
607storage-format
SQLite file format, B-trees, pages, cells, overflow, freelist that is used in tursodb
607testing
How to write tests, when to use each type of test, and how to run them. Contains information about conversion of `.test` to `.sqltest`, and how to write `.sqltest` and rust tests
601pr-workflow
General guidelines for Commits, formatting, CI, dependencies, security
599