agentleFS
karim-bhalwanikarim-bhalwani/agentic-harness/skills/data-engineering/SKILL.md

data-engineering

Skill0 starsChanged 4 months agoMITView on GitHub

Comprehensive data engineering reference covering Medallion architecture, Data Vault 2.0, PySpark optimization, dbt transformation patterns, data quality frameworks, and SQL optimization. Use when building ETL/ELT pipelines, designing data schemas, optimizing Spark/SQL performance, implementing data governance, or architecting lakehouse solutions. DO NOT USE FOR: ad-hoc SQL querying (use data-analyst), deprecation analysis (use data-deprecation-analysis), LLM/RAG pipeline design (use llm-app-patterns), or CI/CD configuration (use ops).

21 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use qa-testing, infrastructure-as-code and 10 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • miketrombaSkill

    qa-testing

    Autonomously QA and verify the application using browser automation. Use when verifying code changes, testing features, validating bug fixes, or confirming any work done on the application. Triggers on requests to "test this", "verify this works", "QA this change", "make sure it works", or after implementing features that need validation.

    Also in 3 projects that use this

  • mmondoraSkill

    infrastructure-as-code

    Infrastructure as Code with Terraform and Pulumi. State management, modularity, drift detection, secrets handling. Use when provisioning cloud resources, writing Terraform/Pulumi modules, or managing infrastructure configuration.

    Also in 3 projects that use this

  • onejaejaeSkill

    api-documentation

    API 문서화 스킬. Notion과 Postman에 API 명세를 추가합니다. Use when documenting APIs, updating Notion database, or adding Postman requests.

    Also in 3 projects that use this

  • AnthropicSkill

    system-design

    Design systems, services, and architectures. Trigger with "design a system for", "how should we architect", "system design for", "what's the right architecture for", or when the user needs help with API design, data modeling, or service boundaries.

    Also in 4 projects that use this

  • OpenAISkill

    observability

    Vercel Observability expert guidance — Drains (logs, traces, speed insights, web analytics), Web Analytics, Speed Insights, runtime logs, custom events, OpenTelemetry integration, and monitoring dashboards. Use when instrumenting, debugging, or optimizing application performance and user experience on Vercel.

    Also in 4 projects that use this

  • VercelSkill

    technical-writing

    Write, edit, review, or audit user-facing documentation for the eve repository. Use for changes under docs/, documentation tied to eve APIs or CLI behavior, docs work based on Slack or support feedback, and requests to make eve docs clearer, more natural, or less AI-patterned while verifying claims against current source, tests, CLI help, public releases, and repository conventions.

    Also in 4 projects that use this

The file

We split this skill into the rules it gives an agent

