CI integration
Run syntaqlite in CI to enforce consistent SQL formatting and catch schema errors before they reach production.
If your project has a syntaqlite.toml,
syntaqlite reads its formatting options, schema routing, and check levels in CI
as well as during local development, so the commands below do not need extra
flags.
Format checking
Use --check to verify that files are already formatted without modifying
them. It exits with code 1 if any file would change:
syntaqlite fmt --check "**/*.sql"
Validation
Run schema-aware validation to catch unknown tables, columns, and functions:
syntaqlite analyze "**/*.sql"
When a schema is configured in syntaqlite.toml, unresolved references are
errors and cause a non-zero exit code. Without a schema, the same issues
are warnings and the exit code remains zero, so syntaqlite analyze
won't fail the build until you've explicitly declared your schema.
If you're not using syntaqlite.toml and passing files directly, file order
matters: put DDL files first so the schema is available when queries are
validated. Within each file, CREATE TABLE and CREATE VIEW statements are
discovered and made available to subsequent statements.
syntaqlite analyze schema.sql "queries/**/*.sql"
GitHub Actions
name: SQL lint
on: [pull_request]
jobs:
sql-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install syntaqlite
run: pip install syntaqlite
- name: Check formatting
run: syntaqlite fmt --check "**/*.sql"
- name: Validate SQL
run: syntaqlite analyze "**/*.sql"
Pre-push hook
Add a git hook to check SQL formatting before each push:
#!/bin/bash
# .git/hooks/pre-push
failed=0
for f in $(git diff --name-only origin/main --diff-filter=ACM | grep '\.sql$'); do
if ! diff -q <(syntaqlite fmt "$f") "$f" > /dev/null 2>&1; then
echo "Not formatted: $f"
failed=1
fi
done
exit $failed
Make it executable:
chmod +x .git/hooks/pre-push
Formatting at scale
The formatter reuses internal allocations across files, which keeps this command practical even for repositories with thousands of SQL files:
syntaqlite fmt -i "**/*.sql"