mcpField
C
code-quality

code-quality

github.com/tursodatabaseTesting & quality25.1k1.8k installsUpdated today
Repository

About code-quality

A code-quality skill for Rust development, focused on correctness, explicit error handling, and avoiding unnecessary complexity. It is aimed at contributors working on production database code.

Key features

  1. 01Assert invariants and handle errors
  2. 02Represent invalid states with types
  3. 03Use exhaustive pattern matching
  4. 04Avoid unnecessary abstractions and comments
  5. 05Check index mutation ordering

Use cases

  1. 01Reviewing Rust changes for silent failure paths
  2. 02Maintaining database integrity during index updates

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/tursodatabase/turso --skill code-quality

After installing, type/code-qualityin Claude Code to confirm it loaded.

Details

From the project README

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

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() {
    }
}

Comments

Markdown supported