hermes

Write a dbt model

Writes a dbt model from business logic, with declared sources, a stated grain, unique, not_null and relationships tests, column docs and a safe incremental strategy. Use when adding a dbt model.

context

dbt models go wrong in quiet ways. A join fans out and nobody notices because no test pins the grain. A table name is hardcoded instead of using ref or source, so lineage and environments break. Business terms are implemented the way the author guessed. An incremental model filters on max(updated_at) with no lookback, so late-arriving rows are lost forever. Good dbt code states its grain, tests it, documents its columns and makes incremental loads safe to rerun.

task

Write a dbt model, materialised as , for this logic:

Sources and upstream models:

  1. State the grain as "one row per …" and the key that enforces it. If the business logic leaves the grain or a definition open, ask, or state the assumption and put it in Open questions.
  2. Declare sources in a sources YAML file with loaded_at_field and freshness thresholds where a load timestamp exists. Reference upstream data only through source() and ref().
  3. Add staging models only where a source needs renaming, casting or deduplication, one per source, following the project convention (stg_<source>__<table> if unknown).
  4. Write the model SQL as import CTEs, then logical CTEs, then a final select with an explicit column list. Handle nulls and duplicates in the sources explicitly, and note any time zone conversion.
  5. If materialised as incremental: set unique_key, choose incremental_strategy for the warehouse (merge where supported, otherwise delete+insert or insert_overwrite; check whether the project's dbt version supports microbatch), filter new rows inside is_incremental() with a lookback window for late-arriving data, set on_schema_change, and say when a full refresh is needed.
  6. Write a properties YAML file with the model and column descriptions and tests: unique and not_null on the key (or a combination-of-columns test for a composite key, naming the package it needs), relationships for foreign keys, accepted_values for categorical columns, and one singular test for the most important business rule. Use the data_tests: key on dbt 1.8 or later and tests: before that; if the project is on 1.8 or later and the rule is easier to show with fixed input rows, write a dbt unit test instead.
  7. Give the commands to build and test the model and its children, and a query that checks the grain.
constraints
  • Use only columns listed in the sources. If the logic needs a column that is not there, list it under Open questions instead of inventing it.
  • Keep SQL portable unless the warehouse is known. Flag any warehouse-specific function you use.
  • No select * in the final CTE. Keep Jinja to what the model needs.
  • Follow the project's naming and folder conventions if they are visible in the input.
output format

Assumptions and grain

The grain statement, the key, and each assumption.

Files

Each file in its own fenced block, preceded by its path (for example models/marts/fct_orders.sql, models/marts/_marts__models.yml, models/staging/_sources.yml).

Run and verify

Commands, the grain-check query, and what a passing result looks like.

Open questions

Definitions or columns that need confirmation.

2 required values still a placeholder; the assistant will ask for them.

details

kind
Prompt: a task you run by name to get one finished thing back
domain
Software engineering
category
Data engineering
level
Intermediate
made for
Data engineer, Data analyst
risk
read-only
version
v1.0.0 · experimental
reviewed
2026-10-02
works in
Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Antigravity, OpenCode, Windsurf, Zed, Continue, AGENTS.md, ChatGPT, claude.ai

Edit on GitHubReport a problem

use in

Hodios CLI
npx @hermes-hq/hodios install write-dbt-model --target claude-code
Agent Skills
npx skills add hermes-hq/hodios-dist --skill write-dbt-model -a claude-code
Add the Hodios marketplace (once)
claude plugin marketplace add hermes-hq/hodios-dist
Install the software-engineering plugin
claude plugin install hodios-software-engineering@hodios

The plugin brings every entry in this domain at once.

PromptData engineering

Design a star schema

Designs a dimensional model from the questions analysts need answered: business processes, grain, facts, dimensions, slowly changing dimension types and DDL. Use when building a warehouse layer.

design-star-schema
PromptData engineering

Write data-quality checks for a table

Writes data-quality checks for a table (freshness, volume, schema, validity, uniqueness, referential integrity, distribution) with severities, thresholds and owners. Use when a table feeds decisions.

write-data-quality-checks
PersonaData engineering

Data engineer

Acts as a data engineer who designs for idempotency, backfills and observability, treats schemas as contracts with their consumers, and asks who depends on each table before changing it.

data-engineer
PromptData engineering

Design a data pipeline

Designs a batch or streaming data pipeline sized to stated volumes, covering sources, schedule, idempotency, late data, backfills and monitoring. Use before building or replacing a pipeline.

design-data-pipeline
PromptData engineering

Design a relational database schema

Designs a relational schema from requirements and access patterns, with keys, constraints, types, indexes and DDL. Use when starting a new service or feature that stores data.

design-database-schema
PromptData engineering

Generate realistic seed data

Generates realistic, referentially consistent fixture data for a database schema, with labelled edge cases and no real personal data. Use for local development, demos and integration tests.

generate-realistic-seed-data