PluginBench
Skill
Pass
Audit score 90

code-quality

tursodatabase/turso

Production-grade correctness rules for Rust: crash over corruption, assert invariants, avoid hacks.

What is code-quality?

A code-quality guide for writing reliable Rust code in production systems, particularly databases. Emphasizes correctness over convenience, explicit error handling, and pragmatic design patterns that prevent silent failures and data corruption.

  • Enforce correctness-first principles: crash rather than corrupt data or silently fail
  • Establish Rust patterns: make illegal states unrepresentable, use exhaustive matching, prefer enums over strings
  • Require explicit error handling and assertion of invariants instead of workarounds or quick hacks
  • Guide conditional logic: use if-statements only for expected branches, assert or error on impossible states
  • Prevent over-engineering: avoid premature abstractions, unnecessary docstrings, and impossible-scenario error handling
  • Highlight index mutation risks: verify ordering against SQLite to prevent index inconsistencies

How to install code-quality

npx skills add https://github.com/tursodatabase/turso --skill code-quality
Claude Code
Cursor
Windsurf
Cline

How to use code-quality

  1. 1.Review the Core Principle: correctness is paramount, crash over corrupt
  2. 2.Apply Correctness Rules: handle all errors, assert invariants, crash on invalid state, consider edge cases
  3. 3.Use Rust Patterns: make illegal states unrepresentable, use exhaustive matching, prefer enums, minimize allocations
  4. 4.Refactor if-statements: replace silent branches with assertions, errors, or unreachable!() macros
  5. 5.Write only necessary code: skip docstrings on unchanged code, delete unused code, avoid one-time abstractions
  6. 6.Double-check index mutations for correct ordering against SQLite behavior

Use cases

Good for
  • Writing database engine code where data corruption is worse than crashes
  • Reviewing Rust code for production systems to catch silent failures and unhandled edge cases
  • Designing error handling strategies that distinguish between expected and impossible states
  • Refactoring conditional logic to use assertions and exhaustive pattern matching instead of silent branches
  • Optimizing for performance-critical paths by minimizing allocations and writing CPU-friendly code
Who it's for
  • Rust developers working on production systems, especially databases
  • Teams building safety-critical or data-integrity-focused applications
  • Code reviewers enforcing correctness standards
  • Engineers transitioning from permissive languages to Rust's type system

code-quality FAQ

When should I use if-statements vs. assertions?

Use if-statements only when both branches are expected execution paths. Use assert!(), return Err(), or unreachable!() when one branch should never happen—this prevents silent failures.

Should I add error handling for impossible scenarios?

No. Don't add error handling for states that logically cannot occur. Instead, use assertions or unreachable!() to catch logic errors during development.

When is it okay to add comments?

Only for Rust SAFETY comments explaining unsafe blocks. Avoid code comments on logic; the code should be clear. Don't add docstrings to unchanged code.

How do I avoid over-engineering?

Make only changes directly requested or clearly necessary. Don't create abstractions for single-use operations. Three similar lines is better than premature abstraction.

Why is index mutation ordering critical?

Wrong ordering of index inserts, deletes, or conflict resolution causes index inconsistencies that are easy to miss. Always verify ordering against SQLite behavior.

Full instructions (SKILL.md)

Source of truth, from tursodatabase/turso.


name: code-quality description: General Correctness rules, Rust patterns, comments, avoiding over-engineering. When writing code always take these into account

Code Quality Guide

Core Principle

Production database. Correctness paramount. Crash > corrupt.

Correctness Rules

  1. No workarounds or quick hacks. Handle all errors, check invariants
  2. Assert often. Never silently fail or swallow edge cases
  3. Crash on invalid state if it risks data integrity. Don't continue in undefined state
  4. 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 branches are expected paths.

Comments

  • Don't add code comments, except for rust SAFETY comments.

Avoid Over-Engineering

  • Only changes directly requested or clearly necessary
  • Don't add features beyond what's asked
  • Don't add docstrings/comments to unchanged code
  • Don't add error handling for impossible scenarios
  • Don't create abstractions for one-time operations
  • Three similar lines > premature abstraction

Index Mutations

When code involves index inserts, deletes, or conflict resolution, double-check the ordering against SQLite. Wrong ordering causes index inconsistencies. and easy to miss.

Ensure understanding of IO model

  • Async IO model

Cleanup

  • Delete unused code completely
  • No backwards-compat hacks (renamed _vars, re-exports, // removed comments)

Single-use helpers

If a helper function has no meaning outside of a single use case, move it inside the function that uses it:

fn do_something() {
    
    something_specific();

    fn something_specific() {
    }
}