Tinker AI
Read reviews

Outcome

Pipeline shipped with 90+ validation rules; catches ~12 data quality issues per week that previously slipped through

5 min read

A team I worked with had recurring data quality issues — bad data flowing through their ETL pipeline into their warehouse, eventually surfacing as wrong dashboard numbers or broken reports. Building a validation layer was overdue. I led the project using Cursor; it shipped in 9 days vs the estimated 3 weeks.

Data validation work has properties that fit AI tools well: clear inputs, clear outputs, repetitive patterns, testable logic. Worth understanding why this fit.

The project

The setup:

  • Existing ETL pipeline (Airflow + Python)
  • Data lands in Snowflake from various sources
  • Reporting and dashboards consume from Snowflake
  • Quality issues were caught (manually) maybe 60% of the time before reaching reports

The plan: build a validation layer that runs after each ETL job. Validations check business invariants (this column should never be null, this value should be in this range, this relationship should hold). Failures trigger alerts and (optionally) block downstream consumption.

The architecture

We picked a structured approach:

@validate(table="orders")
class OrdersValidator:
    @rule("Order ID is unique")
    def order_id_unique(self, df):
        return df["order_id"].is_unique
    
    @rule("Total amount is non-negative")
    def total_amount_positive(self, df):
        return (df["total_amount"] >= 0).all()
    
    # ... more rules

Each table has a validator class. Each validator has multiple rules. Rules are independent; failures are reported individually.

Cursor’s contribution

The pattern emerged quickly. After defining the structure, scaling it was the kind of work Cursor handles well.

For each new validator class:

  1. I’d describe the table being validated
  2. Cursor would generate the class structure
  3. I’d describe the rules in plain English
  4. Cursor would convert each rule to a validation method

Average time per validator: 25 minutes for 10-15 rules. Manual would have been ~75 minutes.

Specific things Cursor handled well:

  • Translating “value should be in range [0, 100]” to Pandas DataFrame operations
  • Handling null values correctly (rules need to specify whether nulls are valid)
  • Generating SQL-friendly versions of the validations (we needed both Python and SQL forms)
  • Writing tests against synthetic data

Specific things that needed human input:

  • Deciding which rules to include (business judgment)
  • Setting thresholds (10% null is OK; 50% null isn’t — these are business calls)
  • Prioritizing by severity (which failures block downstream vs alert only)

A pattern that worked

For the SQL versions of validations, Cursor was particularly useful.

A rule like “this column should match a specific format” can be expressed in Python (regex match) or SQL (REGEXP_LIKE). Both should match. Cursor could generate both forms from one description:

> "phone_number should match E.164 format"

> Generate both the Python validation rule and the equivalent SQL.
> Use the existing rule decorator pattern.

Cursor produced both. They matched. Lost time on inconsistencies between Python and SQL rule definitions: ~zero.

What we learned

A few observations from the project:

90 rules is a lot to write. The total work was 90+ rules across 8 tables. Without Cursor, this would have been weeks of repetitive work. With Cursor, it was days.

The rules are easy to write but tedious. Each rule individually is 5-10 lines. The cumulative volume is what makes it tedious. AI tools shine for “easy but voluminous” work.

Domain knowledge dominates rule selection. Cursor wrote good rules from descriptions. The hard part was knowing which descriptions to give it. Domain experts (in this case, the data team) had to identify what to validate.

Tests were critical. Each rule had tests with synthetic data exercising the validation. Cursor wrote these. They caught a few cases where the rule’s intent didn’t match the implementation.

Productivity numbers

  • Estimated time: 3 weeks
  • Actual time: 9 days
  • Cursor cost: ~$15
  • Rules implemented: 92
  • Bugs caught in production data within first month: 47

The 47 bugs caught are the value. Each represents a data quality issue that would have hit a dashboard or report. At minimum, hours of investigation saved per bug. At maximum, a customer-impacting issue prevented.

The pipeline pays for the AI tooling cost trivially within the first week.

Recommendation

For teams considering similar data quality projects:

Do it. Most teams under-invest in data validation. The investment pays back quickly.

Use AI tools. This is a sweet spot. Repetitive, structured, easily testable.

Codify the pattern early. Spend the first day on the validation framework. Spend the rest on rules.

Get domain experts to specify rules. Not engineers. Data team, business analysts, product folks. They know what should be validated.

Test extensively. Synthetic data tests verify the rules work. Real data tests verify the rules are useful.

Run the validations in production. Surface failures via alerts (Slack, PagerDuty, etc.). Make them visible.

What I’d repeat

For similar projects:

  • The validator class pattern (decorator-based, declarative)
  • Generating both Python and SQL forms when needed
  • Heavy use of AI for the rule implementation
  • Extensive synthetic data tests

What I’d change:

  • Spend more time on the alerting UX. Failures should be actionable.
  • Build a dashboard of historical failures. Trends are useful.
  • Set up retraining for the validation models (some rules benefit from learning from data).

A meta point

Data validation is one of those projects that:

  • Everyone knows is needed
  • Nobody wants to do (tedious)
  • Produces real value when done
  • Is straightforward AI tooling fit

For teams with data quality issues, this is among the highest-leverage projects to take on with AI assistance. The cost is bounded (1-3 weeks); the benefit is ongoing (better data quality forever); the AI helps efficiently.

If your team has been talking about data quality for a year without doing anything, this is the project to do this quarter. AI tooling makes it tractable.