Scythe compiles annotated .sql files into database access code — row types, query functions and
type mappings — that stays in sync with your schema. It reads your SQL statically, so generation
needs no database connection and no network: it runs in a pre-commit hook.
10 languages · 10 databases · 56 backends · 59 lint and audit rules · nullability inferred through
JOINs, CTEs and window functions
Every application that talks to a database needs glue: code that maps parameters in, maps result
rows out, and keeps the types aligned. It is tedious, easy to get subtly wrong, and it changes every
time the schema does.
Scythe deletes that layer. You keep writing SQL — the language your database already optimizes and
your team already knows — and the mapping code is compiled from it. The generated code is readable,
has no runtime dependency beyond your driver, and carries a provenance header so scythe check can
tell you when it has drifted from the schema it came from.
Where an ORM still wins: if your users choose the database, an ORM abstracts dialect differences
at runtime and scythe does not. Scythe targets one engine per configuration block, which is what
buys you engine-specific features and a real query planner. If you control the database, that trade
is worth making.
What you get
What it does
Docs
Type inference that reads the query
Nullability propagated through LEFT/RIGHT/FULL joins, COALESCE, CASE WHEN, aggregates and window functions — not just column constraints. CTEs (including recursive), RETURNING, enums, composites, arrays and JSON map to language-native types.
24 lint rules (UPDATE without WHERE, NULL compared with =, leading-wildcard LIKE, SELECT *) and 35 audit rules, plus sqruff's style rules through scythe fmt.
Security and migration-safety scanning: dangerous functions, GRANT to PUBLIC, literal passwords, SELECT * over PII, plus 19 migration rules for locking ALTERs and destructive DDL. Human, SARIF or JSON.
Verifies committed code still matches the SQL it was generated from, via 11 provenance rules. Given --database-url it adds 7 schema-drift rules against a live PostgreSQL catalog.
Live-database health checks: foreign keys without covering indexes, tables with policies but RLS disabled, duplicate indexes. PostgreSQL (13 checks) and MySQL/MariaDB (4 checks).
Row types as Pydantic, msgspec, dataclasses, Zod schemas or plain interfaces, depending on backend; structs_only (TypeScript and rust-sqlx) for a types-only package; type overrides for ltree, citext or PostGIS.