"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.
Simple Mapping for Advanced Queries
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
column does not exist.Your ORM checked that a field exists in generated code. Nobody asked the database whether the query was actually valid.
String that was secretly null.Outer joins, empty aggregates, CASE without ELSE: your types said non-null, your users got a stack trace.
It knew exactly the SQL it wanted, then burned 40 turns translating it into a builder API it had barely seen.
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.
Everything from the migration to the row record, in one toolchain with one config file. Every move practiced until it's a reflex.
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.
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.
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.
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.
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.
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.
ORMs hide your SQL. DSLs translate it. smaq just checks it.
| Move | smaq | ORM 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.
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
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;
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
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.