Claude Code for Elementary Data: dbt Data Observability — Claude Skills 360 Blog
Blog / AI / Claude Code for Elementary Data: dbt Data Observability
AI

Claude Code for Elementary Data: dbt Data Observability

Published: August 27, 2027
Read time: 5 min read
By: Claude Skills 360

Elementary is the open-source data observability platform built as a dbt package. Add to packages.yml: - package: elementary-data/elementary, version: 0.14.0. dbt deps && dbt run --select elementary sets up Elementary tables. Elementary tests in schema.yml: tests: - elementary.volume_anomalies: {time_bucket: {period: day}, days_back: 14}, - elementary.all_columns_anomalies, - elementary.freshness_anomalies: {max_allowed_delay: 6 hours}. Column-level anomalies: - elementary.column_anomalies: {column_anomalies: [null_rate, zero_rate, min, max, average]}. Schema changes: - elementary.schema_changes. Distribution: - elementary.event_freshness_anomalies: {event_timestamp_column: event_time}. edr report generates an interactive HTML report. edr send-report --slack-token TOKEN --slack-channel alerts sends to Slack. edr monitor runs tests and alerts. Elementary CLI: pip install elementary-data[bigquery]. Source freshness: - elementary.source_freshness_anomalies. edr run-report in CI/CD. Custom monitors via macros: {{ elementary.collect_metrics(model, metrics=['row_count', 'null_rate']) }}. Python SDK: from elementary.clients.dbt.api import DbtRunner. Elementary Cloud at elementary-data.cloud stores history, provides root cause analysis, and routes alerts by team. edr debug diagnoses connection issues. profiles.yml database connection mirrors dbt profile. Claude Code generates Elementary dbt test YAML, report configurations, Slack alert setups, and CI/CD integration workflows.

CLAUDE.md for Elementary

## Elementary Stack
- Package: elementary-data/elementary >= 0.14 in packages.yml
- Install: dbt deps && dbt run --select elementary (creates edr_monitors_runs and artifact tables)
- Tests: add to schema.yml under tests: - elementary.volume_anomalies / all_columns_anomalies / etc.
- Run: dbt test --select elementary (runs all elementary tests)
- Report: edr report (HTML) or edr send-report --slack-token / --slack-channel
- CI: dbt test && edr send-report on failure
- Cloud: edr report --cloud-report (upload to Elementary Cloud)

Elementary Test Configuration

# models/marts/schema.yml — Elementary observability tests
version: 2

models:
  - name: orders_daily
    description: "Daily enriched orders"
    config:
      elementary:
        timestamp_column: created_at  # used for time-series monitoring

    tests:
      # Volume monitoring — detect sudden drops/spikes
      - elementary.volume_anomalies:
          timestamp_column: created_at
          days_back: 30
          time_bucket:
            period: hour
          sensitivity: 3  # standard deviations
          anomaly_direction: both

      # Schema change detection
      - elementary.schema_changes

      # Column-level anomalies across all columns
      - elementary.all_columns_anomalies:
          timestamp_column: created_at
          days_back: 14
          time_bucket: { period: day }
          column_anomalies:
            - null_rate
            - null_count
            - zero_rate
            - average
            - variance

      # Freshness (data recency)
      - elementary.freshness_anomalies:
          max_allowed_delay: "6 hours"
          days_back: 14

    columns:
      - name: order_id
        tests:
          - not_null
          - unique
          - elementary.column_anomalies:
              column_anomalies: [null_count]

      - name: amount_usd
        tests:
          - elementary.column_anomalies:
              column_anomalies: [null_rate, zero_rate, min, max, average, variance]
              timestamp_column: created_at
              days_back: 30

      - name: status
        tests:
          - accepted_values:
              values: [pending, processing, completed, refunded, cancelled]
          - elementary.column_anomalies:
              column_anomalies: [null_rate]

  - name: events
    config:
      elementary:
        timestamp_column: event_timestamp

    tests:
      - elementary.volume_anomalies:
          timestamp_column: event_timestamp
          time_bucket: { period: hour }
          days_back: 7
          anomaly_direction: drop   # Alert only on drops (events never spike unexpectedly)
          sensitivity: 2

      - elementary.event_freshness_anomalies:
          event_timestamp_column: event_timestamp
          max_allowed_delay: "30 minutes"

      - elementary.all_columns_anomalies:
          timestamp_column: event_timestamp
          days_back: 14

sources:
  - name: raw
    schema: raw_data
    tables:
      - name: api_events
        tests:
          - elementary.source_freshness_anomalies:
              timestamp_column: _fivetran_synced
              max_allowed_delay: "2 hours"

