code-quality
code-quality establishes standards for writing reliable database code in Rust, prioritizing data integrity over silent failures. It covers error handling discipline, exhaustive pattern matching, and invariant checking to prevent corruption. The guide emphasizes crashing on invalid state rather than continuing in undefined conditions, and avoiding premature abstractions or workarounds.
code-quality helps you write crash-safe, correct production database code in Rust by enforcing strict error handling and invariant checking.
AI-generated summary based on this skill's SKILL.md
Install
tursodatabase/turso/code-quality · repository language: Rust
git clone https://github.com/tursodatabase/turso
cp -r turso/.claude/skills/code-quality ~/.claude/skills/code-qualityFrequently asked questions
AI-generated answers based on this skill's SKILL.md and metadata
How does code-quality help write correct production database code?
code-quality establishes standards for writing reliable database code in Rust by prioritizing data integrity over silent failures. It covers error handling discipline, exhaustive pattern matching, and invariant checking to prevent corruption. The guide emphasizes crashing on invalid state rather than continuing in undefined conditions, ensuring your database operations remain safe and predictable in production environments.
What rust error handling patterns does code-quality recommend?
code-quality emphasizes handling errors and edge cases without silent failures through disciplined error handling patterns. The guide prioritizes crashing on invalid state rather than continuing in undefined conditions, and advocates for exhaustive pattern matching to catch all cases. This approach prevents subtle bugs where errors go unnoticed, protecting data integrity in production systems.
How can I make illegal states unrepresentable in Rust?
code-quality teaches applying Rust patterns to make illegal states unrepresentable, using techniques like enums over strings and exhaustive pattern matching. By leveraging Rust's type system, you encode valid states directly into your types, making it impossible to represent invalid combinations at compile time. This prevents entire categories of runtime errors and corrupted database states.
Should code-quality guide me on avoiding silent failures in rust?
Yes, code-quality prioritizes avoiding silent failures by establishing standards that treat crashes on invalid state as preferable to continuing in undefined conditions. The guide emphasizes invariant checking and exhaustive pattern matching to catch edge cases early. This discipline ensures errors surface immediately rather than corrupting data silently in production.
What does code-quality say about optimizing Rust for performance?
code-quality addresses optimizing Rust code for performance and memory efficiency, including heap allocation optimization and CPU-friendly code patterns. However, the guide balances optimization with correctness and maintainability, avoiding premature abstractions or workarounds that sacrifice clarity for marginal gains.
How should I write maintainable code according to code-quality?
code-quality recommends writing maintainable code with effective comments and no over-engineering. The guide emphasizes clarity over premature optimization, advocating for straightforward implementations that follow Rust's safety guarantees. Focus on correctness and data integrity first, then optimize only where profiling shows it matters.
SKILL.md
rendered from the published skill — quoted content, verbatim
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)
If-Statements
Wrong:
if condition {
// happy path
} else {
// "shouldn't happen" - silently ignored
}
Right:
// If only one branch should ever be hit:
assert!(condition, "invariant violated: ...");
// OR
return Err(LimboError::InternalError("unexpected state".into()));
// OR
unreachable!("impossible state: ...");
Use if-statements only when both
(truncated - see the full file via the links below)
Read as markdown · JSON record · Browse the source repository
File tree — 1 file
.claude/skills/code-quality/SKILL.md