scythe

Compile annotated SQL queries into type-safe database access code.

65|3|Updated Apr 4, 2026
One-click install
npx skills add https://github.com/Goldziher/scythe --skill scythe
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: scythe
Source: https://github.com/Goldziher/scythe/tree/main/skills/scythe
Command: npx skills add https://github.com/Goldziher/scythe --skill scythe

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Scythe removes the manual and error-prone boilerplate of turning SQL queries into strongly-typed, database-access code by compiling annotated SQL into ready-to-use functions, structs, and type mappings.

Core Features & Use Cases

  • Type-safe SQL-to-code generation: Write annotated SQL (with @name, @returns, etc.) and generate boilerplate across many languages and database engines.
  • Backend-driven support matrix: Select the correct scythe.toml backend (e.g., Rust sqlx, TypeScript pg, Python asyncpg) for your target language and database.
  • Built-in linting and formatting: Catch SQL issues early using scythe’s 93-rule linting (including sqruff rules) and format SQL consistently, including via pre-commit hooks.
  • Common migration and workflow integration: Migrate from sqlc, validate queries without generation, and wire formatting/linting into CI and developer workflows.

Quick Start

Use the scythe skill to generate code by running scythe generate after writing annotated queries and configuring scythe.toml.

Frequently Asked Questions about scythe

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I generate type-safe database access code from SQL queries?

Type-safe database access code is generated by compiling annotated SQL queries with comment annotations like @name and @returns into ready-to-use language-specific structs and functions. This eliminates manual boilerplate and prevents schema mismatches by validating queries before generation.

Can I use SQL code generation with Rust, TypeScript, and Python backends?

SQL code generation supports multiple language backends including Rust sqlx, TypeScript pg, and Python asyncpg. You select the appropriate backend for your target language and database engine in the scythe.toml configuration file to generate accurate type mappings.

How does annotated SQL linting and formatting work in a CI workflow?

Annotated SQL linting and formatting works by applying a 93-rule linter, including sqruff rules, to catch SQL issues early and enforce consistent formatting. These checks can be wired into developer workflows via pre-commit hooks and CI pipelines to validate queries without generating code.

What is the best way to migrate from sqlc to a multi-language SQL code generator?

Migrating from sqlc to a multi-language SQL code generator involves configuring the new backend in scythe.toml and re-annotating queries. This allows you to validate existing queries, enforce engine compatibility, and generate language-specific structs with correct nullability and overridden types across different database engines.

How to handle nullability and type overrides for generated database structs?

Nullability and type overrides for generated database structs are handled through configurable backends and type mappings defined in scythe.toml. The compiler applies these overrides during generation to ensure language-specific functions and structs reflect the correct null constraints and custom types.

Why does pre-generation validation fail for mismatched SQL schemas?

Pre-generation validation fails for mismatched SQL schemas because the compiler enforces engine and backend compatibility while parsing annotated SQL. It applies linting rules to catch structural issues early, ensuring that fragile query code and schema mismatches are resolved before generating the access layer.