agentsclimarketplace

Staff analytics engineer

Skill WayneBanksy/wayneys_claude/skills/staff-analytics-engineer

Your dedicated dbt analytics engineering expert. Invoke this skill — instead of answering from general knowledge — whenever the request involves dbt: building or modifying staging, intermediate, or mart model .sql files; authoring schema.yml or sources.yml; configuring incremental models; debugging dbt test failures; writing dbt macros; designing mart layer architecture; or setting up source freshness checks. Also handles MetricFlow semantic layer metrics and wealth management financial analytics (AUM, returns, P&L) modeled in dbt. Skip for Snowflake query optimization, Prefect/Airflow orchestration, and BI frontend work.From its SKILL.md

Install
npx -y skills add WayneBanksy/wayneys_claude --skill staff-analytics-engineer

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

2 things to look at

  • no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
  • 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

SKILL.md

15.8 KB, as published. Nobody here has run it

Staff Analytics Engineer

Overview

Staff-level guidance for dbt-based analytics engineering at BBR Partners (wealth management). Covers dbt project architecture, model layer design, data testing and documentation, semantic layer metric definitions, dbt CI/CD, and analytics engineering best practices in Snowflake. Financial metrics (AUM, returns, P&L attribution, benchmark comparison) must be audit-ready and trusted by advisors and leadership.

⚠️ Critical Rules

  1. NEVER put raw source table names in mart or intermediate models. Marts reference other models via {{ ref() }} only. Source tables are accessed exclusively through staging models via {{ source() }}. If a raw table name appears anywhere outside sources.yml and staging models, STOP and fix it. No exceptions.

  2. NEVER put business logic in staging models. Staging is for renaming, recasting, and light cleaning ONLY. Joins, filters, aggregations, calculations, and business rules belong in intermediate or mart models. A staging model that calculates returns or applies fee schedules is violating its layer contract. Light cleaning means: CAST, LOWER/UPPER for standardization, surrogate key generation, and type-safe COALESCE (e.g., COALESCE(nullable_int, 0) for pure type safety). Light cleaning does NOT mean: COALESCE that encodes a business default (e.g., "closed accounts have zero market value"), joins of any kind, CASE WHEN with business conditions, or filters that remove rows. If the NULL handling requires domain knowledge to understand, it is business logic — move it to intermediate.

  3. NEVER create a model without tests. Every mart model MUST have at minimum not_null and unique tests on its primary key in schema.yml. Fact tables MUST have relationships tests to their dimensions. A model with zero tests is a liability — it will silently produce wrong numbers.

  4. NEVER create a model without column descriptions. Every column in every model MUST have a description in schema.yml. The description states: what the column means, its unit (dollars, bps, shares), and any business rules applied. At BBR, undocumented financial columns erode trust.

  5. NEVER define metrics in BI tools. portfolio_return_pct, aum_total, benchmark_excess_return are MetricFlow metric definitions — not Tableau calculated fields. One metric definition in the semantic layer, many consumers. If a metric exists only in Tableau, it must be moved to MetricFlow.

  6. NEVER run dbt run --full-refresh on large fact tables without explicit approval. Full refresh on a 500M-row table burns Snowflake credits and causes downtime. Incremental models should be designed to never need full refresh except in controlled migration scenarios. Ask before running full refresh on any table over 10M rows.

  7. ALWAYS use unique_key in incremental models. All incremental models MUST have a unique_key for MERGE semantics. A dbt run must never duplicate rows. The incremental filter MUST reference {{ this }} — never a hardcoded date.

  8. ALWAYS configure source freshness on every source. Every source() in sources.yml MUST have a freshness block with warn_after and error_after. The morning dbt job must fail fast if a source stopped updating — before analysts see stale numbers.

  9. ALWAYS pair schema.yml with every new model in the same PR. When creating a new .sql model file, the corresponding schema.yml entry (model name, description, column descriptions, tests) MUST be created in the same PR. A PR containing a new model without a corresponding schema.yml entry must not be merged. Never create a model "and add the schema later."

Project Structure

Three-Layer Architecture

models/
├── staging/           # 1:1 with sources. Rename, cast, surrogate keys only.
│   ├── custodian/
│   │   ├── stg_custodian__positions.sql
│   │   ├── stg_custodian__transactions.sql
│   │   └── _custodian__sources.yml
│   └── market_data/
│       ├── stg_market_data__prices.sql
│       └── _market_data__sources.yml
├── intermediate/      # Joins, business logic, prep for marts.
│   ├── int_positions_enriched.sql
│   └── int_returns_daily.sql
└── marts/             # Consumption-ready star schema.
    ├── finance/
    │   ├── fct_daily_positions.sql
    │   ├── fct_transactions.sql
    │   ├── dim_accounts.sql
    │   ├── dim_securities.sql
    │   └── _finance__models.yml
    └── reporting/
        ├── fct_portfolio_returns.sql
        └── _reporting__models.yml

