/data-analytics-skills:analytics-engineerfrom data-analytics-skills
Assists with analytics engineering: dbt model design, dimensional modeling, SQL transformations, data tests, and semantic-layer metrics. Useful when building dbt models, designing star schemas, or before merging dbt changes.
Ships in data-analytics-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
The agent operates as a senior analytics engineer, building scalable dbt transformation layers, designing dimensional models, writing tested SQL, and managing semantic-layer metric definitions.
Before building the models, settle the inputs below. When one is missing or vague and would change the result, ask about it; when it wouldn't, use a sensible default and say which one you used.
Ask about the two or three inputs that matter most for this request, not the whole list. If the user wants a result straight away, produce it and state your assumptions at the top.
stg_ model per source table. Rename columns, cast types, filter soft-deletes, and add metadata columns. Validate: dbt build --select stg_*.int_ models (e.g., int_orders_enriched). Keep each CTE single-purpose.dim_ and fct_ models for consumption. Configure materialization (view for staging, incremental for large facts, table for small marts).unique + not_null. Foreign keys get relationships. Add accepted_values for enums. Write model descriptions in YAML.dbt build, confirm test pass rate = 100%, check row counts against source, and verify dashboard numbers match.analytics/
dbt_project.yml
models/
staging/ # stg_<source>__<table>.sql (one per source table)
intermediate/ # int_<entity>_<verb>.sql (reusable logic)
marts/
core/ # dim_*.sql, fct_*.sql (consumption-ready)
marketing/
finance/
macros/ # Reusable Jinja helpers
tests/ # Custom generic + singular tests
seeds/ # Static CSV lookups
snapshots/ # SCD Type 2 captures
Staging model (models/staging/crm/stg_crm__customers.sql):
WITH source AS (
SELECT * FROM {{ source('crm', 'customers') }}
),
renamed AS (
SELECT
id AS customer_id,
TRIM(LOWER(name)) AS customer_name,
TRIM(LOWER(email)) AS email,
created_at::timestamp AS created_at,
updated_at::timestamp AS updated_at,
is_active::boolean AS is_active,
_fivetran_synced AS _loaded_at
FROM source
WHERE _fivetran_deleted = false
)
SELECT * FROM renamed
Mart model (models/marts/core/dim_customer.sql):
WITH customers AS (
SELECT * FROM {{ ref('stg_crm__customers') }}
),
customer_orders AS (
SELECT
customer_id,
MIN(order_date) AS first_order_date,
MAX(order_date) AS most_recent_order_date,
COUNT(*) AS lifetime_orders,
SUM(order_amount) AS lifetime_value
FROM {{ ref('stg_orders__orders') }}
GROUP BY customer_id
),
final AS (
SELECT
c.customer_id,
c.customer_name,
c.email,
c.created_at,
co.first_order_date,
co.most_recent_order_date,
co.lifetime_orders,
co.lifetime_value,
CASE
WHEN co.lifetime_value >= 10000 THEN 'platinum'
WHEN co.lifetime_value >= 5000 THEN 'gold'
WHEN co.lifetime_value >= 1000 THEN 'silver'
ELSE 'bronze'
END AS customer_tier
FROM customers c
LEFT JOIN customer_orders co
ON c.customer_id = co.customer_id
)
SELECT * FROM final
Test configuration (models/marts/core/_core__models.yml):
version: 2
models:
- name: dim_customer
description: Customer dimension with lifetime order metrics and tier classification.
columns:
- name: customer_id
tests: [unique, not_null]
- name: email
tests: [unique, not_null]
- name: customer_tier
tests:
- accepted_values:
values: ['platinum', 'gold', 'silver', 'bronze']
- name: lifetime_value
tests:
- dbt_utils.expression_is_true:
expression: ">= 0"
-- models/marts/core/fct_orders.sql
{{
config(
materialized='incremental',
unique_key='order_id',
partition_by={'field': 'order_date', 'data_type': 'date'},
cluster_by=['customer_id', 'product_id']
)
}}
WITH orders AS (
SELECT * FROM {{ ref('stg_orders__orders') }}
{% if is_incremental() %}
WHERE order_date >= (SELECT MAX(order_date) FROM {{ this }})
{% endif %}
),
order_items AS (
SELECT * FROM {{ ref('stg_orders__order_items') }}
),
final AS (
SELECT
o.order_id,
o.order_date,
o.customer_id,
oi.product_id,
o.store_id,
oi.quantity,
oi.unit_price,
oi.quantity * oi.unit_price AS line_total,
o.discount_amount,
o.tax_amount,
o.total_amount
FROM orders o
INNER JOIN order_items oi ON o.order_id = oi.order_id
)
SELECT * FROM final
| Layer | Materialization | Rationale |
|---|---|---|
| Staging | View | Thin wrappers; no storage cost |
| Intermediate | Ephemeral / View | Business logic; referenced multiple times |
| Marts (small) | Table | Query performance for BI tools |
| Marts (large) | Incremental | Efficient appends for large fact tables |
# models/marts/core/_core__metrics.yml
metrics:
- name: revenue
label: Total Revenue
model: ref('fct_orders')
calculation_method: sum
expression: total_amount
timestamp: order_date
time_grains: [day, week, month, quarter, year]
dimensions: [customer_tier, product_category, store_region]
filters:
- field: is_cancelled
operator: '='
value: 'false'
- name: average_order_value
label: Average Order Value
model: ref('fct_orders')
calculation_method: average
expression: total_amount
timestamp: order_date
time_grains: [day, week, month]
-- macros/cents_to_dollars.sql
{% macro cents_to_dollars(column_name) %}
({{ column_name }} / 100.0)::decimal(18,2)
{% endmacro %}
-- macros/get_incremental_filter.sql
{% macro get_incremental_filter(column_name, lookback_days=3) %}
{% if is_incremental() %}
WHERE {{ column_name }} >= (
SELECT DATEADD(day, -{{ lookback_days }}, MAX({{ column_name }}))
FROM {{ this }}
)
{% endif %}
{% endmacro %}
# Only run modified models and their downstream dependents
dbt run --select state:modified+ --defer --state ./target-base
dbt test --select state:modified+ --defer --state ./target-base
For full CI/CD pipeline configuration, see REFERENCE.md.
REFERENCE.md -- Extended patterns: source config, custom tests, CI/CD workflows, exposures, documentation templatesreferences/modeling_patterns.md -- Data modeling best practicesreferences/dbt_style_guide.md -- SQL and dbt conventionsreferences/testing_guide.md -- Testing strategiesreferences/optimization.md -- Performance tuningRun from this skill folder. The tools read dbt artifacts (dbt compile writes target/manifest.json, dbt docs generate writes target/catalog.json) and never query the warehouse.
python3 scripts/quality_scorer.py --model stg_orders --manifest assets/manifest_flawed.json
python3 scripts/impact_analyzer.py --model fct_orders --manifest assets/manifest_flawed.json
python3 scripts/schema_diff.py --source assets/catalog_prod.json --target assets/catalog_dev_flawed.json
python3 scripts/doc_generator.py --model stg_orders --manifest assets/manifest_sound.json --catalog assets/catalog_prod.json
Real output of the first command (exit 1):
Model stg_orders: read 0 tests; score 0/100 (internal heuristic)
- [staging-no-join] -30: join customers c on c.id=o.cid
Fix: move the join into an `int_` model; keep `stg_` one-to-one with its source
- [staging-no-aggregation] -30: group by 1
Fix: move the aggregation into an `int_` or mart model
...
FIX 5 issue(s)
All four tools: 0 clean, 1 findings to act on, 2 unusable input (missing or malformed file, no model nodes, unknown model; one line on stderr, no traceback). --format json is supported by all (doc_generator.py also takes --format markdown|text); --json stays as an alias where it existed.
| Tool | Exit 1 when |
|---|---|
quality_scorer.py | any convention finding (missing descriptions or tests, staging JOIN/GROUP BY, mart reading a source) |
impact_analyzer.py | the model has a downstream exposure (dashboard/app) |
schema_diff.py | a model or column is dropped, or a column type changes (added models/columns alone exit 0) |
doc_generator.py | the page was written but the model or a column lacks a description |
| Tool | Purpose | Key Flags |
|---|---|---|
impact_analyzer.py | Trace downstream models, tests and exposures via BFS on the manifest child_map | --model, --manifest, --format |
schema_diff.py | Compare two catalog.json files: dropped/added models and columns, type changes | --source, --target, --format |
doc_generator.py | Markdown page with dependencies, column dictionary, tests; types come from the catalog when present | --model, --manifest, --catalog, --format |
quality_scorer.py | Findings with evidence and a fix per rule; the 0-100 score is an internal heuristic (penalties shown), not a benchmark | --model, --manifest, --format |
dbt_common.py | Shared helper module, not a command | n/a |
Samples live in assets/ (manifest_sound.json, manifest_flawed.json, manifest_malformed.json, catalog_*.json) and drive assets/contract.json.
| Problem | Likely Cause | Resolution |
|---|---|---|
dbt build fails with "relation does not exist" | Upstream model was not run or materialization changed | Run dbt build --select +<model> to build the full upstream chain |
| Incremental model produces duplicates | unique_key does not match the actual grain | Verify the unique_key config matches the primary key columns; run a full refresh with --full-refresh |
Test failures on not_null after deployment | Source data introduced unexpected NULLs in a previously clean column | Add a staging-layer COALESCE or adjust the test to warn severity while investigating upstream |
Schema drift detected by schema_diff.py | Upstream source changed column types or removed columns | Coordinate with the data engineering team; update staging model casts and regenerate documentation |
| Semantic-layer metric values differ from dashboard | Dashboard applies its own filters or calculations outside the semantic layer | Move all calculation logic into the semantic layer; audit dashboard-level computed fields |
Slow dbt run on large incremental models | Lookback window is too wide or partition pruning is not engaged | Narrow the incremental filter, verify partition_by config, and check warehouse query plan |
quality_scorer.py reports low score despite good coverage | Staging model contains JOINs or GROUP BY operations triggering layer-violation penalties | Refactor aggregation logic into intermediate or mart models; keep staging models as thin wrappers |
dbt build with a 100% test pass rate before merging to production.unique + not_null).quality_scorer.py exits 0 (no findings) for every mart model.In scope: dbt project design, dimensional modeling (Kimball methodology), SQL transformation logic, data testing, semantic-layer metric definition, CI/CD for dbt, and warehouse query optimization.
Out of scope: Raw data ingestion and extraction (ELT/ETL orchestration tools like Fivetran or Airbyte), data infrastructure provisioning, BI tool configuration beyond semantic-layer integration, and real-time streaming pipelines.
Limitations: The Python tools operate on dbt manifest/catalog JSON artifacts and do not query the warehouse directly. Scoring heuristics in quality_scorer.py use rule-based deductions that may not cover every project convention. All scripts use the Python standard library only -- no external dependencies required.
engineering/senior-data-engineer): Coordinates on source table contracts, ingestion SLAs, and schema change notifications.data-analytics/business-intelligence): Consumes mart models and semantic-layer metrics; dashboard specs reference model outputs.data-analytics/data-analyst): Writes ad-hoc queries against mart models; reports data quality issues back to the analytics engineer.data-analytics/ml-ops-engineer): Feature engineering pipelines may depend on intermediate or mart models as upstream inputs.templates/): Slim CI patterns (state:modified+) integrate into GitHub Actions or similar runners for automated PR validation.REFERENCE.md (opens in a new tab)assets/catalog_dev_flawed.json (opens in a new tab)assets/catalog_dev_sound.json (opens in a new tab)assets/catalog_prod.json (opens in a new tab)assets/contract.json (opens in a new tab)assets/dbt_project.yml (opens in a new tab)assets/macros.sql (opens in a new tab)assets/manifest_flawed.json (opens in a new tab)assets/manifest_malformed.json (opens in a new tab)assets/manifest_sound.json (opens in a new tab)assets/schema.yml (opens in a new tab)assets/source.yml (opens in a new tab)references/dbt_style_guide.md (opens in a new tab)references/modeling_patterns.md (opens in a new tab)references/optimization.md (opens in a new tab)references/testing_guide.md (opens in a new tab)scripts/dbt_common.py (opens in a new tab)scripts/doc_generator.py (opens in a new tab)scripts/impact_analyzer.py (opens in a new tab)scripts/quality_scorer.py (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
dbt, data-modeling, sql-transformation, semantic-layer, star-schema
npx claudepluginhub borghei/claude-skills --plugin data-analytics-skills8 skills in this plugin
/business-intelligenceScore KPIs against targets, validate metric definitions, lay out dashboards and review a finished dashboard spec for overload, chart misuse and conflicting definitions. Use when designing, reviewing or automating BI dashboards and KPIs.
/data-analystProfiles CSV/JSON exports for data-quality problems (with the fix per column), checks SQL for correctness traps and slow patterns, and builds a paste-ready summary report. Use when someone shares a data export or a query and asks what it says, whether it can be trusted, or how to fix it; also for cohort, funnel and dashboard work.
/data-scientistOther plugins' skills for the same job