Elementary Package Config

# packages.yml — dbt packages
packages:
  - package: dbt-labs/dbt_utils
    version: 1.1.1
  - package: elementary-data/elementary
    version: 0.14.3
# dbt_project.yml — Elementary configuration block
vars:
  # Elementary config
  edr_schema: elementary             # Schema where Elementary tables are stored
  edr_database: analytics            # Database for Elementary tables (some warehouses only)

  # Enable/disable
  elementary_enabled: true           # Set false in dev to skip anomaly tests
  anomaly_sensitivity: 3             # Standard deviations for anomaly detection

  # Date range for anomaly training
  rolling_lookback: 30               # Days of history to train on
  days_back: 14                      # Days to check for anomalies

CI/CD Integration

#!/bin/bash
# scripts/dbt_ci_with_elementary.sh — CI/CD pipeline with Elementary monitoring

set -e

echo "=== Running dbt build ==="
dbt build --target prod --exclude tag:skip_ci

echo "=== Running Elementary tests ==="
dbt test --select elementary --target prod

echo "=== Generating Elementary report ==="
edr report --target prod --env prod

# Send report to Slack on test failures
if [ $? -ne 0 ]; then
  echo "=== Sending failure report to Slack ==="
  edr send-report \
    --target prod \
    --slack-token "$SLACK_BOT_TOKEN" \
    --slack-channel "#data-alerts" \
    --env prod
  exit 1
fi

echo "=== Elementary monitoring complete ==="
# scripts/elementary_alert.py — programmatic Elementary alerting
import os
import json
from pathlib import Path


def parse_elementary_results(results_path: str = "target/run_results.json") -> list[dict]:
    """Parse dbt run results for Elementary failures."""
    with open(results_path) as f:
        results = json.load(f)

    failures = []
    for r in results.get("results", []):
        if r.get("status") in ("fail", "warn") and "elementary" in r.get("unique_id", ""):
            failures.append({
                "test":       r["unique_id"],
                "status":     r["status"],
                "message":    r.get("message", ""),
                "node":       r.get("node", {}).get("name", ""),
                "model":      r.get("node", {}).get("relation_name", ""),
                "test_type":  r.get("node", {}).get("test_metadata", {}).get("name", ""),
            })

    return failures


def send_slack_alert(failures: list[dict], webhook_url: str) -> None:
    """Send Slack alert for Elementary failures."""
    import urllib.request

    if not failures:
        return

    blocks = [
        {
            "type": "header",
            "text": {"type": "plain_text", "text": f"⚠️ {len(failures)} Data Quality Alert(s)"},
        },
    ]

    for f in failures[:10]:  # Limit to 10 in Slack message
        blocks.append({
            "type": "section",
            "text": {
                "type": "mrkdwn",
                "text": f"*{f['test_type']}* on `{f['node']}`\n{f['message'][:200]}",
            },
        })

    payload = json.dumps({"blocks": blocks}).encode()
    req = urllib.request.Request(
        webhook_url,
        data=payload,
        headers={"Content-Type": "application/json"},
        method="POST",
    )
    urllib.request.urlopen(req)


if __name__ == "__main__":
    failures = parse_elementary_results()
    if failures:
        print(f"Found {len(failures)} Elementary test failures")
        webhook = os.environ.get("SLACK_WEBHOOK_URL")
        if webhook:
            send_slack_alert(failures, webhook)
        import sys; sys.exit(1)
    print("All Elementary tests passed")

For the Soda alternative when needing a standalone data quality tool that works without dbt — Soda Core connects directly to any warehouse and runs SodaCL checks without requiring a dbt project, making it useful for data pipelines not built on dbt while Elementary lives entirely inside the dbt ecosystem. For the Monte Carlo alternative when needing a fully managed enterprise data observability platform with automatic anomaly detection, data lineage, SAML SSO, and SLA-backed incident management without any configuration — Monte Carlo deploys as SaaS with a UI while Elementary is open-source and self-configurable, requiring more upfront setup in exchange for no vendor lock-in. The Claude Skills 360 bundle includes Elementary skill sets covering dbt test YAML, anomaly detection configuration, CI/CD integration, and Slack alerting. Start with the free tier to try data observability generation.

Keep Reading

AI

Claude Code for email.contentmanager: Python Email Content Accessors