Layer rules:

  • Staging: 1:1 with source tables. {{ source() }} only. Rename columns to snake_case, cast types, add dbt_utils.generate_surrogate_key(). No joins, no filters, no aggregations.
  • Intermediate: Joins, business logic, transformations. References staging via {{ ref() }}. Named int_ prefix. Used when the transformation is complex enough to warrant a separate step.
  • Marts: Star schema fact and dimension tables. References intermediate or staging via {{ ref() }}. Consumption-ready for BI and reporting. Expose natural business keys (account_id, cusip, trade_id) alongside surrogate keys.

Naming Conventions

TypePatternExample
Stagingstg_{source}__{entity}stg_custodian__positions
Intermediateint_{description}int_positions_enriched
Factfct_{event/activity}fct_daily_positions
Dimensiondim_{entity}dim_accounts
Source YAML_{source}__sources.yml_custodian__sources.yml
Model YAML_{domain}__models.yml_finance__models.yml

Primary Stack

Always recommend these defaults first:

ComponentTool
WarehouseSnowflake
Transformationdbt Core (local dev), dbt Cloud (CI, scheduled runs, docs)
Testingdbt generic tests + dbt-expectations (financial-grade assertions)
Quality MonitoringElementary (dbt-native), Monte Carlo (platform)
Documentationdbt docs — full descriptions on every model and column
Lineagedbt DAG (native) + Monte Carlo (cross-tool)
Packagesdbt-utils, dbt-date, dbt-expectations, dbt-audit-helper
BI LayerTableau (fed from Gold marts)
Semantic Layerdbt Semantic Layer + MetricFlow
Version ControlGit + GitHub; PR review with dbt CI job
LintingSQLFluff (--dialect snowflake), dbt-checkpoint (pre-commit)

Secondary (mention only when explicitly relevant): SQLMesh, Coalesce, Looker + LookML, Census/Hightouch (reverse ETL).

Key Patterns

Incremental Models

{{ config(
    materialized='incremental',
    unique_key='position_sk',
    on_schema_change='append_new_columns'
) }}

SELECT
    {{ dbt_utils.generate_surrogate_key(['account_id', 'security_id', 'as_of_date']) }}
        AS position_sk,
    account_id,
    security_id,
    as_of_date,
    market_value,
    shares_held

FROM {{ ref('int_positions_enriched') }}

{% if is_incremental() %}
WHERE as_of_date > (SELECT MAX(as_of_date) FROM {{ this }})
{% endif %}

Snapshots (SCD Type 2)

{% snapshot snp_accounts %}
{{ config(
    target_schema='snapshots',
    unique_key='account_id',
    strategy='timestamp',
    updated_at='updated_at',
) }}

SELECT * FROM {{ source('custodian', 'accounts') }}

{% endsnapshot %}

Use snapshots for every dimension where history matters: clients, accounts, advisors, fee schedules. dbt manages dbt_valid_from, dbt_valid_to, and dbt_scd_id automatically.

MetricFlow Metric Definition

semantic_models:
  - name: daily_positions
    defaults:
      agg_time_dimension: as_of_date
    entities:
      - name: position
        type: primary
        expr: position_sk
      - name: account
        type: foreign
        expr: account_id
    measures:
      - name: total_market_value
        agg: sum
        expr: market_value
      - name: position_count
        agg: count
    dimensions:
      - name: as_of_date
        type: time
        type_params:
          time_granularity: day

metrics:
  - name: aum_total
    type: simple
    type_params:
      measure: total_market_value
  - name: portfolio_return_pct
    type: derived
    type_params:
      expr: (ending_value - beginning_value) / beginning_value
      metrics:
        - name: ending_market_value
        - name: beginning_market_value

Source Freshness

sources:
  - name: custodian
    database: raw
    schema: custodian_data
    freshness:
      warn_after: { count: 12, period: hour }
      error_after: { count: 24, period: hour }
    loaded_at_field: _loaded_at
    tables:
      - name: positions
        description: "Daily end-of-day position snapshots from custodian feed."
      - name: transactions
        description: "Trade and cash movement transactions."

dbt-expectations for Financial Assertions

models:
  - name: fct_portfolio_returns
    columns:
      - name: return_pct
        tests:
          - not_null
          - dbt_expectations.expect_column_values_to_be_between:
              min_value: -1.0
              max_value: 5.0
              row_condition: "as_of_date >= '2020-01-01'"
      - name: benchmark_return_pct
        tests:
          - not_null
          - dbt_expectations.expect_column_values_to_be_between:
              min_value: -0.5
              max_value: 0.5

Seeds for Reference Data

seeds/
├── asset_class_codes.csv
├── sector_mappings.csv
├── benchmark_definitions.csv
└── custodian_ids.csv

Small, slowly-changing lookup tables belong as dbt seeds — version-controlled, documented, always present. Not external source tables.

Slim CI

# .github/workflows/dbt-ci.yml
- name: dbt CI
  run: |
    dbt compile --select state:modified+
    dbt test --select state:modified+
  env:
    DBT_STATE: ./target-base

Only changed models and their downstream dependencies are compiled and tested on PR.

Output Format

When this skill is active, produce:

  • dbt SQL model files with {{ config() }} block, {{ source() }} or {{ ref() }} macros, clearly-named CTEs, and trailing comments for complex logic
  • schema.yml YAML with source/model definitions, column descriptions, and tests — ALWAYS paired with any new model
  • MetricFlow metric definitions when defining new business metrics
  • dbt-expectations tests for financial assertions alongside generic tests
  • dbt snapshot configs for SCD Type 2 dimensions
  • Macro files when logic repeats across 3+ models
  • Incremental patterns with unique_key and {{ is_incremental() }}
  • Always state which layer (staging/intermediate/mart) a model belongs to and why

Verification Checklist

Before marking any analytics engineering work complete:

  • Every new model has a corresponding schema.yml entry
  • Every column has a description (what it means, unit, business rules)
  • Primary key has not_null + unique tests
  • Fact tables have relationships tests to dimensions
  • Staging models use only {{ source() }} — no {{ ref() }}, no raw table names
  • Marts use only {{ ref() }} — no {{ source() }}, no raw table names
  • No business logic in staging models (only rename, cast, surrogate key)
  • Incremental models have unique_key and {{ this }}-based filter
  • Source freshness configured for every source in sources.yml
  • Financial metrics defined in MetricFlow, not BI tools
  • Seeds used for small reference data, not external source tables
  • Model follows naming convention (stg_, int_, fct_, dim_)
  • dbt compile and dbt test pass on modified models

Rationalization Table

ExcuseReality
"I'll add the schema.yml later"Later never comes. The model and its schema.yml are created together or not at all.
"This staging model needs just one small join"One join is the start of business logic migration into staging. Move it to intermediate.
"COALESCE is light cleaning, not business logic"If the NULL handling encodes domain knowledge (e.g., closed accounts = zero), it is business logic. Move it to intermediate with a description explaining why.
"A senior stakeholder needs it by Monday, Tableau is the only way"Communicate the correct timeline and proceed with MetricFlow. Do not offer Tableau as an alternative.
"Tests slow down development"Tests catch silent data errors. Advisors noticing wrong numbers is slower than writing tests.
"The column name is self-explanatory, no description needed"Self-explanatory to you today. Not to the analyst onboarding next quarter. Write the description.
"Defining this metric in Tableau is faster"Faster once. Then three teams define it differently. MetricFlow ensures one truth.
"Full refresh is fine, the table is small-ish"Define 'small-ish.' If it's over 10M rows, it's not small. Check row count first, ask before refreshing.
"Raw table names are fine in this one model"One model becomes ten. The abstraction layer exists for a reason. Use {{ source() }} through staging.
"This is just a quick prototype model"Prototypes become production. Apply layer rules and tests from the start.
"This case is different because..."The rule exists precisely for cases that feel different. Follow it.
"I'm following the spirit not the letter"Violating the letter IS violating the spirit. No reinterpretation.

Red Flags — STOP

If you find yourself thinking or saying any of these, you are about to violate a critical rule:

  • "I'll add tests/descriptions/schema later" (re: skipping documentation or testing)
  • "Just a small join in staging" (re: business logic creeping into staging layer)
  • "The column name is obvious" (re: skipping column descriptions)
  • "It's faster in Tableau" (re: defining metrics outside the semantic layer)
  • "Full refresh won't take long" (re: refreshing large incremental tables)
  • "Just referencing the raw table directly" (re: bypassing source abstraction)
  • "Quick prototype" or "we'll clean it up later" (re: skipping layer conventions)

If any red flag fires: STOP. Re-read the Critical Rules. Follow the rule.

Skill Boundaries

This skill covers: dbt project architecture, model layer design (staging/intermediate/ marts), data testing and documentation, semantic layer/MetricFlow definitions, dbt CI/CD, dbt package ecosystem, analytics engineering best practices in Snowflake.

Defer to staff-sql-engineer for: Deep Snowflake query optimization (clustering, partitioning, EXPLAIN), advanced SQL patterns (window functions, QUALIFY, LATERAL FLATTEN), Snowflake security/RBAC.

Defer to staff-data-engineer for: Pipeline orchestration that triggers dbt runs (Prefect/Airflow integration), upstream data ingestion, raw data landing zone design.

Defer to staff-data-architect for: Enterprise data architecture decisions, choosing between Kimball vs Data Vault vs OBT at the project level, cross-system governance.

Defer to staff-product-engineer for: BI-facing frontend (Streamlit apps, dashboards) consuming mart data.

Keep looking

Skills are one crate of 607,533. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.