pgx
PGX — Lightweight Postgres for AI agents. Written in Rust. Thousands of isolated databases in one runtime. 🐘
翻譯準備中
個人 GitHub 帳號下公開儲存庫的擁有者可以登入並驗證所有權,自行管理介紹,無需管理員核准。
登入並產生驗證檔案,在 30 分鐘內將其提交至此儲存庫的預設分支。其他分支或分叉儲存庫中的檔案無效。然後在下方檢查檔案,即可無需管理員核准直接管理專案。請保留檔案以維持管理權限。
如需登入,將前往登入頁面。登入後請回到此處,再次點擊所選的驗證按鈕。
在專案資料夾中執行 /nomorevibe verify,即可驗證所有權並自行管理介紹。
一分鐘完成驗證One standard for data work, built into your AI coding agent
翻譯準備中
取自儲存庫 README
正在載入完整 README。
檢視完整 README ↗One standard for data work, built into your AI coding agent.
TrueQuery gives AI coding agents, and the data engineers, analytics engineers, BI engineers and analysts who work with them, one standard for how data work gets done: how pipelines and models are built, how SQL is written, how metrics are defined, and how the result is verified. A skill teaches the agent the procedure. A deterministic, offline checker verifies the work as it's written.
Quick start (Claude Code):
claude plugin marketplace add Analytically-ai/truequery, thenclaude plugin install truequery@analytically, then run/truequery initinside your project.Status: preview (0.1). Runs in Claude Code today, with more agents on the roadmap. What we've measured, and what we haven't: evidence and limits. Feedback and bug reports are welcome in issues.
There are two ways to run TrueQuery: the /truequery skill inside Claude
Code, where the agent does the work, and the truequery checker on its own
in a terminal or CI.
/truequery reviewA real session on the demo shop, reviewing one dbt model (sped up; it pauses on the checker's receipt and again on the recommendation). The agent runs the checker, reads everything the model depends on, checks each house definition against the code, confirms suspected bugs in the data, and ends with a merge recommendation.
/truequery askIn a run on the demo shop in October 2026,
/truequery ask how much money did we make last month? answered:
About $8,863 in March 2025
Revenue for March 2025 was $8,862.88 (US dollars). That's money from 20 completed, paid orders placed by 19 customers. No refunds were processed against those orders.
Why March 2025 and not last month: today is October 2026, but the shop's records stop on 24 April 2025. September 2026 has no data, so I used the most recent full month.
truequery reviewThe checker on its own, with no agent: the same command the skill runs under the hood. Offline and deterministic, with the receipt at the end.
/truequery init in your project, then
/truequery review models/ (or any SQL folder).uvx truequery detect path/to/sql/pip install truequery or uv tool install truequeryAsk an AI agent to "build a pipeline for the refunds data" and you get code that runs. You also get revenue that counts deleted accounts, a model with no stated grain, no tests, a metric made up on the spot, and nothing that tells you what was checked. Ask again tomorrow and you get a different answer. The model is capable. It's working without your definitions and without a standard.
Today's fixes don't hold up. Senior engineers review everything by hand, or the model is asked to check its own work: slow, expensive, and blind in exactly the same places. And the problems surface in review or in production instead of while the code is being written.
TrueQuery moves the standard into the loop where the work happens:
Every command follows one flow. It reads the repo, your definitions and the
schema first, then asks only what it can't find out: at most 5 questions,
each with a recommended default. It writes the contract (grain, keys,
columns with units, freshness, owner) before any code. It builds in your
project's own stack (dbt, Airflow, Dagster, plain SQL, pandas) with tests it
actually runs, then checks the result. It ends with a receipt: what was
built, what was checked, and what was not checked, and why. Your answers
go into DATA.md and the contracts, so nobody is asked twice.
Your definitions win. If a request contradicts how your team defines a number, say "average order value" over a column stored in cents, TrueQuery says so before writing anything. It follows your definition unless you confirm otherwise, and records the decision.
Where the standard comes from. TrueQuery ships 220 practices the
industry has converged on: dimensional modeling, warehouse storage and
performance, dbt conventions, data quality, governance and operations. Your
team's own conventions layer on top through /truequery init, DATA.md and
per-table contracts. A team without a veteran modeler still builds to the
standard, and a mature team gets its own house rules enforced.
Run them in your agent session, or just describe the task: the skill picks it up on its own.
| Command | For | What it does |
|---|---|---|
/truequery init | everyone | One-time setup: detects your stack, asks a few questions about your house definitions, writes DATA.md |
/truequery build … | data and analytics engineers | Build a pipeline, load or model end to end: contract, code, tests, checks, receipt |
/truequery ask … | non-technical users | A plain-English answer with how sure it is; the SQL sits under "How I got this" |
/truequery analyze … | analysts | Answer a data question to the standard, with sanity checks and caveats |
/truequery metric "…" | BI engineers | Define a metric once; metric check … finds every place that computes it differently |
/truequery review | everyone | Run every check, then the receipt and a critique of what checks can't see |
/truequery harden … | engineers | Make a model or load production-ready: idempotency, late data, schema changes, NULL and edge guards |
/truequery hooks on|off|status | everyone | Show or set up per-edit checks (with the plugin they're on already; to stop them, disable the plugin) |
Underneath the skill, the checker (truequery, short alias tq) looks for
SQL that silently returns the wrong answer. On the demo file
samples/bad_orders.sql:
$ truequery detect samples/bad_orders.sql
samples/bad_orders.sql:7:19 [error] sql/accidental-cross-join — no predicate links o: every row pairs with every row on the other side
fix: add ON <keys>, or CROSS JOIN if cartesian is intended
samples/bad_orders.sql:13:7 [error] sql/not-in-nullable-subquery — a NULL in the subquery makes NOT IN return zero rows
fix: rewrite as NOT EXISTS, or add WHERE col IS NOT NULL
samples/bad_orders.sql:17:14 [error] sql/count-star-after-left-join — COUNT(*) over an outer join counts 1 for unmatched rows
fix: count the nullable-side key instead, e.g. COUNT(o.<key>)
...
5 errors, 2 warnings in 1 file checked offline
truequery review adds the receipt. Its Not checked lines are the
point: they name what this pass could not verify. Here that's the data
itself; a limit such as integer division is listed only when a file
could hit it.
TrueQuery receipt
Checked 1 SQL file · contracts for 0 of 3 tables
Found 5 errors · 2 warnings
Not checked your data: TrueQuery reads files and never connects to your database
No contract customers, orders, staging_orders
= NULL, an unguarded DELETE, a WHERE that empties a
left join). At the end of each turn they run every enabled check over the
files touched. New findings go back to the agent once, a clean pass is
silent, and no edit is ever refused.--fail-on (default error); 2 is a usage or config
error; 3 means some files couldn't be checked (--allow-unverified turns
3 into 0).TrueQuery isn't an orchestrator, warehouse or catalog, and it doesn't ask you to change your stack. It sits alongside what you already use:
| Where | Status |
|---|---|
| Claude Code | Supported: skill, commands, hooks (on Windows the per-edit hooks need Git for Windows, which provides Git Bash) |
| Terminal and CI (any agent, any person) | Supported: truequery detect / review, JSON and SARIF |
| Codex, Muse Code | Hook configs included (truequery install --harness codex|muse), not yet verified live |
| Cursor, GitHub Copilot, Gemini CLI and others | Planned |
Needs Claude Code and uv (Python 3.11+).
claude plugin marketplace add Analytically-ai/truequery
claude plugin install truequery@analytically
Then open your project in Claude Code and run /truequery init.
The checker ships inside the plugin: the hooks and the agent always run
the version that matches the plugin, with nothing else to install. To use
truequery in a terminal or in CI:
pip install truequery # or: uv tool install truequery
That installs truequery and the short alias tq. If another tool in the
same environment already provides a tq command, use truequery. Contributors working from a
clone can install the local engine instead, from the repo root:
uv tool install ./plugin/engine
Stay up to date. TrueQuery is moving fast, and Claude Code doesn't
auto-update third-party plugins unless you ask it to. Turn it on under
/plugin → Marketplaces → analytically → Enable auto-update, or update by
hand with claude plugin update truequery@analytically, then
/reload-plugins. /truequery init explains this, and for a shared repo
offers to turn on auto-update for the whole team.
Every rule can be switched on or off, moved between the per-edit and
end-of-turn checks, or given a different severity: per project in
DATA.md, or for yourself in ~/.config/truequery/config.yaml.
truequery rules # what's on, and where each setting came from
truequery rules sql/accidental-cross-join # one rule: what it means, with a proof
truequery rules set sql/between-date-on-timestamp --enabled off
Agents never change rule settings: the skill forbids it, and if settings
change during a session, the agent is told to check with you. An agent may
only ignore a single line, and must give a reason
(truequery ignore add <rule> <path:line> --reason "..."). Every rule
earns its place on precision: one that misfires gets fixed or switched off
by default.
immediate checks run after every edit; stop checks run at the end of the
turn. Checks that are off by default aren't yet precise enough to run
unasked; switch them on with truequery rules set.
| Rule | Default | Build severity | What it catches |
|---|---|---|---|
dq/uniqueness-key-no-duplicates | off (stop) | error | Declared keys carry a zero-duplicate uniqueness check |
ingest/declare-source-freshness | off (stop) | warning | Every ingested source declares a freshness threshold |
model/unique-key-merge-key | on (stop) | error | Incremental merge models declare a non-null unique merge key |
orch/explicit-catchup-policy | off (stop) | warning | Scheduled DAGs set catchup explicitly |
sql/accidental-cross-join | on (stop) | error | Every join of two tables carries an explicit join predicate |
sql/average-of-ratios | off (stop) | warning | Aggregate a ratio as SUM(numerator) / SUM(denominator), not AVG of row ratios |
sql/between-date-on-timestamp | on (stop) | warning | Filter timestamps with a half-open range, not BETWEEN date literals |
sql/case-without-else-in-aggregate | on (stop) | advisory | A CASE that feeds arithmetic or an aggregate states its ELSE |
sql/count-star-after-left-join | on (stop) | error | Count child rows with COUNT(child.key), not COUNT(*), after a LEFT JOIN |
sql/distinct-dedup-bandaid | off (stop) | warning | SELECT DISTINCT never stands in for a grain fix |
sql/group-by-bare-column | on (stop) | warning | In engines that allow it, GROUP BY queries never project bare ungrouped columns |
sql/insert-explicit-column-list | on (stop) | warning | INSERT INTO names its target columns |
sql/integer-division-truncation | on (stop) | warning | Divide integers only after casting to a non-integer type |
sql/keyset-pagination | off (stop) | warning |
220 practices for data work, across 9 lifecycle domains (ingest, store,
model, orchestrate, data quality, semantics and metrics, consumption,
governance, operations) and 2 cross-cutting packs (SQL, Python). Each one
is a record with its rationale, examples and sources. The skill teaches all
of them; the checker enforces only the ones a file can prove.
truequery rules --all lists them.
TrueQuery starts where agents write data code and grows to cover the whole data lifecycle, from first draft to production.
Now: preview (0.1)
Next
SELECT * in production
models, incremental watermarks.Later
dq), migrations and backfills (change),
documentation kept in sync with the code (document), cost and
performance (optimize), and dialect porting (adapt).examples/shop/ is a small synthetic online shop: a DuckDB warehouse and a
dbt project, with house definitions and the messy data real teams have.
docs/try-the-demo.md has a prompt for each role
and what a good answer looks like.
Why not just put these rules in CLAUDE.md?
Instructions in CLAUDE.md are a good start, but nothing checks that the
agent followed them, and an agent reviewing its own work is blind in the
same places as its first draft. TrueQuery gives the agent a full procedure
and 220 sourced practices, then backs them with a deterministic checker
that runs on every edit and a receipt that says what wasn't verified. It
works alongside your CLAUDE.md; your house definitions go in DATA.md.
Why not just run SQLFluff?
SQLFluff checks style and layout. TrueQuery checks whether the logic
returns the right answer: a NOT IN that one NULL empties, a WHERE that
turns a LEFT JOIN into an inner join, a COUNT(*) that counts missing
rows. They don't overlap, so use both.
What does it cost in tokens? A little more. On 10 vague, realistic requests, TrueQuery cost about 19% more than plain Claude Code in tokens, and made no silent mistakes where plain Claude Code made three. The checker itself uses no tokens: it's plain code running on your machine. See Evidence and limits.
Which SQL dialects does the checker handle?
It parses SQL with sqlglot. Tested on
real code: BigQuery, PostgreSQL and DuckDB. Snowflake, Redshift,
Databricks and Spark, T-SQL, MySQL, Trino and sqlglot's other dialects are
parsed too, with less test coverage, so false alarms there are especially
welcome. /truequery init detects the dialect from your dbt or SQLMesh
config. You can also set it in DATA.md or with --dialect. A file that
doesn't parse is reported as not checked, never as clean.
What do I do about a false alarm?
truequery ignore add <rule> <path:line> --reason "..."truequery rules set <rule> --enabled off (add --scope user to
switch it off just for you).Does my code or data leave my machine? The checker makes no network calls and sends no telemetry. Claude Code still talks to its model provider as it always does, and TrueQuery doesn't change that. TrueQuery never connects to your warehouse.
See CONTRIBUTING.md for setup, tests and the
repository layout.
Apache-2.0. See LICENSE and NOTICE.
TrueQuery is built by Analytically.ai.
| Paginated reads use keyset seeks, not OFFSET |
sql/left-join-null-rejecting-where | on (immediate) | warning | Filters on the nullable side of an outer join live in ON |
sql/limit-requires-order-by | off (stop) | warning | Every LIMIT carries an ORDER BY |
sql/natural-join-explicit-keys | on (stop) | warning | Joins name their keys explicitly, never NATURAL JOIN |
sql/negative-filter-drops-nulls | off (stop) | warning | Negative filters on nullable columns state what happens to NULLs |
sql/nondeterministic-merge-keys | on (stop) | error | Merge and dedupe keys never use nondeterministic functions |
sql/not-in-nullable-subquery | on (stop) | error | NOT IN is never used against a nullable subquery |
sql/null-equality-comparison | on (immediate) | error | Test for NULL with IS NULL, never with = NULL or <> NULL |
sql/row-number-dedupe-tiebreaker | on (stop) | warning | ROW_NUMBER dedupe orders by a unique tiebreaker |
sql/set-operation-column-position | off (stop) | error | Set-operation branches align columns explicitly by position |
sql/unguarded-update-delete | on (immediate) | error | UPDATE and DELETE always carry a filter or an explicit full-table guard |
sql/union-all-default | off (stop) | warning | Bare UNION states its dedup intent; UNION ALL is the default for appends |