Skip to content

context verify

The verify command compares your context files against a live database to detect drift — columns that were added, removed, or changed since the last introspection.

Terminal window
context verify --db <connection-url>
OptionDescriptionDefault
--source <name>Use a specific data_source from configFirst configured source
--db <url>Database URL override (postgres:// or path.duckdb)
--context-dir <path>Path to context files./context
--format <type>Output format: pretty, jsonpretty
Terminal window
context verify --db postgres://localhost:5432/myapp
Terminal window
context verify --db postgres://localhost:5432/myapp --source analytics
Terminal window
context verify --db postgres://localhost:5432/myapp --format json
Verifying against postgres://localhost:5432/myapp...
context/public/users.context.yaml
✓ All columns match
context/public/orders.context.yaml
✗ Column "discount_code" exists in DB but missing from context
✗ Column "legacy_status" in context but not found in DB
✗ Column "total" type mismatch: context says "integer", DB says "numeric(10,2)"
context/public/sessions.context.yaml
✗ Table "sessions" not found in database
Summary: 1 passed, 2 drifted, 1 missing

The verify command connects to your database, introspects tables, columns, sample values, golden queries, and guardrail filters, then runs all data/* lint rules against the results. This catches issues like missing tables, missing columns, type mismatches, stale sample values, and failing golden queries.

Terminal window
# Fail the build if context has drifted
context verify --db "$DATABASE_URL" --format json | jq -e '.drifted == 0'

When drift is detected, you have two options:

Terminal window
# Re-introspect to pick up DB changes (overwrites manual edits)
context introspect --db postgres://localhost/myapp --tables "orders"
# Or manually update the context file to match
# Then verify again
context verify --db postgres://localhost/myapp