xiaohongshu
xiaohongshu
dbt-model-builder
Create dbt models following FF Analytics Kimball patterns and 2×2 stat model. This skill should be used when creating staging models, core facts/dimensions, or analytical marts. Guides through model creation with proper grain, tests, External Parquet configuration, and per-model YAML documentatio...
Full skill instructions
Create complete dbt models for the Fantasy Football Analytics project following Kimball dimensional modeling and the 2×2 stat model (actuals/projections × real-world/fantasy).
Use this skill proactively when:
The FF Analytics project follows:
_<model>.yml file per modelarguments: blockStaging models normalize raw provider data.
Steps:
Identify source: Determine provider and dataset
Design grain: Define one row per...
Create SQL using assets/staging_template.sql:
stg_{provider}__{dataset}.sql{{ source('{provider}', '{dataset}') }}Create YAML using assets/staging_yaml_template.yml:
_stg_{provider}__{dataset}.ymlRun and test:
make dbt-run --select stg_{provider}__{dataset}
make dbt-test --select stg_{provider}__{dataset}
Fact tables capture measurable events/processes.
Steps:
Design grain: Define composite primary key (e.g., player_id + game_id + stat_name)
Map foreign keys: Join to conformed dimensions (dim_player, dim_team, etc.)
Create SQL using assets/fact_template.sql:
fact_{process}.sqlmaterialized='table', external=true, partition_by=['season','week']Create YAML using assets/fact_yaml_template.yml:
dbt_utils.unique_combination_of_columns for grain testRun and test:
make dbt-run --select fact_{process}
make dbt-test --select fact_{process}
Critical: Fact tables MUST have grain uniqueness test with dbt 1.10+ syntax:
data_tests:
- dbt_utils.unique_combination_of_columns:
arguments:
combination_of_columns:
- column1
- column2
config:
severity: error
Dimensions provide descriptive context for facts.
Steps:
assets/dim_template.sql:
dim_{entity}.sqldbt_utils.generate_surrogate_key()SCD Type 2 pattern:
Marts provide wide-format, analytics-ready data.
2×2 Model Quadrants:
mart_real_world_actuals - NFL stats (actuals)mart_real_world_projections - Projected NFL statsmart_fantasy_actuals - Fantasy points (actuals, apply scoring rules)mart_fantasy_projections - Projected fantasy pointsSteps:
dim_scoring_rule{stat} * {points_per_stat}assets/mart_template.sql:
Example pivot:
SUM(CASE WHEN stat_name = 'passing_yards' THEN stat_value END) AS passing_yards,
SUM(CASE WHEN stat_name = 'passing_tds' THEN stat_value END) AS passing_tds
Real models from the codebase:
Templates for creating models:
CRITICAL: Every model must explicitly declare grain:
-- Grain: one row per...Staging models:
Fact tables:
Dimensions:
CRITICAL: Follow these two rules to avoid deprecation warnings:
data_tests: key (not tests:): dbt 1.5+ introduced data_tests: to distinguish from unit_tests:arguments:: dbt 1.10+ requires this for all generic tests with parameters# CORRECT - Column-level tests
columns:
- name: position
data_tests: # Use data_tests:, not tests:
- not_null
- accepted_values:
arguments: # Arguments must be nested
values: ['QB', 'RB', 'WR', 'TE']
- name: player_id
data_tests:
- not_null
- relationships:
arguments: # Wrap to, field in arguments:
to: ref('dim_player')
field: player_id
config: # config: is sibling to arguments:
where: "player_id > 0"
# CORRECT - Model-level tests
data_tests: # Use data_tests:, not tests:
- dbt_utils.unique_combination_of_columns:
arguments:
combination_of_columns:
- player_key
- game_id
# WRONG - Deprecated syntax (will cause warnings)
columns:
- name: position
tests: # WRONG - should be data_tests:
- accepted_values:
values: ['QB', 'RB'] # WRONG - should be under arguments:
tests: # WRONG - should be data_tests:
- relationships:
to: ref('dim_player') # WRONG - should be under arguments:
field: player_id
Key Points:
data_tests: (not tests:)arguments: wraps test parameters (to, field, values, combination_of_columns)config: is a sibling to arguments:, not nested insidenot_null and unique have no arguments, use directlyLarge models use External Parquet:
{{ config(
materialized='table',
external=true,
partition_by=['season', 'week']
) }}
stg_{provider}__{dataset}fact_{process} (e.g., fact_player_stats)dim_{entity} (e.g., dim_player)mart_{purpose} (e.g., mart_fantasy_actuals_weekly)_<model_name>.ymlxiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience