Can an AI Agent Peer Review dbt SQL Before It Hits Production?
One prompt drives the full peer review. Seven mart models come out graded, fixed, and re-validated without a senior engineer in the loop.
OVERVIEW
When a junior engineer pushes their first dbt models to production, the code might be green. Is the SQL actually good? Anti-patterns like SELECT *, unnecessary UNIONs, and phantom joins don't break pipelines immediately, but they compound into expensive, hard-to-maintain technical debt.
Altimate Code automates the entire SQL peer review process in a single prompt. The agent reads every mart model, applies quality checks in parallel, grades the SQL, applies fixes, and re-validates, producing a full audit report with before-and-after scores.
Models that scored D and F grades (due to SELECT * scanning billions of rows, UNION forcing expensive deduplication sorts, and phantom self-joins multiplying row counts) came out at A and B after automated fixes. The agent also flags patterns that aren't errors but warrant a conversation, making it a better teaching tool than a silent linter.
WHAT YOU'LL LEARN
- →How to run automated SQL quality checks across an entire dbt mart layer
- →Which anti-patterns are most expensive in compute and maintainability
- →How to generate before-and-after quality grades for code review
- →How to use AI-generated audit reports to coach junior engineers
KEY POINTS
- Detects SELECT *, UNION without ALL, phantom joins, and subquery wrappers
- Grades every model before and after fixes (D/F → A/B)
- Runs dbt build to validate all fixes compile and execute correctly
- Generates a full recurring-pattern report across the mart layer
- Works in one prompt, with no manual file-by-file review


