---
name: al-668-turn-giant-legacy-sql-into-snowflake-and-dbt-with-an-agen
description: "Zensar's case study describes an Agentic AI modernization framework for a leading US regional bank moving legacy SQL onto Snowflake and dbt. Many queries were 1,000–1,500 lines and failed when sent as a single model call. Zensar built a LangGraph pipeline with Claude models that decomposes large SQL into chunks, applies curated conversion rules, stitches outputs, executes the converted code in Snowflake, captures errors, and runs up to six automated fix iterations. Newly learned rules are stored in Snowflake so later runs improve. The write-up reports handling 1,500+ line workloads and reducing manual debugging through self-healing; it does not publish a bank-wide percent of scripts converted or hours saved. Treat those benefits as directional until you measure on your own estate. Use when the user wants help with sql-to-dbt conversion with self-healing agents (coding) for a small business."
---

# Turn giant legacy SQL into Snowflake and dbt with an agent that chunks the script, converts it, runs it, and self-heals failed validations up to a fixed number of retries

Zensar's case study describes an Agentic AI modernization framework for a leading US regional bank moving legacy SQL onto Snowflake and dbt. Many queries were 1,000–1,500 lines and failed when sent as a single model call. Zensar built a LangGraph pipeline with Claude models that decomposes large SQL into chunks, applies curated conversion rules, stitches outputs, executes the converted code in Snowflake, captures errors, and runs up to six automated fix iterations. Newly learned rules are stored in Snowflake so later runs improve. The write-up reports handling 1,500+ line workloads and reducing manual debugging through self-healing; it does not publish a bank-wide percent of scripts converted or hours saved. Treat those benefits as directional until you measure on your own estate.

## Inputs to collect first
Ask the user for anything below that they haven't already given you. Don't guess missing facts.

- Snowflake/dbt version
- One complex view or procedure, or describe size
- Tolerance

## Instructions

Do the task below with the user's inputs in place of each [bracket].

Plan a SQL-to-Snowflake/dbt conversion agent for my warehouse. Stack: [Snowflake/dbt version], sample object: [paste one complex view or procedure, or describe size]. Constraints: no production writes without my approval; keep business logic comments. 1) Design the agent graph: chunk → convert → stitch → execute-in-dev → capture error → fix (max 6 loops) → human review. 2) Write the conversion rules checklist (dialect changes, temp tables, procedural control flow → dbt models/tests). 3) Define what "validated" means (compiles, row-count check vs source within [tolerance], key column checksum). 4) Specify which failures must stop for a person (permission errors, ambiguous business rules). 5) Give a 5-object pilot plan and the metrics to log (iterations to green, human minutes per object). Do not run against prod.

## Safety checks (share these with the user)

- Remove names, contact details, account numbers and other personal data the task doesn't need before you paste, and check your AI tool's data and training settings.
- Read and edit the draft before it reaches a customer or goes public. If you later automate this prompt, start with "draft and notify me", not "send automatically".
- Check names, dates, numbers and any claim against your own source material before you use the answer. AI can misread or invent details.
- Say clearly which parts need a person to review or approve before anything is sent, paid, posted or filed.

## About this skill

- Works with: LangGraph, Claude, Snowflake, dbt, ChatGPT
- Based on this real-world example: https://www.zensar.com/insights/case-study/banking-and-financial-services/data-engineering-and-analytics/accelerating-enterprise-data-modernization-with-agentic-ai-powered-sql-to-dbt-conversion-on-snowflake
- Free prompt from AgentPlaybook Real Estate: https://agentic-library.netlify.app/prompt/al-668-turn-giant-legacy-sql-into-snowflake-and-dbt-with-an-agent-t/
- To install in an agent that supports Agent Skills, save this file as SKILL.md in a folder with the same name as `name` above (for example in your skills directory). Install steps for Claude.ai, Claude Code, Cursor and Codex: https://agentic-library.netlify.app/skills/