10 rules. 0 are common, 7 are distinctive, and 3 are very specific to this project.

  • 0

    Common

    Most of the 18 edited versions we read keep these.

  • 7

    Distinctive

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Discovery before implementation: before writing pipeline code, verify: source schema shape, target write mode, partition strategy, and …

    line 22
  2. Distinctive:

    No transformations, no deduplication

    line 70
  3. Very specific:

    DataFrame API over RDD: Always import pyspark.sql.functions as F and use F.col() notation.

    line 114
  4. Distinctive:

    Prefer built-in Spark functions over Python UDFs.

    line 116
  5. Very specific:

    Default write format is delta.

    line 121
  6. Very specific:

    Prefer MERGE INTO (upsert) over full overwrites for incremental loads.

    line 122
  7. Distinctive:

    Does NOT manage cloud infrastructure (use ops skill for IaC)

    line 167
  8. Distinctive:

    Does NOT build ML model training pipelines (use ai-engineer agent)

    line 168
  9. Distinctive:

    Does NOT implement real-time streaming without explicit architecture approval (see Streaming Patterns section for reference patterns that …

    line 169
  10. Distinctive:

    Does NOT skip schema validation even for exploratory pipelines

    line 170

“Common” is measured: kept by at least 6 in 10 of the 18 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Data Engineering Skill

Version: 9.0 | Updated: 01-July-2026 | Architect: Karim Bhalwani |

Unified reference for data pipeline design, implementation, and optimization. Covers the full stack: schema design, Spark tuning, dbt patterns, SQL optimization, and data quality.

Behavioral Directives

  • One clear approach: recommend a single implementation path. Present alternatives only when you can cite a concrete, measurable tradeoff (e.g., 2x higher latency but 50% lower cost) supported by the user's stated requirements. Do not present alternatives based on general performance assumptions. Do NOT list anti-patterns as options.
  • Discovery before implementation: before writing pipeline code, verify: source schema shape, target write mode, partition strategy, and idempotency guarantees.
  • Fail fast, explain clearly: error messages from validators and quality checks must double as remediation instructions for the next agent or human.

Pipeline Routing Guide

Answer these four questions in order to determine the correct pattern. If the pipeline spans multiple transformation scopes (e.g., both Silver and Gold), address each layer separately in order. If the request is ambiguous about scope, ask one clarifying question before proceeding.

1. What is your data source type?

  • Batch (historical snapshots, full scans, scheduled loads) → Go to Step 2
  • Streaming (real-time events, CDC, append-only feeds) → Go to Streaming Patterns below

2. For batch pipelines: What transformation scope?

  • No transformation (raw ingestion) → Use Bronze Layer (append-only, schema-on-read)
  • Deduplication, conformance, SCD → Use Silver Layer (MERGE with schema enforcement)
    • Type 1 SCD (overwrite current) → Use whenMatchedUpdateAll in MERGE
    • Type 2 SCD (preserve history) → Use Data Vault Satellites or _valid_from / _valid_to columns
  • Aggregation, star schema → Use Gold Layer (Materialized View or pre-aggregated table)

3. What transformation framework?

  • SQL-dominant, multiple models, clear lineage → Use dbt (staging → intermediate → marts)
  • Complex logic, UDFs, feature engineering → Use PySpark DataFrame API
  • Both SQL and complex logic → Use dbt for SQL models + PySpark for heavy transforms

4. Data quality requirements?

  • Schema validation at entry → Apply StructType enforcement or dbt schema tests in Bronze/Staging
  • Business rule checks → Implement Great Expectations suite or dbt custom generic tests in Silver/Intermediate
  • Monitoring & alerting → Add row count / null rate / freshness checks on Gold layer

Streaming Patterns

Architecture approval required: these patterns are reference material only. Do NOT implement real-time streaming without explicit architecture approval. If the user requests streaming help, confirm approval exists before providing implementation guidance.

  • File ingestion (cloud storage) → Use Auto Loader or Spark Structured Streaming
  • CDC or change feed → Use MERGE with sequence column for deterministic ordering
  • Append-only events → Use Streaming write with checkpointing
  • Windowed aggregation → Use stateful streaming with watermark

Medallion Architecture

Bronze (Raw Ingestion)

  • Append-only, schema-on-read
  • Preserve source metadata: _source_file, _ingested_at, _batch_id
  • Partition by ingestion date: _ingested_date
  • No transformations, no deduplication

Silver (Conformed)

  • Schema enforcement with MERGE (Type 1 or Type 2 SCD)
  • Deduplication, null handling, type casting
  • Business keys as primary identifiers
  • Partition by business date or entity key prefix

Bronze-to-Silver Pattern (PySpark)

from delta.tables import DeltaTable

target = DeltaTable.forPath(spark, silver_path)
target.alias("t").merge(
    bronze_df.alias("s"),
    "t.business_key = s.business_key"
).whenMatchedUpdateAll(
    condition="s._ingested_at > t._ingested_at"
).whenNotMatchedInsertAll().execute()

Gold (Business)

  • Pre-aggregated, query-optimized views
  • Star schema or wide denormalized tables
  • Partition by common query dimensions (date, region)
  • Z-ORDER on high-cardinality filter columns

Data Vault 2.0

Three core table types: Hubs (business keys, append-only), Links (relationships between hubs), Satellites (descriptive attributes, Type 2 history). Hash keys use SHA-256 of uppercase-trimmed business keys. Load date = source system timestamp, not processing time.

Full DDL patterns, loading code, and PIT/Bridge tables: references/data-vault.md

PySpark Optimization

Key rules: target 128-256MB per partition, broadcast tables < 100MB, filter before joins, prefer explicit StructType over inferSchema, enable AQE (spark.sql.adaptive.enabled = true).

Full tuning guide with code examples, skew handling, and config reference: references/pyspark-optimization.md

PySpark Coding Standards

  • DataFrame API over RDD. Always import pyspark.sql.functions as F and use F.col() notation.
  • Chain transformations logically; break long chains with \ or parentheses for readability.
  • Prefer built-in Spark functions over Python UDFs; UDFs bypass Catalyst optimizer and hurt performance.
  • Schema-validate DataFrames at pipeline entry points before any transformations ("fail fast").
  • Never .collect() large DataFrames: .collect() pulls all data to the driver, causing OOM. Use .limit(n).collect() for sampling, or write to storage.
  • Cache strategically: .cache() or .persist(StorageLevel.DISK_AND_MEMORY) for DataFrames reused 3+ times. Always .unpersist() when done to free memory.
  • Broadcast small tables in joins: wrap with F.broadcast(small_df) for any join side < ~100 MB to avoid full shuffle.
  • Default write format is delta. Use mergeSchema=True for additive schema evolution; overwriteSchema=True only when intentionally replacing the schema.
  • Prefer MERGE INTO (upsert) over full overwrites for incremental loads.

dbt Transformation Patterns

Three-layer model organization: staging/ (1:1 source mirrors), intermediate/ (business logic), marts/ (final entities). Naming: stg_<source>__<entity>, int_<entity>__<verb>, fct_<entity> / dim_<entity>. Test every primary key with unique + not_null.

Full patterns with incremental strategies, YAML examples, and project scaffolding: references/dbt-patterns.md

Data Quality Frameworks

Gate pattern: Source -> Schema Validation -> Null/Range Checks -> Uniqueness -> Business Rules -> Write. Fail fast at entry point, quarantine rejected records (never silently drop), alert on threshold breaches.

Full guide with Great Expectations, dbt tests, quarantine code, and alert thresholds: references/data-quality.md

SQL Optimization

Key rules: CTEs over subqueries, EXISTS over IN, window functions over self-joins, composite indexes with most selective column first. Always run EXPLAIN ANALYZE on slow queries and ANALYZE tables after bulk loads.

Full reference with index design, query patterns, EXPLAIN reading guide, and anti-patterns: references/sql-optimization.md

Pipeline Orchestration Patterns

Core rules: idempotent tasks (re-runnable without side effects), execution_date for time partitioning, sensor timeouts always set, retry with exponential backoff, alert on task failure (not just DAG failure).

Full patterns with code examples, circuit breakers, and DAG design: references/pipeline-orchestration.md

Definition of Done

  • Pipeline is idempotent (re-runnable without side effects)
  • Data quality checks pass (schema validation, null/range checks, uniqueness)
  • dbt tests pass (unique, not_null, relationships on all keys)
  • Spark jobs have no shuffle spills and partitions are within 128-256MB target
  • Quarantine table exists for rejected records (no silent data drops)

When to Load This Skill

  • Building or reviewing any data pipeline (ETL/ELT)
  • Optimizing Spark jobs or SQL queries
  • Designing data schemas (Medallion, Data Vault, star schema)
  • Implementing data quality checks
  • Working with dbt models or Airflow DAGs
  • Reviewing pipeline architecture

Constraints

  • Does NOT manage cloud infrastructure (use ops skill for IaC)
  • Does NOT build ML model training pipelines (use ai-engineer agent)
  • Does NOT implement real-time streaming without explicit architecture approval (see Streaming Patterns section for reference patterns that require this approval)
  • Does NOT skip schema validation even for exploratory pipelines

Common Traps

TrapWhy It FailsCorrect Approach
Using inferSchema in productionNon-deterministic across files, slow on large datasetsDefine explicit StructType schema. Store as JSON or Python constant
repartition() before coalesce()Triggers a full shuffle only to reduce partitionsUse coalesce(n) to reduce without shuffle. Only repartition(n, col) when changing partition keys
Running OPTIMIZE + ZORDER on every writeCompaction overhead exceeds benefit for small/frequent writesSchedule OPTIMIZE as a separate maintenance job (daily or after N writes)
Aggregation in a streaming tableStreaming tables are append-only; aggregates require recomputationUse a Materialized View with batch read for Gold-layer aggregations
UNION of streaming sourcesNon-deterministic ordering, potential data loss on failureUse multiple append flows (fan-in), one per source
SELECT * in production queriesReads unnecessary columns, breaks on schema changesExplicitly name required columns
Functions on indexed columns in WHEREBreaks predicate pushdown (e.g., WHERE UPPER(name) = 'X')Use computed/generated columns or functional indexes
cache() without unpersist()Memory leak across long-running jobsCache only when reused 3+ times; always unpersist() after last use
Implicit type conversions in joinsSilent mismatches cause wrong results or slow hash joinsCast join keys to identical types explicitly before the join
Skipping schema validation in BronzeCorrupt upstream data propagates silently to Silver/GoldValidate schema at entry point; quarantine non-conforming records
Hardcoded file paths or connection stringsBreaks across environments (dev/staging/prod)Use parameterized paths and environment-based configs (env vars, Airflow Variables)
Non-idempotent pipeline tasksRe-runs create duplicates or partial writesUse MERGE or replaceWhere overwrite semantics; design for safe re-execution

Integration Points

  • architect: Provides data model specs and pipeline architecture decisions
  • guardian: Reviews pipeline code for quality, security (secret handling), and performance
  • ops: Handles CI/CD pipeline deployment and Airflow DAG scheduling
  • context-engineer: Documents data lineage and pipeline decisions in Project Bible
  • data-analyst: Queries and analyzes data in Azure SQL / SQL Server using optimized T-SQL and Data Vault patterns

References

Load these on demand for deep-dive guidance. Read the relevant reference before writing code for that domain. If a reference file cannot be loaded, state which file is missing and provide guidance based only on the patterns documented in this skill file. Do not fabricate content from unavailable references.

Reference Guides

  • PySpark Optimization - partitioning, joins, broadcast, skew handling, shuffle reduction, memory tuning
  • dbt Patterns - model organization, naming, incremental strategy, testing, documentation
  • Data Vault 2.0 - hubs, links, satellites, hash key rules, load date conventions
  • SQL Optimization - index strategy, query patterns, EXPLAIN analysis, anti-patterns
  • Data Quality - Great Expectations, quality gate pattern, dbt tests, monitoring
  • Pipeline Orchestration - Airflow best practices, error handling, retry patterns

Scripts

  • validate_schema.py - DataFrame schema contract validator. Run after every transformation step to catch missing columns, type mismatches, and nullable violations before writing to Delta. Produces agent-legible remediation instructions on failure.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.