Dataops

From j4flmao/agent-skills · View interactive version

Dataops is an AI agent skill from the GitHub repository j4flmao/agent-skills. Use when the user asks about DataOps, CI/CD for data pipelines, dbt slim CI with state:modified, SQLFluff, Great Expectations in CI, data environment management, or data contract checks in CI. Produces data pipeline CI/CD workflows and quality gates. Not for pipeline design (use data-etl-pipeline) o

How to use this skill

Skill file

DataOps Agent

Purpose

Implements CI/CD pipelines for data transformations, testing, environment management, and data contract enforcement.

Agent Protocol

Trigger

User request includes: DataOps, CI/CD for data, data pipeline CI/CD, data testing CI, dbt CI/CD, SQLFluff, data pipeline deployment, data environment management, data contract CI.

Input Context

Output Artifact

DataOps pipeline CI/CD configuration, dbt project setup, data testing config, environment promotion rules, data contracts.

Response Format

`

DataOps Pipeline

CI Configuration

Framework: {dbt/sqlfluff/custom}

Linting: {sqlfluff config} | Threshold: {strict/warn}

Testing: {dbt test / Great Expectations / both}

Model Compilation: {enabled/disabled}

Data Contract Validation: {schema check / row count / freshness}

CD Pipeline

Environments: [{dev, staging, prod}]

Promotion Gates:

dev-staging: {tests pass, lint pass}

staging-prod: {tests pass, schema compat, manual approval}

Rollback Strategy: {dbt source freshness / version pin / reverse migration}

`

No preamble. No postamble. No explanations.

Completion Criteria

Architecture / Decision Trees

Data Transformation Framework Decision Tree

CI/CD Architecture Options

| Approach | Description | Best For |

|---|---|---|

| dbt Slim CI | Only build models changed vs production manifest | Large dbt projects (100+ models) |

| Full Rebuild CI | Build all models every time | Small projects (<50 models) |

| GE + dbt | Great Expectations quality + dbt transformation | Data quality focused teams |

| dbt-expectations | GE tests as dbt package | dbt-centric teams |

| Soda + dbt | Soda checks in CI pipeline | Teams wanting SQL-based quality |

| Dagster + dbt | Dagster orchestrates, dbt transforms | Complex pipeline DAGs |

Environment Strategy

| Environment | Data Freshness | CI/CD Trigger | Validation Gates | Data Volume |

|---|---|---|---|---|

| Dev | Stale snapshot | PR created | SQLFluff, compile, unit tests | Subset (10%) |

| Staging | Near-production | PR merged | Slim CI, integration tests, contracts | Subset (50%) |

| Prod | Live | Manual approval | Full tests, source freshness, contracts | Full (100%) |

Testing Framework Choice

| Tool | Scope | Language | Integration | Coverage Type |

|---|---|---|---|---|

| dbt test | dbt models | SQL/YAML | Native in dbt | Schema, uniqueness, relationships |

| Great Expectations | Any data source | Python | Standalone, Airflow, dbt | Profiling, expectations, validation |

| dbt-expectations | dbt models | SQL/YAML | dbt package | GE-style tests in dbt |

| Soda | Any data source | YAML | CI, Airflow, K8s | Row count, freshness, schema |

| Deequ | Spark data | Scala/Python | Spark jobs | Column metrics, constraints |

| data-diff | Any DB | CLI/Python | CI | Cross-DB diff, regression |

Core Workflow

Step 1: dbt Project CI Configuration

`yaml

name: dbt CI

on:

pull_request:

paths:

env:

DBT_PROFILES_DIR: ./

DBT_TARGET: ci

jobs:

lint:

runs-on: ubuntu-latest

steps:

with:

python-version: '3.12'

slim-ci:

runs-on: ubuntu-latest

steps:

with:

python-version: '3.12'

uses: actions/download-artifact@v4

with:

name: prod-manifest

path: target-manifest/

data-quality:

runs-on: ubuntu-latest

steps:

with:

python-version: '3.12'

`

Step 2: dbt Project Structure

`

my-dbt-project/

models/

staging/

stg_customers.sql

stg_orders.sql

_stg_sources.yml

intermediate/

int_customer_orders.sql

_int_models.yml

marts/

fct_orders.sql

dim_customers.sql

_marts.yml

tests/

generic/

assert_positive_total.sql

assert_valid_email.sql

singular/

expected_row_count.sql

referential_integrity.sql

macros/

grant_permissions.sql

generate_schema_name.sql

analyses/

seeds/

snapshots/

dbt_project.yml

packages.yml

profiles.yml

.sqlfluff

`

