CI for the context your SQL agent reads.
Rules, dbt metrics, semantic views, LookML: every change gets a verdict before it merges.
Quickstart · Docs & live verdict · How it decides · Install
Some context helps. Some does nothing. Some makes your agent worse.
Each row is a paired run: same model, same questions, one context change. Every number is pinned by a test to a committed run.
uvx contextlift demo # no key, no cloud: canned answers, real SQL, the real paired test
1 Lint what you already have
2 minutes $0 no questions needed
$ contextlift lint --spec spec/ --dbt dbt/ --db warehouse.duckdb
[REFUSE] invalid enum literal: 00-finance:1
[REFUSE] cross-layer metric conflict: Active ARR (dbt vs spec)
2 refusal(s). Fix these before paying for a round: each one was measured to cost more than it takes to fix.
Your rule says 'ACTIVE', the warehouse holds 'active', and dbt counts trials as Active ARR while your spec does not. No model was called.
lint reads Markdown rules, dbt, Snowflake Semantic Views, Apache Ossie and LookML. Run it as the contextlift-lint pre-commit hook, or on every pull request:
# .github/workflows/context.yml
on: pull_request
permissions: { contents: read, pull-requests: write }
jobs:
context:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: moutasemalakkad/context-lift@v0.3.0 # lints, comments on the PR, fails on a refusal
with: { spec-dir: spec/, dbt-dir: dbt/ }
2 Prove a change on real SQL
10 minutes your warehouse any agent
Write down what the agent should know, and what a right answer looks like:
# spec/rules/00-finance.md
- "Active ARR" -> SUM(subscriptions.mrr_usd) * 12 WHERE subscriptions.status = 'active'
# golds.csv: a few dozen questions your users really ask, with the SQL that answers each
id,question,gold_sql
q1,What is active ARR?,SELECT SUM(mrr_usd) * 12 FROM subscriptions WHERE status = 'active'
q2,How many trials are running?,SELECT COUNT(*) FROM subscriptions WHERE status = 'trial'
Then run the same questions twice, once without the context and once with it:
contextlift init --db warehouse.duckdb # writes contextlift.yaml + schema/
contextlift round --runner openai:gpt-4.1 --budget 5 --out round.json # two arms, one verdict
contextlift bundle # .contextlift/verdict.html
contextlift pr-summary --report round.json # the comment below
Swap in anthropic:MODEL, gemini, any OpenAI-compatible server (--base-url: Ollama, vLLM) or your own agent (--runner command), or score two CSVs of answers you already have.
Every query runs read-only and row-capped, as the --db-role you pass. A question set too small to decide is refused before the first paid call.
3 Serve what you proved
1 command
contextlift serve-mcp --spec spec/ --attestation .contextlift/attestation.json
A local stdio MCP server for Claude Code, Cursor or any MCP client: six tools over your spec, from get_metric to get_attestation_status, which verifies the round's sealed HMAC integrity and spec hash binding. Or compile the spec into the layer you already run:
contextlift compile --spec spec/ --target snowflake-yaml # or dbt-yaml, ossie
Three results that changed what we build, and every number behind the chart
Sending everything beat perfect retrieval. Giving each question only its own sentence instead of all 22 KB scored -2.2 points across 450 questions (NOT PROVEN) and -8.6 points [-17.0, -0.8] on Toxicology: 7 fixed, 19 broke, p = 0.0290, REAL LOSS. Run
A BI model with no descriptions is not context. LookML read straight into rules: +2.0 points over 102 questions, p = 0.6875, NOT PROVEN. Looker's public project also says orders.id where the warehouse has orders.order_id. Run
Models almost never ask for more. Told to answer INSUFFICIENT rather than guess: 2 of 139 questions escalated, 1.4%. The run had no positive control, so it cannot tell a model that will not escalate from a prompt it ignores. Run
The headline row, recomputed offline from committed predictions with make example-bird (no key, no network):
paired ablation on 39 questions (execution accuracy)
without context : 30.8% [18.6%, 46.4%]
with context : 53.8% [38.6%, 68.4%]
lift : +23.1% [+1.2%, +43.6%] (the two rates subtracted; 95% interval on the paired difference)
context fixed : 12 questions
context broke : 3 questions
McNemar p : 0.0352 significant at 0.05
one repetition per arm: a single sample, not a measurement; run each arm again before quoting this
ruling : REAL GAIN
Every published result:
| Context change | Questions | Lift, points [95% CI] | p | Verdict |
|---|---|---|---|---|
| BIRD evidence sentences written by people, 3 databases (K=1, no holdout split) | 39 | +23.1 [+1.2, +43.6] | 0.0352 | REAL GAIN |
| BIRD evidence sentences, 11 databases (25.4% selective coverage, oracle table routing) | 65 | +18.5 [+4.6, +32.7] | 0.0044 | REAL GAIN |
| BEAVER verified-query worked examples, 97-table warehouse | 69 | +10.1 [+0.2, +21.8] | 0.0391 | REAL GAIN |
| LookML read into rules, no written descriptions | 102 | +2.0 [-4.8, +9.3] | 0.6875 | NOT PROVEN |
| Oracle selection vs the 22 KB blob, 3 databases | 450 | -2.2 [-5.9, +1.4] | 0.2451 | NOT PROVEN |
| Oracle selection vs the 22 KB blob, Toxicology | 139 | -8.6 [-17.0, -0.8] | 0.0290 | REAL LOSS |
On BEAVER the worked examples came after hand-written rules scored -0.7 on the working set. Intervals are paired score intervals. results.json names the committed file and the test behind every row.
WITHDRAWN: an earlier worked-examples penalty on thelook was one schema, one model, one run, and a scoring bug: _cmd_classes graded 22 stored-answer hits as errors. Raw run in docs/evidence/classes-thelook-cost.txt, postmortem in docs/results.md.
Install
pip install contextlift # zero dependencies: SQLite, lint, the stats, the verdict
pip install "contextlift[duckdb,yaml]" # or [postgres] [snowflake] [databricks] [bigquery] [lookml]
Warehouses DuckDB, SQLite, BigQuery. Postgres, Snowflake and Databricks in beta.
Context Markdown rules, dbt schema.yml and manifest.json, Snowflake Semantic Views, Apache Ossie, LookML.
Agents OpenAI, Anthropic, Gemini, Ollama or vLLM, your own CLI agent, or answers in a CSV.
Eight verbs complete one measurement: demo doctor gate split lint round bundle next. contextlift --help lists those eight. contextlift --help-all lists the rest, grouped.
Quickstart · How it works · CI setup · Warehouses & agents · CLI reference · Security · Contributing
src/context_lift/ is the package: 8 core verbs, every number on this page pinned by tests/ to a run in docs/evidence/ or examples/. make test runs green from a fresh clone, no credentials. Apache-2.0.
Metadata
Release files for contextlift 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| contextlift-0.3.0.tar.gz | 4.8 MB | With provenance | Details for contextlift-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| contextlift-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for contextlift-0.3.0-py3-none-any.whl |
Total release size: 5.7 MB
Release files / contextlift-0.3.0.tar.gz
| Download URL | contextlift-0.3.0.tar.gz |
|---|---|
| Size | 4.8 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
33c8104123e590f50f4a93a429d48695c8c6a1329ddb462dabb11818c3c9d6d3
|
|
BLAKE2b-256 checksum How to use checksums |
bf9c3041b9df7bea9d57bc9a2855521bf60525c590efc86467fef934b877aed3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 4, 2026.
Transparency logRelease files / contextlift-0.3.0-py3-none-any.whl
| Download URL | contextlift-0.3.0-py3-none-any.whl |
|---|---|
| Size | 883.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a3f88830399ad9250440f10858c2e64a5217b3662102a212c21f2ed94a0c5143
|
|
BLAKE2b-256 checksum How to use checksums |
d1cb43e53409ebf10aa7eecfa05da23adf4108ea241eb841dcbf966f0f2389e6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 4, 2026.
Transparency logSecurity for contextlift 0.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for contextlift-0.3.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 4, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.