building-dbt-semantic-layer
Use when creating or modifying dbt Semantic Layer components — semantic models, metrics, dimensions, entities, measures, or time spines. Covers MetricFlow configuration, metric types (simple, derived, cumulative, ratio, conversion), and validation for both latest and legacy YAML specs.
What this skill does
# Building the dbt Semantic Layer
This skill guides the creation and modification of dbt Semantic Layer components: semantic models, entities, dimensions, and metrics.
- **Semantic models** - Metadata configurations that define how dbt models map to business concepts
- **Entities** - Keys that identify the grain of your data and enable joins between semantic models
- **Dimensions** - Attributes used to filter or group metrics (categorical or time-based)
- **Metrics** - Business calculations defined on top of semantic models (e.g., revenue, order count)
## Additional Resources
- [Time Spine Setup](references/time-spine.md) - Required for time-based metrics and aggregations
- [Best Practices](references/best-practices.md) - Design patterns and recommendations for semantic models and metrics
- [Latest Spec Authoring Guide](references/latest-spec.md) - Full YAML reference for dbt Core 1.12+ and Fusion
- [Legacy Spec Authoring Guide](references/legacy-spec.md) - Full YAML reference for dbt Core 1.6-1.11
## Determine Which Spec to Use
There are two versions of the Semantic Layer YAML spec:
- **Latest spec** - Semantic models are configured as metadata on dbt models. Simpler authoring. Supported by dbt Core 1.12+ and Fusion.
- **Legacy spec** - Semantic models are defined as separate top-level resources. Uses measures as building blocks for metrics. Supported by dbt Core 1.6 through 1.11. Also supported by Core 1.12+ for backwards compatibility.
### Step 1: Check for Existing Semantic Layer Config
Look for existing semantic layer configuration in the project:
- Top-level `semantic_models:` key in YAML files → **legacy spec**
- `semantic_model:` block nested under a model → **latest spec**
### Step 2: Route Based on What You Found
**If semantic layer already exists:**
1. Determine which spec is currently in use (legacy or latest)
2. Check dbt version for compatibility:
- **Legacy spec + Core 1.6-1.11** → Compatible. Use [legacy spec guide](references/legacy-spec.md).
- **Legacy spec + Core 1.12+ or Fusion** → Compatible, but offer to upgrade first using `uvx dbt-autofix deprecations --semantic-layer` or the [migration guide](https://docs.getdbt.com/docs/build/latest-metrics-spec). They don't have to upgrade; continuing with legacy is fine.
- **Latest spec + Core 1.12+ or Fusion** → Compatible. Use [latest spec guide](references/latest-spec.md).
- **Latest spec + Core <1.12** → Incompatible. Help them upgrade to dbt Core 1.12+.
**If no semantic layer exists:**
1. **Core 1.12+ or Fusion** → Use [latest spec guide](references/latest-spec.md) (no need to ask).
2. **Core 1.6-1.11** → Ask if they want to upgrade to Core 1.12+ for the easier authoring experience. If yes, help upgrade. If no, use [legacy spec guide](references/legacy-spec.md).
### Step 3: Follow the Spec-Specific Guide
Once you know which spec to use, follow the corresponding guide's implementation workflow (Steps 1-4) for all YAML authoring. The guides are self-contained with full examples.
**Minimal latest spec example** (dbt Core 1.12+ / Fusion) — use this as your starting point to avoid guessing the structure:
```yaml
# models/fct_orders.yml
models:
- name: fct_orders
semantic_model:
agg_time_dimension: order_date
entities:
- name: order
type: primary
expr: order_id
- name: customer
type: foreign
expr: customer_id
dimensions:
- name: order_date
type: time
type_params:
time_granularity: day
- name: status
type: categorical
measures:
- name: revenue
agg: sum
expr: amount
metrics:
- name: total_revenue
type: simple
label: Total Revenue
type_params:
measure: revenue
```
**Minimal legacy spec example** (dbt Core 1.6–1.11) — use this if the project is on an older version:
```yaml
# models/sem_orders.yml
semantic_models:
- name: orders
model: ref('fct_orders')
entities:
- name: order
type: primary
expr: order_id
dimensions:
- name: order_date
type: time
type_params:
time_granularity: day
measures:
- name: revenue
agg: sum
expr: amount
metrics:
- name: total_revenue
type: simple
label: Total Revenue
type_params:
measure: revenue
```
## Entry Points
Users may ask questions related to building metrics with the semantic layer in a few different ways. Here are the common entry points to look out for:
### Business Question First
When the user describes a metric or analysis need (e.g., "I need to track customer lifetime value by segment"):
1. Search project models or existing semantic models by name, description, and column names for relevant candidates
2. Present top matches with brief context (model name, description, key columns)
3. User confirms which model(s) / semantic models to build on / extend / update
4. Work backwards from users need to define entities, dimensions, and metrics
### Model First
When the user specifies a model to expose (e.g., "Add semantic layer to `customers` model"):
1. Read the model SQL and existing YAML config
2. Identify the grain (primary key / entity)
3. Suggest dimensions based on column types and names
4. Ask what metrics the user wants to define
Both paths converge on the same implementation workflow.
### Open Ended
User asks to build the semantic layer for a project or models that are not specified. ("Build the semantic layer for my project")
1. Identify high importance models in the project
2. Suggest some metrics and dimensions for those models
3. Ask the user if they want to create more metrics and dimensions or if there are any other models they want to build the semantic layer on
## Metric Types
Both specs support these metric types. For YAML syntax, see the spec-specific guides.
### Simple Metrics
Directly aggregate a single column expression. The most common metric type and the building block for all others.
- **Latest spec**: Defined under `metrics:` on the model with `type: simple`, `agg`, and `expr`
- **Legacy spec**: Defined as top-level `metrics:` referencing a measure via `type_params.measure`
### Derived Metrics
Combine multiple metrics using a mathematical expression. Use for calculations like profit (revenue - cost) or growth rates (period-over-period with `offset_window`).
### Cumulative Metrics
Aggregate a metric over a running window or grain-to-date period. Requires a [time spine](references/time-spine.md). Use for running totals, trailing windows (e.g., 7-day rolling average), or period-to-date (MTD, YTD).
Note: `window` and `grain_to_date` cannot be used together on the same cumulative metric.
### Ratio Metrics
Create a ratio between two metrics (numerator / denominator). Use for conversion rates, percentages, and proportions. Both numerator and denominator can have optional filters.
### Conversion Metrics
Measure how often one event leads to another for a specific entity within a time window. Use for funnel analysis (e.g., visit-to-purchase conversion rate). Supports `constant_properties` to ensure the same dimension value across both events.
## Filtering Metrics
Filters can be added to simple metrics or metric inputs to advanced metrics. Use Jinja template syntax:
```
filter: |
{{ Entity('entity_name') }} = 'value'
filter: |
{{ Dimension('primary_entity__dimension_name') }} > 100
filter: |
{{ TimeDimension('time_dimension', 'granularity') }} > '2026-01-01'
filter: |
{{ Metric('metric_name', group_by=['entity_name']) }} > 100
```
**Important**: Filter expressions can only reference columns that are declared as dimensions or entities in the semantic model. Raw table columns that aren't defined as dimensions cannot be used in filters — even if they appear in a measure's `expr`.
## External Tools
This skill references [dbt-autofix](https://github.comRelated in Ads & Marketing
ads
IncludedMulti-platform paid advertising audit and optimization skill. Analyzes Google, Meta, YouTube, LinkedIn, TikTok, Microsoft, and Apple Ads. 250+ checks with scoring, parallel agents, industry templates, and AI creative generation.
banana
IncludedAI image generation Creative Director powered by Google Gemini Nano Banana models. Use this skill for ANY request involving image creation, editing, visual asset production, or creative direction. Triggers on: generate an image, create a photo, edit this picture, design a logo, make a banner, visual for my anything, and all /banana commands. Handles text-to-image, image editing, multi-turn creative sessions, batch workflows, and brand presets.
rpg-migration-analyzer
IncludedAnalyzes legacy RPG (Report Program Generator) programs from AS/400 and IBM i systems for migration to modern Java applications. Extracts business logic from RPG III/IV/ILE source code, identifies data structures (D-specs), file operations (F-specs), program dependencies (CALLB/CALLP), and converts RPG constructs to Java equivalents. Generates migration reports, complexity estimates, and Java implementation strategies with POJO classes, JPA entities, and service methods. Use when modernizing AS/400 or IBM i legacy systems, analyzing RPG source files (.rpg, .rpgle, .RPGLE), converting RPG to Java, mapping data specifications to Java classes, planning legacy system migration, or when user mentions RPG analysis, Report Program Generator, RPG III/IV/ILE, AS/400 modernization, IBM i migration, packed decimal conversion, or mainframe application rewrite.
brand-library-architect
IncludedBuild a complete brand library for a product — visual asset render pipeline, brand documentation set (BRAND, COPY, MANIFESTO, BIOS, FAQ, GLOSSARY, TONE, PRICING), open-source convention files (README, CONTRIBUTING, SECURITY, CODE_OF_CONDUCT), and a self-contained press kit. This skill should be used when the user asks to "build a brand library / brand kit / press kit / brand assets" for a product, "set up a brand library workflow," "create a positioning manifesto plus visual identity," or any combination of brand documentation + visual asset pipeline. Apply phase-by-phase or run end-to-end. Templates are product-agnostic and use {{TOKEN}} placeholders the skill prompts the user to fill.
writing-tech-post
IncludedAuthors engineering blog posts end-to-end: launch deep-dives, incident postmortems, architecture migrations, performance case studies, tutorials, AI/agent system writeups, security disclosures, and research-to-product translations. Picks the correct archetype, plans the abstraction ladder, enforces an evidence cadence (diagrams, benchmarks, profiles, traces, code, ablations), tunes voice against publisher house styles (Datadog, Vercel, GitHub, AWS, Meta, Cloudflare, Jane Street), and runs a pre-publish gate for narrative momentum and disclosure ethics. Use when drafting a new engineering post, restructuring a draft that feels flat, deciding which evidence form belongs where, validating that depth and product context are balanced, or preparing a postmortem, migration, or performance narrative for external publication. Do not use for API reference documentation, README authoring, marketing copy, release notes, generic SEO content, ghost-written executive thought leadership, or non-engineering long-form essays.
blog-google
IncludedGoogle API integration for blog performance: PageSpeed Insights, CrUX Core Web Vitals with 25-week history, Search Console performance, URL Inspection, Indexing API, GA4 organic traffic, NLP entity analysis for E-E-A-T, YouTube video search for embedding, and Google Ads Keyword Planner. Progressive feature availability based on credential tier (API key, OAuth/service account, GA4, Ads). Shares config with claude-seo at ~/.config/claude-seo/google-api.json. Use when user says "google data", "page speed", "core web vitals", "search console", "indexation", "GA4", "keyword research", "nlp entities", "blog performance", "youtube search", "google api setup".