Skills

Querying The Dbt Information Schema

Use when answering questions about a dbt v2 project's own metadata, which models...

Install

npx skills add dbt-labs/dbt-agent-skills --skill querying-the-dbt-information-schema -g -a claude-code -y
Category
Testing
Updated
6d ago
License
Apache-2.0
Context cost
Mediumabout 3,000 tokens
Runs scripts
No, instructions only

What it does

Use when answering questions about a dbt v2 project's own metadata, which models, sources, tests, columns, configs, tags, packages or lineage exist, what is untested or undocumented, what depends on what, how long models took in the last run, or when using `dbt show --info`, `{{ info_schema() }}`, `--generate-info-schema`, `target/info_schema/`, or writing `dbt check` SQL. Prefer this over grepping YAML or parsing `manifest.json` on dbt v2.

Querying the dbt Information Schema

The dbt Information Schema is a set of SQL views over your project's metadata: models, sources, tests, columns, DAG edges, configs, and run results. You query it with DuckDB SQL, locally, without touching the warehouse.

Use it to answer "what is in this project" questions with one SQL query, instead of grepping YAML or loading a 70 MB manifest.json.

Contents

You want to…Go to
Check the project can use thisPrerequisites
Answer a one-off questionRoute A: dbt show (default)
Run many queries, script them, or use run_results_latestRoute B: DuckDB on the parquet files
Avoid wrong answers from tricky columnsColumn gotchas
Understand why a view is emptyWhat is populated when
Copy a working queryCommon queries
Enforce a rule on every buildTurning a query into a check

Which route? Use dbt show unless you have a reason not to. It always reads the metadata from the latest dbt command, and it needs nothing installed. Switch to DuckDB when it is installed and you will run many queries, because each dbt show call costs about 0.6 s versus about 0.1 s for DuckDB. The trade-off is that you must refresh the parquet files yourself.

Route A: dbt showRoute B: DuckDB on parquet
Table names{{ info_schema('models') }} (Jinja, bare view name)dbt.models, dbt_rt.run_results (after .read views.sql), or 'dbt.models.parquet'
FreshnessUpdated by build, run, check by defaultUpdated only by a command run with --generate-info-schema
Needsdbt v2dbt v2 once, plus the duckdb CLI or a parquet library
dbt_rt.run_results_latestNot availableAvailable
Speed per query~0.2, 0.7 s~0.1 s

Prerequisites

Read the whole SKILL.md on GitHub

More in Testing