add-dbt-model
Skill1 starsChanged 6 months agoMITView on GitHub
Add a new dbt model (staging, intermediate, or marts) to an existing MDS deployment. Invoke when the user wants to transform raw data, build an analytics table, or expose a new metric in BigQuery.
In this repository6 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- add-mcp-skillSkill
- add-sourceSkill
- create-mdsSkill
- troubleshootSkill
- verify-pipelineSkill
The file
We split this skill into the rules it gives an agent
4 rules. About 0 are common, 2 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 34
Ask the user what they want to compute.
- Distinctive: line 49
Create the SQL file in the right folder.
- Very specific: line 50
Write the SELECT with explicit column lists (never SELECT * in marts).
- Very specific: line 51
Add a schema.yml entry with tests (not_null, unique where applicable, accepted_values for known categories).
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
add-dbt-model
Status: v0.10.0 (pre-test) — conventions + templates complete, with incremental-by-default for fact/event marts on BigQuery (cost control). Conventions and decision-tree references written; copy-paste templates (staging, marts dimension, marts incremental fact, schema, sources) included plus the
incremental-and-cost.mdreference; the Phase A–D playbook (classify → write → run/verify → commit) is in place.
What this skill does
Adds a new dbt model to the client's dbt project. Decides where the model belongs (staging / intermediate / marts) based on what the user describes, writes the SQL, adds tests, and runs it once to verify before committing.
Preflight
if [ ! -f .agentic-data-engineer.json ]; then
echo "[abort] not a managed MDS deployment"
exit 1
fi
# Confirm dbt is configured in this stack
jq -e '.stack.transform == "dbt_vps"' .agentic-data-engineer.json > /dev/null || {
echo "[abort] this MDS doesn't have dbt configured"
echo "Phase 2 of create-mds adds dbt — run that first"
exit 1
}Playbook outline
Phase A — Classify the model
Ask the user what they want to compute. Then decide:
| Layer | When |
staging (stg_<source>_<table>) | One-to-one with a raw source table, applies cleanup (rename columns, cast types, filter junk rows). One staging model per raw table. |
intermediate (int_<concept>) | Reusable logic that several marts will consume (e.g. int_orders_with_customer). Not exposed to end users. |
marts (analytics-ready, plain names like orders, revenue_monthly) | The deliverable. End users and BI tools query these. |
See references/staging-vs-marts.md and references/dbt-naming-conventions.md.
Materialization is a cost decision on BigQuery (bills by bytes scanned). Default by layer: staging = view; dimensions / small reports = table; fact/event marts = incremental (partitioned + clustered, insert_overwrite). A full-refresh table on a growing fact re-scans all history every run — the surprise-bill risk this default prevents. See references/incremental-and-cost.md.
Phase B — Write the model
- SSH to the VPS, locate the dbt project.
- Create the SQL file in the right folder.
- Write the
SELECTwith explicit column lists (neverSELECT *in marts). - Add a
schema.ymlentry with tests (not_null,uniquewhere applicable,accepted_valuesfor known categories).
Phase C — Run and verify
dbt run --select <model>in the venv on the VPS.dbt test --select <model>.- Spot-check the resulting table in BigQuery (
bq queryorSELECT * LIMIT 10).
Phase D — Commit
- Push to the client repo.
- Update marker history.
References
Conventions (complete):
references/dbt-naming-conventions.md— file/model/column naming, SQL style, tests pattern, canonical model shapesreferences/staging-vs-marts.md— decision tree for which layer a model belongs inreferences/incremental-and-cost.md— BigQuery cost control: when to go incremental, partition/cluster choice,maximum_bytes_billed, the GCP budget alert backstop, and the light cross-db convention (prefer dbt macros, flatten structs early — noadapter.dispatchframework)
Templates (complete) — copy into the client's dbt project and fill the <PLACEHOLDER> markers:
templates/staging.sql.template— canonical staging model:viewmaterialization,source+renamedCTEs, explicit casts, ingest-tool-agnostic load metadata (dlt's_dlt_load_id→load_id, join_dlt_loadsfor the timestamp; Airbyte legacy_airbyte_extracted_at→loaded_at),where <pk> is not nulltemplates/marts.sql.template— DIMENSION / small-report mart:tablematerialization, one CTE perref()input, ajoinedCTE, explicit final select. Heavily commented on when to usetable(dim) vsincremental(fact)templates/marts_incremental.sql.template— FACT / event mart (BigQuery default):incremental+insert_overwrite+partition_by+cluster_by+on_schema_change, with theis_incremental()look-back guardtemplates/schema.yml.template— model docs + tests (not_null/uniquePK,not_nullFK,accepted_valuesenum, optional monetary check) plus optional incremental-fact guards (partitionnot_null, recency, row-count)templates/sources.yml.template— rawsources:declaration (database<project>, schemaraw_<source>, freshness warn 26h / error 50h,loaded_at_field)
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

