206-dbt-analytics-engineering

A set of rules for building analytics data models with dbt, a tool that transforms warehouse data into tested and documented datasets.

In plain words
What is it for?
Use it to structure staging and reporting models, document data sources, add tests, track lineage, and choose how results are stored.
Why use it?
It keeps data projects organized and makes model quality, documentation, dependencies, and performance easier to maintain.

Cursor rule

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/hamzaamjad/cursor-rules/206-dbt-analytics-engineering
Clone the repo
git clone --depth 1 https://github.com/hamzaamjad/cursor-rules
Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 642 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00000 $0.00642
Opus 5 $0.00000 $0.00321
Sonnet 5 $0.00000 $0.00128
Haiku 4.5 $0.00000 $0.00064

Measured 2d ago against content hash 9f77cb04f3d7, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

206-dbt-analytics-engineering scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

rules/200-domain/206-dbt-analytics-engineering.mdc · 57 lines

What it actually says

dbt-analytics-engineering

Purpose: Establish a robust, scalable, and maintainable analytics engineering workflow using dbt.

1. Project Structure & Naming

  • Organize models into folders:
    • staging/ for raw table transformations
    • marts/ subdivided into core/, operational/, analytics/
  • Prefix folders and models using stg_, src_, dim_, fct_
  • Use snake_case and singular nouns for model names

2. Documentation & Lineage

  • Document all sources and models with YAML docs (description, meta, tags)
  • Generate and version the docs site via dbt docs generate in CI
  • Tag models for lineage grouping (e.g., business_domain, data_source)

3. Testing & Quality

  • Define schema tests: unique, not_null, accepted_values, relationships
  • Create custom generic tests for domain-specific rules (e.g., same_day_orders)
  • Use snapshots for Slowly Changing Dimensions (SCD1/SCD2)
  • Integrate pre-commit-dbt and require tests in PR checks

4. Performance & Materializations

  • Materialize models strategically:
    • view for lightweight transforms
    • table for heavy or reused results
    • incremental with unique_key and explicit on_schema_change
  • Partition and cluster large tables where supported (e.g., by date)
  • Avoid expensive operations (cross-joins, cartesian products)
  • Leverage warehouse-specific optimizations (e.g., Snowflake clustering)

5. Reusability & Macros

  • Centralize reusable logic in macros/ (e.g., watermark, safe_cast)
  • Use the dbt_utils package for common operations (surrogate_key, pivot)
  • Abstract environment-specific configs in dbt_project.yml via vars

6. Metrics & Semantic Layer

  • Define metrics in metrics/ files and build a centralized semantic layer
  • Leverage exposures for BI tool integration and lineage tracking
  • Validate metric definitions with endpoint tests

7. CI/CD & Versioning

  • Pin dbt core and package versions in packages.yml lockfile
  • Automate pipelines: dbt deps, dbt run, dbt test, dbt docs generate
  • Promote between environments via Git branches and release tags
  • Monitor run history and alert on failures or freshness threshold breaches

8. Observability & Monitoring

  • Configure sources.yml freshness thresholds and enforce via CI
  • Log run metadata (timing, row counts) to the run_results table
  • Integrate data observability frameworks (e.g., Great Expectations, Monte Carlo)

References: Consolidated from dbt Labs guides ("Analytics engineering: Six best practices", "Data quality best practices") and community standards.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 57 lines · 0 tokens per session scan A 9f77cb04f3d7

Subscribe to this mod's changes

206-dbt-analytics-engineering is a cursor rule published in the GitHub repository hamzaamjad/cursor-rules (2 stars, last pushed 1y ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 642 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.