Step 3: SQLFluff Configuration

`ini

[sqlfluff]

dialect = postgres

templater = dbt

max_line_length = 120

indent_unit = space

tab_space_size = 4

[sqlfluff:indentation]

indented_joins = True

indented_ctes = True

indented_on_contents = True

[sqlfluff:layout:type:comma]

line_position = trailing

[sqlfluff:rules]

capitalisation.keywords = upper

capitalisation.functions = upper

capitalisation.literals = upper

`

Step 4: Data Contracts

`yaml

contracts:

description: Cleaned customer data

columns:

data_type: integer

not_null: true

unique: true

data_type: varchar(255)

not_null: true

unique: true

data_type: timestamp

not_null: true

freshness:

warn: { lookback: 1 }

error: { lookback: 2 }

row_count:

min: 1000

max: 10000000

sla:

availability: 99.9%

freshness: 1h

owners: [data-team@example.com]

downstream: [int_customer_orders, dim_customers]

`

Step 5: dbt YAML Tests

`yaml

version: 2

sources:

database: raw

schema: public

tables:

loaded_at_field: _etl_loaded_at

freshness:

warn: { rule: max_bucket, lookback: 1 }

error: { rule: max_bucket, lookback: 3 }

columns:

tests: [unique, not_null]

tests: [not_null, unique]

loaded_at_field: _etl_loaded_at

freshness:

warn: { rule: max_bucket, lookback: 1 }

error: { rule: max_bucket, lookback: 6 }

columns:

tests: [unique, not_null]

tests: [not_null]

tests:

to: source('raw_data', 'customers')

field: id

models:

columns:

tests: [unique, not_null]

tests: [unique, not_null]

columns:

tests: [unique, not_null]

tests:

to: ref('dim_customers')

field: customer_id

tests:

expression: "total_amount >= 0"

datepart: day

field: order_date

interval: 1

`

Step 6: Environment Promotion CD

`yaml

name: dbt Deploy

on:

push:

branches: [main]

jobs:

deploy-staging:

runs-on: ubuntu-latest

environment: staging

steps:

with:

python-version: '3.12'

with:

name: staging-manifest

path: target/manifest.json

deploy-prod:

needs: deploy-staging

runs-on: ubuntu-latest

environment: production

concurrency: dbt-prod

steps:

with:

python-version: '3.12'

with:

name: prod-manifest

path: target/manifest.json

`

Step 7: Data Lineage and Documentation

`ash

Generate and deploy documentation

dbt docs generate

dbt docs serve --port 8080

Deploy to static hosting for team access

aws s3 sync target/ s3://dbt-docs-prod/ --delete

`

Anti-Patterns

Anti-Pattern 1: Full Rebuild in Large Projects

Building all models on every PR takes hours for 100+ model projects. Without slim CI, CI pipeline time grows linearly with model count. Always use state:modified+ with production manifest stored as artifact.

Anti-Pattern 2: Ignoring Source Freshness

Models compile and tests pass against stale sources, then fail in production because source data changed or stopped arriving. Run dbt source freshness before any deployment. Set freshness thresholds with warn and error buckets.

Anti-Pattern 3: No Data Contract Validation

Downstream consumers are surprised when column types change, columns are dropped, or row counts drop below thresholds. Define contracts per model with schema, row count range, and freshness SLA. Validate breaking changes in CI.

Anti-Pattern 4: Insufficient Test Coverage

Tests pass means nothing if there are no tests. Every model must have uniqueness and not_null on primary keys. Set explicit coverage targets. Track test coverage in CI dashboard.

Anti-Pattern 5: Full Refresh Without Testing

Running dbt run --full-refresh in production without testing can break downstream models. Always test full refresh in staging first. Use targeted --select for specific models. Backup tables before destructive operations.

Anti-Pattern 6: Environment Config Drift

Dev, staging, and prod configurations diverge over time. Use dbt profiles in version control with environment variables for secrets. Test in staging with production-like data volume.

Anti-Pattern 7: No Rollback Plan

When a dbt deployment fails mid-run, partial state corrupts downstream models. Have a documented rollback procedure tested in staging. Maintain N-1 versions deployable.

Production Considerations

Pipeline Performance

Source Freshness

Testing Cadence

