effective-dbt-sql
ما الذي تفعله
تقدم هذه المهارة قواعد لكتابة SQL لنماذج dbt صحيح وسهل القراءة. وهي لمهندسي التحليلات الذين يكتبون نماذج dbt ومقاييسها أو يغيرونها.
متى تستخدمها
- ✓عندما تكون على وشك كتابة SQL داخل نموذج dbt.
- ✓عندما تريد تغيير تعريف SQL لمقياس.
- ✓عندما تقرر ما إذا كنت ستضيف استعلامًا فرعيًا أو تعيد استخدام حقل موجود.
رابط المهارة
https://github.com/lightdash/lightdash/blob/main/skills/effective-dbt-sql/SKILL.mdانسخه والصقه في الذكاء الاصطناعي الذي تستخدمه (Claude أو ChatGPT أو Cursor) واطلب منه اتباع التعليمات.
طريقة الاستخدام
أسهل طريقة: انسخ الرسالة والصقها في الذكاء الاصطناعي الذي تستخدمه. سيقرأ المهارة وينفّذ تعليماتها.
رسالة جاهزة للصق
لـ Claude Code أو Codex أو Cursor: شغّله داخل مجلد مشروعك وستُثبَّت المهارة.
نزّل ملف SKILL.md وضعه في مجلد مهارات وكيلك.
مثال على ما تطلبه من الذكاء الاصطناعي
“أضف مقياس معدل الإلغاء إلى نموذج الاشتراكات، وأعد استخدام الحقول الموجودة بدلًا من تكرار المنطق.”
5 مهارات جديدة كل أسبوع. قراءة في دقيقة واحدة.
كيف تعمل
تطلب المهارة من الوكيل إعادة استخدام الحقول الموجودة حيثما أمكن، وتجنب الاستعلامات الفرعية التي تعتمد على كل صف في الاستعلام الخارجي، وتفضيل 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
- الترخيص
- —
- آخر تحديث
- 2/11/2026
التعليقات
- …
المزيد من المهارات من هذا المستودع
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يساعد وكيلك على البحث عن المقالات العلمية في المجال الطبي الحيوي. مفيد للبحوث التي تحتاج إلى معلومات طبية محددة.