This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
sbt test # Run all tests
sbt "test;lintCheck" # Run tests + lint checks (what CI runs)
sbt "testOnly *QueryBuilderTest" # Run a single test class
sbt lint # Format + fix: scalafmtAll; scalafixAll
sbt lintCheck # Check formatting + linting without modifyingTests are forked (Test / fork := true). Test databases: H2 (in-memory, always available) and PostgreSQL (requires POSTGRES_HOST, POSTGRES_USER, POSTGRES_PASSWORD env vars).
- Scala 3 with
-feature -new-syntax -rewriteflags; all warnings are errors - Scalafmt: max 120 columns, Scala 3 dialect,
align = most - Scalafix: no
vars, nofinalize, removes unused imports/locals - No external runtime dependencies — only JDBC
usql is a lightweight JDBC toolkit for Scala 3 providing SQL interpolation, type-safe query building, and automatic CRUD generation.
Sql.scala—sql"..."string interpolation with type-safe parameter embeddingDataType[T]— Type class mapping Scala types to JDBC (ResultSetextraction,PreparedStatementfilling)RowDecoder[T]/RowEncoder[T]— ComposeDataTypeinstances for tuples and multi-column reads/writesQuery.scala/Update.scala/Batch.scala— Execute SQL statements against aConnection
SqlFielded[T]— Macro-derived field structure for case classesSqlTabular[T]— ExtendsSqlFieldedwith table name; derive viaSqlTabular.derived[MyCaseClass]Crd[T]/KeyedCrud[K, T]— Auto-generated Create/Read/Delete(/Update) operationsQueryBuilder[T]— Functional query builder withfilter,map,join,leftJoinColumnPath[T, R]— Type-safe column references for query builder predicatesMacros.scala— Scala 3 macro derivation poweringSqlFielded,SqlTabular, column paths
BasicProfile— CoreDataTypeinstances (primitives, strings, temporal types, arrays)H2Profile/PostgresProfile— Database-specific type support
TestBaseWithH2— Creates fresh in-memory H2 database per testPostgresSupport— Connects to external PostgreSQL when env vars are set