migrating-sql-to-dbt

For migrating legacy SQL into modular dbt models. Use when converting stored procedures, views, or raw SQL files into dbt models; when tasks mention “migrate/convert/legacy SQL/convert to dbt/modernize”; when splitting monolithic queries into modular layers (first discover project conventions); and when porting existing data pipelines or ETL into dbt. Build and validate layer by layer by inspecting existing models/sources.

Last repository push
GitHub Stars
137
Forks
13
Issues / PRs
5

Installation

Review the source and dependencies with a prompt. A package is available to download.

Install with an AI assistant

Copy the prompt so your assistant can review the pinned revision and dependencies first.

View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "migrating-sql-to-dbt" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-59ea2b4452437034ed645da1e8adb885e4cc321c7eb06e3cb7c08ec4d7a8b628. Verify the upstream source and version against https://github.com/AltimateAI/data-engineering-skills before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.

Source and setup

github.com

Setup guidance pending

See the original source for supported tools, dependencies, and permissions.

Installation test pending

For migrating legacy SQL into modular dbt models. Use when converting stored procedures, views, or raw SQL files into dbt models; when tasks mention “migrate/convert/legacy SQL/convert to dbt/modernize”; when splitting monolithic queries into modular layers (first discover project conventions); and when porting existing data pipelines or ETL into dbt. Build and validate layer by layer by inspecting existing models/sources.

0 Downloads

Introduction source: third_party · AltimateAI · 0.0.1 Reference

SkillPi interpretation

Tasks
Don't convert everything at once. Build and validate layer by layer.**
Testing
Not tested

Browse files

Browse files at the source ↗

Original SKILL.md

Open original ↗
Frontmatter
name: migrating-sql-to-dbt
description: |
  Converts legacy SQL to modular dbt models. Use when migrating SQL to dbt for:
  (1) Converting stored procedures, views, or raw SQL files to dbt models
  (2) Task mentions "migrate", "convert", "legacy SQL", "transform to dbt", or "modernize"
  (3) Breaking monolithic queries into modular layers (discovers project conventions first)
  (4) Porting existing data pipelines or ETL to dbt patterns
  Checks for existing models/sources, builds and validates layer by layer.

dbt Migration

Don't convert everything at once. Build and validate layer by layer.

Workflow

1. Analyze Legacy SQL

cat <legacy_sql_file>

Identify all tables referenced in the query.

2. Check What Already Exists

# Search for existing models/sources that reference the table
grep -r "<table_name>" models/ --include="*.sql" --include="*.yml"
find models/ -name "*.sql" | xargs grep -l "<table_name>"

For each table referenced in the legacy SQL:

  1. Check if an existing model already references this table
  2. Check if a source definition exists
  3. If neither exists, ask user: "Table X not found - should I create it as a source?"

Only proceed to intermediate/mart layers after all dependencies exist.

3. Create Missing Sources

# models/staging/sources.yml
version: 2

sources:
  - name: raw_database
    schema: raw_schema
    tables:
      - name: orders
        description: Raw orders from source system
      - name: customers
        description: Raw customer records

4. Build Staging Layer

One staging model per source table. Follow existing project naming conventions.

Build before proceeding:

dbt build --select <staging_model>

5. Build Intermediate Layer (if needed)

Extract complex joins/logic into intermediate models.

Build incrementally:

dbt build --select <intermediate_model>

6. Build Mart Layer

Final business-facing model with aggregations.

7. Validate Migration

# Build entire lineage
dbt build --select +<final_model>
dbt show --select <final_model>

Migration Checklist

  • [ ] All source tables identified and documented
  • [ ] Sources.yml created with descriptions
  • [ ] Staging models: 1:1 with sources, renamed columns
  • [ ] Intermediate models: business logic extracted
  • [ ] Mart models: final aggregations
  • [ ] Each layer compiles successfully
  • [ ] Each layer builds successfully
  • [ ] Row counts match original (manual validation)
  • [ ] Tests added for key constraints

Common Migration Patterns

  • Nested subqueries → Separate models (staging → intermediate → mart)
  • Temp tables → Ephemeral materialization {{ config(materialized='ephemeral') }}
  • Hardcoded values → Variables {{ var("name") }}

Anti-Patterns

  • Converting entire legacy query to single dbt model
  • Skipping the staging layer
  • Not validating each layer before proceeding
  • Keeping hardcoded values instead of using variables
  • Not documenting business logic during migration

Current listing version

0.0.1

Verify the source revision ↗

Safety and assessment details

Quality assessment

Out of 100 · Assessment report from SkillPi LAB.

Scenario Value85/100

Highlights

  • 提供完整的 SQL 到 dbt 迁移工作流
  • 包含详细的检查清单和验证步骤
  • 针对数据工程师的实际迁移痛点
Trigger Precision95/100

Highlights

  • 触发词覆盖全面,包含多种关键词变体
  • 适用场景描述清晰,边界明确
Structure and Standards90/100

Areas to improve

  • 缺少 When to Use 章节 Reported severity: Minor

    文档结构完整但缺少明确的 When to Use 章节

    Recommendation: 建议添加 When to Use 章节以增强文档规范性

Highlights

  • 工作流步骤清晰,包含端到端示例
  • 提供了迁移检查清单和常见模式
  • frontmatter 完整,结构组织良好
Execution Reliability88/100

Highlights

  • 提供具体的 dbt 命令示例
  • 包含逐层验证机制
  • 覆盖主要异常情况和反模式提醒
Evidence Verifiability (mean of the first four)90/100

The arithmetic mean of the first four original scores, rounded to a whole number.

Static text checks

100 / 100 · skillpi-20261123-no-r3-v1

No current rules matched the text.

This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.

Permissions and checks before use

Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.

These common operations were not identified in the main document. This does not mean no permissions or risks exist.

These notices grant no permissions. Your host tool must still confirm file changes, secrets, external transfers or costs as needed.

Security rating and access scope

safe · Static evidence review; not a runtime safety guarantee.

Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.