---
name: "dbt-semantic-layer-metrics-spec"
description: "Define unified business metrics once and query them consistently across all BI tools."
metadata:
  author: "dbt Labs"
  version: "1.0.0"
  runtime_compatibility:
    - "codex"
    - "claude-code"
    - "cursor"
    - "windsurf"
triggers:
  - "define dbt semantic model"
  - "create dbt metric spec"
  - "query metricflow metrics"
permissions:
  fs_read: true
  fs_write: "workspace"
  shell_exec: false
  net_access: false
---

# dbt Semantic Layer Metrics & Semantic Models

Implements the dbt Semantic Layer (MetricFlow): defining semantic models with entities, dimensions, and measures, declaring derived and cumulative metrics, and querying metric values via dbt CLI.

## When to Invoke
Invoke this skill whenever you need to:
- define dbt semantic model
- create dbt metric spec
- query metricflow metrics

## Execution SOP & Rules
1. Define semantic models in models/semantic/ with entities (primary/foreign keys) and dimensions.
2. Declare measures with aggregation types: sum, average, count_distinct, or expr.
3. Define metric definitions under metrics: section with type simple, derived, or cumulative.
4. Validate semantic layer graph using dbt parse and test queries via MetricFlow CLI.

## Verification Checklist
- Run local linting, syntax validation, and type-checks before reporting completion.
- Ensure all created or modified files adhere to workspace boundaries and avoid uncommitted secrets.
- Verify tests or build commands exit cleanly with return code 0.
