Skip to content

scaf.yaml

scaf uses a .scaf.yaml configuration file in your project root.

neo4j:
uri: bolt://localhost:7687
username: neo4j
password: password

The presence of a database key (like neo4j:) determines which database to use.

# Neo4j database configuration
neo4j:
uri: bolt://localhost:7687
username: neo4j
password: password
database: neo4j # optional
# Code generation settings
generate:
lang: go
adapter: neogo # inferred from neo4j + go if not set
out: ./generated
package: queries

Configure exactly one database. The database key determines the dialect automatically.

neo4j:
# Connection URI (required)
uri: bolt://localhost:7687
# Authentication
username: neo4j
password: password
# Target database (optional, defaults to neo4j)
database: neo4j

URI formats:

  • bolt://host:7687 — Standard connection
  • neo4j://host:7687 — Routing/cluster connection
  • bolt+s://host:7687 — SSL encrypted
  • neo4j+s://host:7687 — SSL with routing
postgres:
# Individual fields
host: localhost
port: 5432
database: mydb
user: postgres
password: password
sslmode: disable
# Or connection URI
uri: postgres://user:pass@localhost:5432/mydb?sslmode=disable

Settings for scaf generate:

generate:
# Target language (required for generate)
lang: go
# Database adapter (usually inferred)
adapter: neogo
# Output directory
out: ./queries
# Go package name
package: queries

If adapter is not set, it’s inferred from the database and language:

DatabaseLanguageDefault Adapter
neo4jgoneogo
postgresgopgx
mysqlgomysql
sqlitegosqlite

Override config with environment variables:

VariableDescription
SCAF_URIDatabase URI
SCAF_USERDatabase username
SCAF_PASSDatabase password
Terminal window
SCAF_PASS=secret scaf test

Command-line flags also override config:

Terminal window
scaf test --uri bolt://localhost:7687 --username neo4j --password secret

scaf looks for configuration in order:

  1. .scaf.yaml in current directory
  2. .scaf.yml in current directory
  3. scaf.yaml in current directory
  4. scaf.yml in current directory
  5. Same patterns in parent directories (up to filesystem root)
neo4j:
uri: bolt://localhost:7687
username: neo4j
password: password
generate:
lang: go
out: ./internal/queries
package: queries
postgres:
host: localhost
port: 5432
database: testdb
user: postgres
password: postgres
sslmode: disable
generate:
lang: go
adapter: pgx

Use environment variables for secrets:

neo4j:
uri: ${NEO4J_URI:-bolt://localhost:7687}
username: ${NEO4J_USER:-neo4j}
password: ${NEO4J_PASSWORD}
Terminal window
# In CI
export NEO4J_URI=bolt://neo4j-service:7687
export NEO4J_USER=neo4j
export NEO4J_PASSWORD=$SECRET_PASSWORD
scaf test

Or use flags:

Terminal window
scaf test \
--uri "$NEO4J_URI" \
--username "$NEO4J_USER" \
--password "$NEO4J_PASSWORD"