NEW Open source · Apache 2.0 · Java & Kotlin

Write real SQL.
Get smaq'd into typed code.

Simple Mapping for Advanced Queries

  • Every query checked by the real engine.
  • Null-correct Java & Kotlin, generated.
  • Built for coding agents. Loved by humans.

No ORM. No DSL. No surprises at 3 a.m. You (or your agent) write the SQL your database actually runs. smaq has the engine parse, plan and type every query against your real schema, then hands back small, typed code. The database is the compiler.

$ curl -fsSL https://smaq.dev/install.sh | bash

PostgreSQL · SQL Server · MySQL · MariaDB · SQLite · Oracle · Db2MCP built in

Illustrated loop · smaq check and smaq gen

Sound familiar?

Your data layer is lying to you.
smaq makes it confess at build time.

K.O. #1

"It compiled." Then prod said column does not exist.

Your ORM checked that a field exists in generated code. Nobody asked the database whether the query was actually valid.

K.O. #2

A String that was secretly null.

Outer joins, empty aggregates, CASE without ELSE: your types said non-null, your users got a stack trace.

K.O. #3

Your agent fought the DSL. The DSL won.

It knew exactly the SQL it wanted, then burned 40 turns translating it into a builder API it had barely seen.

SMAQ!

Write the SQL. smaq builds your schema from your own migrations in the real engine, asks that engine to describe every query, and turns its answer into compile errors, typed code, and fixes your agent can act on.

100%
queries engine-checked
in CI, against the schema you ship
7
engines, one license
SQL Server is not an upsell
≤5%
over hand-written JDBC
the bar, measured with JMH
0
reflection at runtime
GraalVM native, virtual threads
What you get

Advanced queries in. Simple mapping out.

Everything from the migration to the row record, in one toolchain with one config file. Every move practiced until it's a reflex.

01 · Advanced queries

If your database can run it, smaq can type it.

CTEs, window functions, LATERAL, MERGE, JSON, pgvector, PostGIS, keyset pagination. No lowest-common-denominator dialect and no emulation. What you write is what runs, byte for byte, and the exact SQL sits in the Javadoc of the method that calls it.

02 · Types that don't lie

Non-null means non-null. Proven, not hoped.

smaq follows nullability through outer joins, aggregates and expressions. When it can't prove a value is present, the type is @Nullable, and a diagnostic says why. Every key gets its own type, so a UserId can never slip into a TaskId parameter. JSpecify, NullAway-clean, and real Kotlin nullable types.

In the sum above, sum(estimate) is nullable because a project with no tasks sums to NULL. count(*) is a plain long, because it can't be.

03 · Agent-native

Your agent writes better SQL than DSL code. So let it.

Models have read far more SQL than any query builder. smaq meets them there: --json on every command, diagnostic codes that never change meaning, a schema digest that fits the whole database in a few hundred tokens, and an MCP server so the agent can check, generate and look things up in one call.

Generated code is small on purpose: an interface per query file, plus records, typed IDs and enums. No metamodel to burn through your agent's context window.

04 · Migrations included

The schema, the migrations and the code: one source of truth.

Versioned SQL migrations are built in and feed code generation directly. The linter flags what usually takes production down: dropped columns, index builds that block writes, renames that running code still uses, risky DDL without a lock timeout. The migration linting other tools paywall, free.

05 · Fast feedback, anywhere

Engine-checked in CI. Lightning-quick on your laptop.

A warm daemon keeps engines hot between checks. No Docker? PostgreSQL runs from embedded binaries, and static mode checks PostgreSQL, SQL Server and Db2 from the files alone, for review agents and tiny CI runners. Static results are labeled, conservative when unsure, and continuously checked against the real engine.

06 · Batteries included

A thin runtime. Every add-on you'd reach for.

The runtime is a thin layer over JDBC with no dependencies beyond the JDK and JSpecify. When you want more, add exactly what you need, and nothing you don't.

Choose your fighter

Round one. Fight!

ORMs hide your SQL. DSLs translate it. smaq just checks it.

MovesmaqORM
JPA / Hibernate
Query DSL
e.g. jOOQ
You write plain SQL✓◐JPQL; native queries unchecked◐through the DSL
The real engine checks every query at build time✓✗✗checks generated metadata
Nullability you can trust✓✗✗
Typed IDs and enums, generated✓◐by hand◐with converters
SQL Server, Oracle and Db2 at no cost✓✓✗commercial editions
Migrations and a migration linter built in✓✗✗
No lazy loading, no hidden SQL✓✗✓
Agent-native: JSON diagnostics, schema digest, MCP✓✗✗

A summary for comparison; each tool has strengths of its own. smaq keeps what the best of them got right: codegen from the schema, full access to advanced SQL, nested results without N+1.

Press start

Three commands. Flawless victory.

Install

One command puts smaq on your PATH: a native binary for macOS (Apple silicon), Linux (x64, arm64) and Windows (x64), checked against the release's signature before it runs. Engine checks also need a JDK 25.

curl -fsSL https://smaq.dev/install.sh | bash
irm https://smaq.dev/install.ps1 | iex

1Set up and write a query

smaq init writes smaq.toml, a db/ folder, and a section in your AGENTS.md so your agent knows the moves.

-- name: findByEmail :opt
-- @returns UserLogin
select id, email from users where email = :email;

2Check and generate

check verifies every query against the real engine (Docker or Podman, an embedded PostgreSQL, or your own database). gen writes the typed API. Commit both.

smaq check
smaq gen

3Call it

UserLogin is the name your agent gave the result, shared by every query that returns it. u.id() is a UserId, not a long. Columns that can be NULL are @Nullable; smaq proves the rest can't be.

AppDb db = AppDb.of(dataSource);
Optional<UserLogin> u = db.users().findByEmail("a@x");

Building with JumpKick? The [smaq] plugin regenerates and checks as part of every jk build.

Stop mapping by hand.
Start smaqing.

The database is the compiler.