effective-dbt-sql
하는 일
이 스킬은 정확하고 읽기 쉬운 dbt 모델 SQL을 작성하기 위한 규칙을 제공합니다. dbt 모델과 지표를 쓰거나 바꾸는 분석 엔지니어를 위한 스킬입니다.
사용하는 경우
- ✓dbt 모델 안에 SQL을 쓰려고 할 때.
- ✓지표의 SQL 정의를 바꾸고 싶을 때.
- ✓서브쿼리를 추가할지 기존 필드를 재사용할지 결정할 때.
스킬 링크
https://github.com/lightdash/lightdash/blob/main/skills/effective-dbt-sql/SKILL.md복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.
사용 방법
가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.
바로 붙여넣을 수 있는 메시지
Claude Code, Codex, Cursor용입니다. 프로젝트 폴더에서 실행하면 스킬이 설치됩니다.
SKILL.md를 다운로드해 에이전트의 스킬 폴더에 넣으세요.
AI에게 요청하는 예시
“subscriptions dbt 모델에 이탈률 지표를 추가해 주세요. 같은 로직을 반복하지 말고, 이미 있는 필드를 재사용해 주세요.”
매주 새 스킬 5개. 읽는 데 1분.
작동 방식
스킬은 가능하면 기존 필드를 재사용하고, 바깥 행마다 달라지는 상관 서브쿼리를 피하며, 복잡한 로직에는 CTE를 쓰라고 에이전트에게 지시합니다. 또한 저장소에 이미 쓰이는 스타일에 맞추라고 요청합니다.
기술 내용 (원본 SKILL.md)
작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.
Effective dbt SQL
Write dbt model SQL that is correct, readable, and idiomatic. This skill is about the semantics of the SQL you write — not naming or formatting.
Scope
Use this when you are about to write or change SQL inside a dbt model (.sql), or a metric/dimension whose value is defined by SQL.
This skill covers semantics only. It does not prescribe naming schemes, file layout, or indentation. For those, follow the rule below.
Match the target repo first. These are fallback defaults, not mandates. Before applying any rule, read the models around the one you are changing and match the repo's established conventions where they differ. Apply these rules to new or changed SQL only — do not reformat, rename, or restructure existing code that already works.
The rules
Reuse before you re-derive. If the value you are asked for is already expressed by an existing dimension or metric — or by two of them combined — compose those fields instead of writing new SQL to recompute it. Read the model's existing dimensions/metrics before adding one. See reuse-over-subqueries.
No correlated subqueries. Never compute a value with a subquery that references the outer query's rows (a per-row correlated subquery in
SELECTorWHERE). Reuse an existing field, or join to an aggregated CTE instead. This is the single most common mistake. See cte-pipelines.CTEs over nested subqueries. Structure a query as a pipeline of named CTEs, each referenced by the next, ending in a final
select. Prefer this over subqueries nested insidefrom/where. See cte-pipelines.Explicit joins. Always state the join type (
inner/left/…) and theoncondition. Never comma-join. Know the grain: a join that fans out rows silently changes every downstream aggregate.Explicit columns. Select named columns rather than
select *when adding or changing what a model emits, so a change to an upstream model can't silently alter this model's output. (A pass-throughselect * from finalat the very end of a CTE pipeline is fine — the columns are already pinned by the CTEs.)Don't break references. Before editing a model's SQL, read the
source()/ref()models it selects from. Do not rename or remove a column that downstream models orschema.ymlreference without checking the impact first.
Not in scope
- Emitted-type / casting safety (e.g. boolean-vs-numeric column types): follow the warehouse skill the system prompt points you to (
/home/user/.lightdash-skills/). This skill does not restate casting rules. - Naming and formatting conventions: match the target repo (see the rule above).
자주 묻는 질문
이름이나 서식도 바꾸나요?
아니요, 스킬은 이름이나 배치가 아니라 SQL의 의미를 다룹니다.
기존 코드를 다시 쓰나요?
아니요, 스킬은 새로 만들거나 바뀐 SQL에만 적용되며, 작동하는 코드는 다시 쓰지 않습니다.
상관 서브쿼리란 무엇인가요?
바깥 쿼리의 행을 참조하는 서브쿼리이며, 스킬은 이를 피하라고 말합니다.
상세 정보
작성자의 원본 설명
Use when writing or modifying dbt model SQL — deciding whether to add a subquery or reuse an existing dimension/metric, structuring a query, joining models, or refactoring a metric's SQL. Encodes SQL semantic-correctness rules: reuse existing fields, prefer CTEs over correlated subqueries, and make joins and column lists explicit.
repo: lightdash/lightdash
인기도
- GitHub 스타
- 6.2k
- 순위
- #14405
- 라이선스
- —
- 업데이트
- 2026. 11. 2.
댓글
- …
이 저장소의 다른 스킬
breakup-pr
6.2k에이전트가 큰 풀 리퀘스트를 검토하고 병합할 수 있는 작은 스택형 조각으로 나누도록 돕습니다.
lightdash-agent-slack-messaging
6.2k에이전트가 제공된 근거만 바탕으로, Lightdash 관리자를 위한 명확하고 친근한 유지 보수 및 활동 보고서를 작성하도록 돕습니다.
developing-in-lightdash
6.2k에이전트가 Lightdash 대시보드와 차트를 JSON으로 읽고, 만들고, 수정하도록 돕습니다. 차트 종류별 설정도 포함합니다.
filter-expressions
6.2k에이전트가 Lightdash 지표 쿼리에 쓸 필터 식을 올바르게 작성하도록 돕습니다. 사용자 정의 지표에 대한 필터도 포함합니다.
비슷한 스킬
discrawl
394k에이전트가 저장된 로컬 Discord 메시지 보관본을 검색하고 요약하며, 최신 상태를 확인하고 다이렉트 메시지를 읽도록 돕습니다.
clickhouse-io
280k에이전트가 ClickHouse 데이터베이스의 쿼리와 스키마를 최적화하도록 돕습니다. 고성능 분석 작업의 모범 사례를 적용합니다. 분석 쿼리가 느릴 때 씁니다.
scientific-db-pubmed-database
280k생의학 분야의 과학 논문을 에이전트가 검색하도록 돕습니다. 특정 의학 정보가 필요한 연구에 유용합니다.