Skip to main content

Claude Prompt to Build an ETL Data Quality Framework

Build a robust ETL data quality framework: validation rules, error handling, data profiling checks, quality scoring, and automated monitoring.

Fill in the placeholders

Edit the values, then copy your finished prompt.

Your Prompt
prompt.txt
You are a data engineering expert. Design a comprehensive data quality and error handling framework for my ETL pipeline.

**Pipeline Context:**
- Source: PostgreSQL production database (read replica) + 3 REST APIs (Stripe, Salesforce, HubSpot)
- Destination: Snowflake data warehouse with dbt transformation layer
- Volume: 2M rows/day from DB, 500K events/day from APIs
- Frequency: Hourly incremental loads, daily full refresh for dimension tables
- Tool: Python + Apache Airflow + dbt

**Design These Components:**

1. **Data Profiling & Validation Rules:**

   For each table/entity in the pipeline, define validation rules at three levels:

   **Schema-Level Checks:**
   - Column existence and data types
   - NOT NULL constraints
   - Unique constraints
   - Foreign key relationships
   - Schema drift detection (source schema changed since last run)

   **Row-Level Checks:**
   - Value range validation (min/max for numbers, length for strings)
   - Format validation (emails, phones, dates, postal codes)
   - Referential integrity (does the foreign key exist in the target?)
   - Business rule validation (e.g., order total = sum of line items)
   - Currency amounts must have exactly 2 decimal places and be positive

   **Dataset-Level Checks:**
   - Row count within expected range (not suddenly 0 or 10x normal)
   - Completeness: percentage of NULL values per column
   - Freshness: newest record timestamp within expected window
   - Distribution: statistical outlier detection on key metrics
   - Duplicates: exact and fuzzy duplicate detection

2. **Error Handling Strategy:**

   | Error Type | Example | Action | Severity |
   |-----------|---------|--------|----------|
   | Schema mismatch | New column in source | Halt + alert | Critical |
   | Null in required field | Missing email | Route to dead letter queue | High |
   | Format violation | Invalid date string | Transform + flag | Medium |
   | Duplicate record | Same ID twice | Keep latest + log | Low |
   | Referential integrity | Unknown foreign key | Quarantine row | High |

   For each error type:
   - Detection mechanism
   - Automated remediation (if possible)
   - Dead letter queue design
   - Alert and notification rules
   - Manual review workflow

3. **Implementation Code:**
   Generate the validation framework in Python + Apache Airflow + dbt:
   - Reusable validation functions for each check type
   - Configuration-driven rules (add new rules without code changes)
   - Error logging with full context (source row, rule violated, timestamp)
   - Summary report generation after each run

4. **Quality Score Dashboard:**
   Design a data quality score (0-100) based on:
   - Completeness (% non-null values)
   - Accuracy (% values passing validation)
   - Timeliness (data freshness)
   - Consistency (cross-source agreement)
   - Uniqueness (% duplicate-free records)

   Generate SQL/queries for each metric.

5. **Monitoring & Alerting:**
   - Quality score trending (detect gradual degradation)
   - Anomaly detection on row counts and distributions
   - Source system health monitoring
   - Pipeline SLA tracking (did it finish on time?)
   - Cost tracking — alert if Snowflake compute credits spike unexpectedly

6. **Recovery Procedures:**
   - How to reprocess failed batches
   - How to reconcile data after an outage
   - Backfill strategy for historical data corrections
   - Idempotency guarantees (safe to re-run)

What this prompt does

This prompt makes the model a data engineering expert that designs a complete data quality and error-handling framework for an ETL pipeline. You describe the pipeline with [data_source], [data_destination], [data_volume], [pipeline_frequency], and [etl_tool], and it returns validation rules, an error-handling strategy, implementation code, a quality-score design, monitoring, and recovery procedures.

