Simple Example
Copy
Ask AI
name: breaking-change-detector
description: Catch breaking changes before they reach production
triggers:
- type: pull_request
on_changed_files: "models/**/*.{sql,yml}"
tools:
preset: safe # Read-only, can't commit or push changes
prompt: |
Check for breaking changes:
1. Compare old vs new: any columns removed?
2. Find downstream models that use those columns
3. Comment on PR with impact assessment
Mark as "changes requested" if HIGH risk found.
More Robust Example
Production-ready with full impact analysis:Copy
Ask AI
name: breaking-change-detector
description: Detect and assess impact of breaking changes in PRs
triggers:
- type: pull_request
on_changed_files: "models/**/*.{sql,yml}"
branches: ["main", "staging", "production"]
tools:
preset: safe # Read-only, can't commit or push changes
prompt: |
Analyze this PR for breaking changes to data contracts.
## 1. Detect changes
For each modified model:
a) Columns removed or renamed?
- Compare old vs new SELECT statements
- Compare YAML column lists
- Note any missing columns
b) Data types changed?
- Look for modified CAST statements
- Check YAML type specifications
- Flag: VARCHAR → INT, DECIMAL → INT, wider → narrower
c) Filters added/changed?
- New WHERE clauses (removes rows)
- Modified JOIN conditions
d) Grain changed?
- New/removed GROUP BY columns
- New DISTINCT clauses
## 2. Assess downstream impact
For each breaking change:
a) Find references:
- Search for ref('model_name') in all models
- Check which columns they select
- Look for direct column references
b) Calculate risk:
- HIGH: Removed column + found usage downstream
- MEDIUM: Type change + usage in calculations
- LOW: Column added (non-breaking)
## 3. Generate PR comment
Structure:
Breaking Changes Detected
HIGH RISK:
• Model: stg_customers
- Removed: email column
- Impact:
✗ customers (line 45: SELECT email)
✗ user_360 (line 89: email_domain calculation)
✗ orders_enriched (line 23: LEFT JOIN on email)
- Action: Update downstream models OR keep column with deprecation
MEDIUM RISK:
• Model: stg_orders
- Changed: order_id type VARCHAR → INT
- Impact:
⚠ order_metrics (line 67: CONCAT with order_id)
- Action: Verify string operations still work
## 3. Set PR status
- HIGH risk: Set to "changes requested"
- MEDIUM risk: Set to "needs review"
- LOW/none: Set to "success"
## 4. Alert if HIGH risk
Send Slack to #data-pipeline:
"PR #{{pr.number}} has HIGH RISK breaking changes.
Review required: {{pr.url}}"