Quickstart
Go from zero to a verified context verdict in about ten minutes. Every command below runs against the live CLI.
Level 0: Try the offline demo (30 seconds, $0)
No API key, no cloud account, and no optional dependencies required:
uvx contextlift demo
The demo builds a small SQLite database in a temporary directory, runs canned baseline and context predictions as real SQL, applies the paired McNemar test, writes a static verdict.html, and prints three follow-up commands you can paste straight into your terminal.

For real projects, install the package with the extras you need:
pip install contextlift # zero deps: SQLite, lint, stats, verdict, MCP
pip install "contextlift[duckdb,yaml]" # add [postgres] [snowflake] [databricks] [bigquery] [lookml]
Level 1: Initialize and lint what you already have (2 minutes, $0)
Point contextlift init at your local database (and optional dbt project or SQL folder):
contextlift init --db warehouse.duckdb --dbt .
init does three things automatically:
- Writes
contextlift.yamlwithworkspace: .contextliftand a defaultpolicy:merge gate. - Introspects local SQLite or DuckDB table and column names (read-only) into starter
spec/schema/<table>.jsonfiles whenspec/schema/is empty. - Creates
spec/rules/00-definitions.md(and bootstrapsreview/review.csvif dbt verified queries or--sql-dirfiles are found).
Add one business rule in spec/rules/00-definitions.md:
# Core business definitions
- "Active ARR" -> On `subscriptions` (`status = 'active'`): `SUM(mrr_usd) * 12`.
Run the free linter and Cross-Layer Conflict Radar before making any paid model call:
contextlift lint --spec spec/ --dbt . --db warehouse.duckdb
lint checks rule hygiene, column coverage, cross-layer metric disagreements across Markdown spec/, dbt, Snowflake Semantic Views, Apache Ossie, and LookML, and (when --db is given) live enum literals against warehouse column values. Pass --db-role ROLE on Postgres, Snowflake, Databricks, or BigQuery to enforce read-only role scoping.
Level 2: Prove a change on real SQL (10 minutes)
Every measurement needs a clean gold answer key (golds.csv with id,question,gold_sql). You can bring your own, ingest production agent failures into a Steward review sheet:
contextlift ingest-failures --input prod_failures.jsonl --out review/review.csv
contextlift review --sheet review/review.csv --html --db warehouse.duckdb
Or mine warehouse query history on BigQuery (filtering for analytical multi-table queries with a scan ceiling):
contextlift log --db bq://BILLING --days 90 --min-tables 2 --require-analytical --max-bytes 1GB --out log.csv
contextlift mine --db bq://BILLING --queries log.csv --out candidates.csv --write-questions
Before running any agent, audit the gold set and create a sealed split:
contextlift gate --db warehouse.duckdb --golds golds.csv --timeout 60
contextlift split --golds .contextlift/runs/<gate>/outputs/golds_clean.csv \
--out-curate-csv curate.csv --out-holdout-csv holdout.csv \
--out-curate curate_ids.txt --out-holdout holdout_ids.txt
gate checks every gold statement against 16 defect classes (such as EXEC_FAIL, ZERO_ROWS, WHOLE_ROW, DEGENERATE, and TIMEOUT) and 4 warnings (MISSING_LITERAL, MISSING_ORDER, MISSING_PROJECTION, LITERAL_ON_WRONG_COLUMN).
Now run one paired evaluation round. Both arms execute the same questions on the same database:
contextlift round \
--runner openai:gpt-4.1 \
--budget 5 \
--out round.json \
--attestation-out .contextlift/attestation.json
Tip for small smoke-test sets: by default, round refuses any held-out split too small to prove a +10 point lift before spending money (6 unanimous disagreements is the smallest exact McNemar result with p < 0.05). For a small pilot set of 20 to 30 questions targeting a large fix, declare the larger effect explicitly with --target-lift 50.
Generate the static verdict report and the pull-request comment:
contextlift bundle
contextlift pr-summary --report round.json
.contextlift/verdict.htmlopens offline fromfile://with zero JavaScript.pr-summaryoutputs Markdown ready for a GitHub PR comment (or pass--format json).
Level 3: Serve or compile what you proved (1 command)
Serve the verified spec directly to Claude Code, Cursor, or any MCP client over local stdio JSON-RPC 2.0:
contextlift serve-mcp --spec spec/ --attestation .contextlift/attestation.json
get_attestation_status verifies the HMAC-SHA256 integrity seal, checks that the live spec/ SHA-256 hash matches the attested arm, and reports certified: true only when integrity passed, the spec is unmodified, the verdict is REAL GAIN, and any merge policy passed. Editing a single character in spec/ flips attestation_arm_matches and certified to false.
Or compile the spec back into your warehouse semantic layer:
contextlift compile --spec spec/ --target snowflake-yaml --attestation .contextlift/attestation.json --out semantic_view.yaml
contextlift compile --spec spec/ --target dbt-yaml --out models/semantic_metrics.yml
contextlift compile --spec spec/ --target ossie --out semantic_model.yaml
Where to go next
- How it works: paired test math, verdicts, safety badges, and pre-flight refusal gates.
- CI setup: GitHub Action, pre-commit hooks, merge policies, and attestations.
- Warehouses and agents: DuckDB, BigQuery, Postgres, Snowflake, Databricks, and every runner.
- Building a gold set: mining, failure ingestion, and the Business Steward review pack.
- CLI reference: the 8 core verbs and every grouped command.