The structure is what makes it production-grade. Validation is split into schema-level, row-level, and dataset-level checks, so it catches everything from a dropped column to a sudden 10x row count. The error-handling section maps error types to actions and severities, including a dead-letter queue design for rows that fail. Because you name your [etl_tool], it generates reusable, config-driven validation functions in that stack rather than pseudocode. The [custom_validation] and [monitoring_addition] slots let you bake in business rules and cost alerts specific to your pipeline.

When to use it

  • When bad source data keeps breaking dashboards or reports downstream.
  • Setting up a new pipeline and you want quality gates in from day one, not bolted on later.
  • When you need a dead-letter queue and quarantine workflow for rows that fail validation.
  • To define a single data-quality score that trends over time and flags gradual degradation.
  • When you need idempotent, replayable recovery procedures after a pipeline outage.

Example output

You get layered validation rules (schema, row, dataset) for each entity, an error-handling table mapping error types to detection, remediation, severity, and alerting, plus dead-letter-queue design. Then implementation code in your chosen tool with reusable validators and config-driven rules, a data-quality score (0-100) across completeness, accuracy, timeliness, consistency, and uniqueness with SQL per metric, monitoring and alerting rules, and recovery procedures covering reprocessing, reconciliation, backfill, and idempotency.

Pro tips

  • Name your real [etl_tool] stack (for example Python + Airflow + dbt) so the generated validators use idioms you can actually drop in.
  • Encode genuine business rules in [custom_validation] — things like "order total equals the sum of line items" catch errors generic checks miss.
  • Set [data_volume] and [pipeline_frequency] accurately; the dataset-level row-count and freshness checks key off your expected ranges.
  • Use [monitoring_addition] for cost or SLA concerns specific to your warehouse, such as alerting when compute credits spike unexpectedly.
  • Start by wiring up the dead-letter queue and dataset-level checks first — in my experience those two catch most production surprises before they spread.
  • Treat the generated code as a scaffold: review every threshold and remediation rule against your data before enabling auto-remediation.

Frequently Asked Questions

What ETL tools does this prompt support?
It generates the framework in whatever stack you set in `[etl_tool]`, such as Python with Apache Airflow and dbt. Naming your real tool makes the validation functions and code idioms usable rather than generic pseudocode.
Does it design a dead-letter queue?
Yes. The error-handling section maps error types to actions and severities and includes dead-letter-queue design for rows that fail required checks, plus quarantine handling for referential-integrity failures.
How is the data quality score calculated?
It defines a 0-100 score across five dimensions: completeness, accuracy, timeliness, consistency, and uniqueness. It also generates the SQL or queries to compute each metric so you can track the score over time.
Can it enforce my own business rules?
Yes, through the `[custom_validation]` variable. You supply rules like currency amounts needing exactly two decimal places and being positive, and it adds row-level checks for them alongside the standard validations.
Does it cover recovery after a pipeline failure?
Yes. It includes recovery procedures for reprocessing failed batches, reconciling data after an outage, backfilling historical corrections, and guaranteeing idempotency so re-running the pipeline is safe.
Engr Mejba Ahmed

Need this built for real?

Engr Mejba Ahmed

AI Developer · Software Engineer

I'm Mejba — I design and ship production AI systems, automations, and full-stack apps. If you want this turned into a working solution for your team, let's talk.

More in Data & SQL Prompts

Engr Mejba Ahmed

Engr Mejba Ahmed

AI assistant · trained on my work

👋

Hey there!

Quick Actions

WhatsApp Direct line to me

Chat on WhatsApp

+880 1723 741224 · Replies within the hour on working days

Popular Questions

Engr Mejba Ahmed is connected
Engr Mejba Ahmed is typing...
Engr Mejba Ahmed avatar

✉ Want me to follow up? Drop your email

Engr Mejba Ahmed avatar

📞 Connect Directly

Choose how you'd like to reach me

WhatsApp

+880 1723 741224

Email

mejba.13@gmail.com

✓ Details sent! I'll get back to you shortly.

Powered by OpenAI

335+

Blog Posts

25

AI Courses

63

Projects

Services & Expertise

Pricing & Process

Learning & Resources

Connect & Support