Read and write EmailMessage body content with Python's email.contentmanager module and Claude Code — email contentmanager ContentManager for the class that maps content types to get and set handler functions allowing EmailMessage to support get_content and set_content with type-specific behaviour, email contentmanager raw_data_manager for the ContentManager instance that handles raw bytes and str payloads without any conversion, email contentmanager content_manager for the standard ContentManager instance used by email.policy.default that intelligently handles text plain text html multipart and binary content types, email contentmanager get_content_text for the handler that returns the decoded text payload of a text-star message part as a str, email contentmanager get_content_binary for the handler that returns the raw decoded bytes payload of a non-text message part, email contentmanager get_data_manager for the get-handler lookup used by EmailMessage get_content to find the right reader function for the content type, email contentmanager set_content text for the handler that creates and sets a text part correctly choosing charset and transfer encoding, email contentmanager set_content bytes for the handler that creates and sets a binary part with base64 encoding and optional filename Content-Disposition, email contentmanager EmailMessage get_content for the method that reads the message body using the registered content manager handlers, email contentmanager EmailMessage set_content for the method that sets the message body and MIME headers in one call, email contentmanager EmailMessage make_alternative make_mixed make_related for the methods that convert a simple message into a multipart container, email contentmanager EmailMessage add_attachment for the method that attaches a file or bytes to a multipart message, and email contentmanager integration with email.message and email.policy and email.mime and io for building high-level email readers attachment extractors text body accessors HTML readers and policy-aware MIME construction pipelines.

5 min read Feb 12, 2029
AI

Claude Code for email.charset: Python Email Charset Encoding

Control header and body encoding for international email with Python's email.charset module and Claude Code — email charset Charset for the class that wraps a character set name with the encoding rules for header encoding and body encoding describing how to encode text for that charset in email messages, email charset Charset header_encoding for the attribute specifying whether headers using this charset should use QP quoted-printable encoding BASE64 encoding or no encoding, email charset Charset body_encoding for the attribute specifying the Content-Transfer-Encoding to use for message bodies in this charset such as QP or BASE64, email charset Charset output_codec for the attribute giving the Python codec name used to encode the string to bytes for the wire format, email charset Charset input_codec for the attribute giving the Python codec name used to decode incoming bytes to str, email charset Charset get_output_charset for returning the output charset name, email charset Charset header_encode for encoding a header string using the charset's header_encoding method, email charset Charset body_encode for encoding body content using the charset's body_encoding, email charset Charset convert for converting a string from the input_codec to the output_codec, email charset add_charset for registering a new charset with custom encoding rules in the global charset registry, email charset add_alias for adding an alias name that maps to an existing registered charset, email charset add_codec for registering a codec name mapping for use by the charset machinery, and email charset integration with email.message and email.mime and email.policy and email.encoders for building international email senders non-ASCII header encoders Content-Transfer-Encoding selectors charset-aware message constructors and MIME encoding pipelines.

5 min read Feb 11, 2029
AI

Claude Code for email.utils: Python Email Address and Header Utilities

Parse and format RFC 2822 email addresses and dates with Python's email.utils module and Claude Code — email utils parseaddr for splitting a display-name plus angle-bracket address string into a realname and email address tuple, email utils formataddr for combining a realname and address string into a properly quoted RFC 2822 address with angle brackets, email utils getaddresses for parsing a list of raw address header strings each potentially containing multiple comma-separated addresses into a list of realname address tuples, email utils parsedate for parsing an RFC 2822 date string into a nine-tuple compatible with time.mktime, email utils parsedate_tz for parsing an RFC 2822 date string into a ten-tuple that includes the UTC offset timezone in seconds, email utils parsedate_to_datetime for parsing an RFC 2822 date string into an aware datetime object with timezone, email utils formatdate for formatting a POSIX timestamp or the current time as an RFC 2822 date string with optional usegmt and localtime flags, email utils format_datetime for formatting a datetime object as an RFC 2822 date string, email utils make_msgid for generating a globally unique Message-ID string with optional idstring and domain components, email utils decode_rfc2231 for decoding an RFC 2231 encoded parameter value into a tuple of charset language and value, email utils encode_rfc2231 for encoding a string as an RFC 2231 encoded parameter value, email utils collapse_rfc2231_value for collapsing a decoded RFC 2231 tuple to a Unicode string, and email utils integration with email.message and email.headerregistry and datetime and time for building address parsers date formatters message-id generators header extractors and RFC-compliant email construction utilities.

5 min read Feb 10, 2029

Put these ideas into practice

Claude Skills 360 gives you production-ready skills for everything in this article — and 2,350+ more. Start free or go all-in.

Back to Blog

Get 360 skills free