Incident Response

  1. Identify failed model from dbt run output.
  2. Determine failure type: compilation, test failure, timeout.
  3. Compilation error: fix SQL, open PR, redeploy.
  4. Test failure: check source data quality, adjust tests.
  5. Timeout: optimize SQL, increase timeout, add indexes.
  6. Rollback: revert Git commit, redeploy previous version.
  7. Document root cause and add preventive test.

Rules

Compared With

DataOps vs MLOps

DataOps: CI/CD for data pipelines, testing, environment promotion, contracts. MLOps: CI/CD for ML models, feature stores, model registry, A/B testing. Overlap in CI/CD tooling but different artifacts (SQL vs models). DataOps is deterministic transformations; MLOps is statistical models.

dbt vs SQLFluff vs Great Expectations

dbt: transformation framework (build, run, test SQL). SQLFluff: SQL linter (style and anti-patterns only). Great Expectations: data quality testing (profiling, expectations, validation). These are complementary -- use all three.

dbt vs Airflow

dbt: transformation layer (SELECT statements). Airflow: orchestration layer (DAG of tasks, scheduling). dbt runs inside Airflow DAG. Complementary -- Airflow triggers dbt runs.

Operations & Maintenance

Weekly Tasks

Monthly Tasks

Quarterly Tasks

References

Handoff

For data warehouse schema design, hand off to data-warehouse. For data pipeline ETL, hand off to etl-pipeline. For quality monitoring, hand off to data-quality.

Architecture Decision Trees

Batch vs Streaming Pipeline

| Decision | Batch | Streaming |

|---|---|---|

| Latency requirement | > 5 min acceptable | < 1 min required |

| Data volume pattern | Periodic large loads | Continuous small events |

| Processing complexity | Complex joins, aggregations | Simple transforms, filtering |

| Cost sensitivity | Lower (spot instances) | Higher (always-on clusters) |

| Recommended tool | Apache Spark, Airflow | Kafka Streams, Flink |

Data Lake vs Data Warehouse

| Dimension | Data Lake | Data Warehouse |

|---|---|---|

| Schema | Schema-on-read | Schema-on-write |

| Data types | Raw, unstructured, structured | Structured, curated |

| Users | Data scientists, engineers | Analysts, BI tools |

| Storage | Object store (S3, ADLS) | RDBMS (Redshift, Snowflake) |

| Partitioning | Hive-style partitions | Star/snowflake schema |

Implementation Patterns

YAML: Airflow DAG for Data Pipeline Orchestration

dag_id: data_quality_pipeline
schedule: "0 2 * * *"
default_args:
  owner: data-platform
  retries: 2
  retry_delay: 5m
  email_on_failure: true
tasks:
  - id: extract_sources
    operator: PostgresOperator
    sql: "SELECT * FROM source_orders WHERE date = '{{ ds }}'"
  - id: validate_schema
    operator: PythonOperator
    python_callable: validate_columns
    params:
      expected_schema:
        order_id: INTEGER
        customer_id: INTEGER
        amount: FLOAT
  - id: transform_to_parquet
    operator: SparkSubmitOperator
    application: transforms/orders_to_parquet.py
    conf:
      spark.sql.adaptive.enabled: "true"
  - id: load_to_warehouse
    operator: SnowflakeOperator
    sql: "COPY INTO analytics.orders FROM @staging/{{ ds }}"
  dependencies:
    - from: extract_sources
      to: validate_schema
    - from: validate_schema
      to: transform_to_parquet
    - from: transform_to_parquet
      to: load_to_warehouse

Bash: Data Quality Monitor

#!/usr/bin/env bash
set -euo pipefail

check_data_quality() {
  local table=$1
  local date=$2

  TOTAL=$(bq query --format=json \
    "SELECT COUNT(*) as cnt FROM ${table} WHERE date = '${date}'" \
    | jq '.[0].cnt')

  NULLS=$(bq query --format=json \
    "SELECT COUNT(*) as cnt FROM ${table} WHERE date = '${date}' AND primary_key IS NULL" \
    | jq '.[0].cnt')

  echo "Total rows: $TOTAL, Null PKs: $NULLS"

  if [ "$NULLS" -gt 0 ]; then
    echo "FAIL: Found $NULLS null primary keys in $table"
    exit 1
  fi

  if [ "$TOTAL" -eq 0 ]; then
    echo "FAIL: Zero rows in $table for $date"
    exit 1
  fi
}

Production Considerations

Anti-Patterns

Performance Optimization

Security Considerations

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.