Skip to content

Scythe

Write SQL. Get type-safe code. In any language.

Polyglot SQL-to-code generator with built-in linting and formatting.

Write SQL. Get type-safe code. In any language.

10 languages, 56 backends

Rust, Python, TypeScript, Go, Java, Kotlin, C#, Elixir, Ruby, PHP – plus plain JavaScript via the TypeScript backends’ JSDoc emit mode.

10 databases

PostgreSQL, MySQL, MariaDB, SQLite, DuckDB, CockroachDB, Redshift, SQL Server, Oracle, Snowflake.

58 built-in rules

23 lint + 35 audit rules – plus sqruff’s 69 style rules – catch bugs before they ship. scythe check adds 8 provenance and 7 schema drift rules on top.

Smart type inference

Nullability from JOINs, COALESCE, window functions, and aggregates.

Configurable row types

Pydantic, msgspec, Zod, or language defaults per backend.

@optional parameters

SQL rewriting for conditional filters without dynamic query building.

Terminal window
cargo install scythe-cli
# or
brew install Goldziher/tap/scythe
# or, with no Rust toolchain:
npm install --save-dev scythe-cli
pip install scythe-sql
-- @name GetUserOrders
-- @returns :many
SELECT u.id, u.name, o.total, o.notes
FROM users u
LEFT JOIN orders o ON u.id = o.user_id
WHERE u.status = $1;

Scythe knows o.total and o.notes are nullable (right side of LEFT JOIN) and generates type-safe code:

pub struct GetUserOrdersRow {
pub id: i32,
pub name: String,
pub total: Option<rust_decimal::Decimal>,
pub notes: Option<String>,
}