DEV Community

Sugunah
Sugunah

Posted on

Dex tutorial: your first /dex:explore run, step by step

Part 2 of a short Dex by Exmergo series. Independent notes, based on the official docs and the open-source engine; not affiliated with Exmergo. Part 1 covered the guardrail design — this one is the operating procedure. Links to my free cheat sheet and starter pack are at the end.

Most people meet an agent-analytics tool at the wrong end: they ask a question first and debug the wrong answer later. Dex (Exmergo's open-source, Apache 2.0 analytics engine for coding agents) is built to run in the opposite order. Before any metric gets built, you run /dex:explore and let the agent map the warehouse — read-only — so the first real question is answered against a verified map instead of a guess. Here is that first run, in order.

Step 0: Start on DuckDB, not on a billed warehouse

Install Dex into your agent (Claude Code plugin, or skills for Codex, Cursor, Gemini CLI), point it at a local DuckDB file or a small exported slice of your data, and run the whole procedure there first. Every mistake in this tutorial is free on DuckDB and metered on BigQuery or Snowflake. Graduate to the real warehouse only after the loop feels boring.

Step 1: Run explore, and let it finish

/dex:explore
Enter fullscreen mode Exit fullscreen mode

Explore is read-only profiling. Per the docs, it:

  • Ranks tables so you see what is actually central to your data, not what the folder structure claims.
  • Profiles columns from aggregates — distributions and cardinality, not raw row dumps.
  • Infers and verifies joins — candidate join keys get tested, not just guessed from matching column names.
  • Establishes grain — what one row is in each table, the fact agents most often get silently wrong.
  • Flags PII columns — flagged, and kept out of the model's context.

The output lands in a local .dex/ directory. That cache is the point: the next session reads the map instead of re-scanning — and re-billing — your warehouse.

Step 2: Read the map like an auditor, not a fan

Before you ask anything, spend ten minutes checking three things:

  1. Grain statements. Pick two tables you know well. Does the recorded grain match reality — one row per order, or one row per order line? A wrong grain doubles revenue in exactly the queries you'll trust most.
  2. Verified joins. Look at which joins were verified and which were only inferred. Inferred joins are hypotheses; treat any metric built on one as provisional.
  3. PII flags. Confirm the columns you'd expect to be flagged actually are. The flag is what keeps them out of prompts and outputs.

This is also where you catch the classic trap: two tables with the same name in different datasets, one of them a stale snapshot. The ranking usually exposes it — the stale one profiles like a fossil.

Step 3: Ask the first question — through transform, as a plan

Now ask for a metric. /dex:transform returns a plan first, then diffs: dbt SQL models, schema tests, documentation, and the semantic-layer definitions on top. Review the diff the way you'd review a pull request — because that is what it is. Builds validate against dev targets only, and reads pass the SQL/cost guard described in part 1.

Pick a first metric whose correct answer you already know by hand. You're not testing arithmetic; you're testing whether the map, the joins, and the grain produce your number — and if not, whether the diff shows you why.

Step 4: Write down the convention the run just exposed

Every warehouse has a rule nobody wrote down: refunds netted in the month of the refund, not the month of the sale. The first run will surface at least one. That is what Dex Semantics declarations are for (part 1): record what a row means, what a join does to row counts, and how a number may add up — so the next session starts from your conventions instead of re-guessing them.

The pitfalls, collected

  • Skipping explore on a "simple" question. Simple questions are where wrong grain does the most damage, because nobody double-checks them.
  • Running your first session against the production warehouse. The DuckDB on-ramp is not a toy; it's the rehearsal.
  • Letting an inferred join harden into a metric. Verify it or label it provisional — in writing, in the model.
  • Trusting a stale map. Projects drift. /dex:maintain diffs the project against your .dex/ baseline on schema, volume, grain, and semantics, with proposed fixes you review. Run it on a cadence, not after an incident.
  • Pasting a credential when asked. Dex discovers credentials (ADC, connections.toml, dbt profiles) and never collects them. If anything in the loop asks you to paste a key, stop — you're not talking to Dex anymore.

Pre-flight checklist

  • [ ] Dex installed and the install verified in your agent
  • [ ] First run pointed at DuckDB or a dev target — not production
  • [ ] /dex:explore completed; .dex/ cache exists
  • [ ] Grain spot-checked on two tables you know
  • [ ] Verified vs. inferred joins reviewed
  • [ ] PII flags sanity-checked
  • [ ] First metric is one whose answer you already know
  • [ ] The convention the run exposed is written down as a semantic declaration

Do those eight things and your first real question starts from a map you have personally audited — which is the entire difference between an agent doing analytics and an agent doing improv.


Free: the install, the three commands, all 8 connectors, and the 6 safety rules on one page: https://payhip.com/b/zOwsR

Full starter pack: an 18-section tutorial, 12 copy-paste agent prompts, and 3 workflow worksheets (source onboarding, metric requests, weekly drift log): https://payhip.com/b/yUI8Y

Disclosure: the pack is my own independent product, sold on Payhip. The cheat sheet is free and covers the essentials. This article is based on Dex's official documentation and open-source repository — I have no relationship with Exmergo.

Top comments (0)