Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/iterate/sqlfu/llms.txt

Use this file to discover all available pages before exploring further.

sqlfu is a set of SQL-first tools for SQLite built around a simple idea: SQL should be the source language for your data layer. Schema lives in definitions.sql, migrations are plain SQL files, queries are checked-in .sql files, and TypeScript wrappers are generated automatically from those files. You write SQL; sqlfu derives everything else.

Philosophy

SQL first

Humans have been writing SQL for decades, and agents are excellent at generating and editing it. SQL is deep in the weights. sqlfu tries to keep that advantage rather than hiding it behind another abstraction layer. That is why sqlfu leans on SQL artifacts for every step:
  • schema in definitions.sql
  • migrations as SQL files
  • checked-in .sql queries
  • a SQL formatter
  • a SQL diff engine
The goal is not to make SQL disappear. The goal is to make SQL a better source language for the rest of the toolchain.

TypeScript second

TypeScript is the second language in sqlfu, not the first. You still get strong TypeScript output from SQL — generated wrappers, typed params, typed result rows, and a client surface that feels natural in an application. But you never write TypeScript to describe a query. You write SQL; sqlfu infers the types.

Core capabilities

Runtime client

A lightweight Client interface backed by adapters. Sync drivers stay sync — no spurious async creeping up your call stack.

SQL migrations

Schema diff engine turns definitions.sql changes into reviewable SQL migration files. No JavaScript migrations, no repeatable migrations, no down migrations.

Type generation

Each .sql query file becomes a TypeScript function with fully inferred params and result rows. No rewriting queries in a DSL.

Admin UI

Browser interface for schema, migrations, queries, and live data. Run npx sqlfu to start the local backend.

SQL formatter

Opinionated SQLite-first formatter — available as a CLI command, ESLint rule, or programmatic API.

Observability

Route query names to OpenTelemetry spans, Sentry errors, PostHog events, and Datadog metrics with a single instrument() call.

Project structure

sqlfu organizes your data layer into four artifacts:
your-project/
├── definitions.sql                          # desired schema — the source of truth
├── sqlfu.config.ts                          # sqlfu configuration
├── migrations/
│   └── 20260101000000_add_posts_table.sql   # reviewed migration history
├── sql/
│   ├── get-posts.sql                        # authored query files
│   └── .generated/
│       └── get-posts.sql.ts                 # generated TypeScript wrappers
└── db/
    └── app.sqlite                           # local SQLite database
  • definitions.sql — the schema you want right now: tables, views, triggers
  • migrations/ — the ordered history of schema changes as SQL files
  • sql/ — your checked-in query files, one or more per file
  • sql/.generated/ — TypeScript wrappers generated from your queries
The .sqlfu/ directory holds scratch databases used for schema diffing. It is safe to delete at any time.

New to sqlfu?

Get started in under 10 minutes

Build a posts app from scratch — schema in SQL, migrations drafted automatically, typed TypeScript wrappers generated from your query files, and a working getPosts(client, {limit: 10}) call with full IDE types.

Build docs developers (and LLMs) love