用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/godatadriven/dbt-bouncer --skill new-check命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
基于 SOC 职业分类
正在显示 SKILL.md
| name | new-check |
| description | Scaffold a new dbt-bouncer check class with tests |
Follow these steps to add a new check to dbt-bouncer.
src/dbt_bouncer/checks/<category>/.Use the @check decorator, passing the rule code. Everything else is inferred from the function signature:
from dbt_bouncer.check_framework.decorator import check, fail
@check(code="XX000")
def check_model_xxx(model):
"""Check description."""
if some_condition:
fail(f"`{model.unique_id}` failed because ...")
code is the only argument @check takes. All other metadata is inferred from the function signature:
MO048. See "Assign a rule code" below.name: value in YAML config).ctx). If there are none, the check is global (runs once with context only).*) become user-configurable Pydantic fields.(resource, ctx, *, params). Resource first, ctx second. Putting ctx before the resource breaks iterate_over inference. For context-only checks, use (ctx, *, params).@check(code="MO021")
def check_model_description_populated(model):
"""Models must have a populated description."""
if not model.description or len(model.description.strip()) < 4:
fail(f"`{model.unique_id}` does not have a populated description.")
@check(code="MO038")
def check_model_names(model, *, model_name_pattern: str):
"""Models must have a name matching the supplied regex."""
import re
if not re.match(model_name_pattern, model.name, re.IGNORECASE):
fail(f"`{model.unique_id}` does not match pattern `{model_name_pattern}`.")
@check(code="MO044")
def check_model_test_coverage(ctx, *, min_model_test_coverage_pct: float = 100):
"""Set the minimum percentage of models that have at least one test."""
...
fail() — raises DbtBouncerFailedCheckErrorfail("message")
Every check needs a unique rule code: a 2-letter resource prefix plus a 3-digit number, e.g. MO048. Two steps:
Pass it to the decorator: @check(code="MO048").
Add the matching member to the resource's *RuleCode enum in src/dbt_bouncer/enums.py, keeping alphabetical order:
class ModelRuleCode(StrEnum):
CHECK_MODEL_XXX = "MO048"
Use the next free number for the prefix — read the enum to find it. Never reuse or renumber a published code; users reference codes in their config.
Prefixes: CA catalog, EX exposure, LI lineage, MA macro, ME metadata, MO model, RR run results, SE seed, SM semantic model, SN snapshot, SO source, TE test, UT unit test.
dbt-bouncer-example.ymldbt-bouncer --config-file dbt-bouncer-example.ymlUse check_passes / check_fails from dbt_bouncer.testing:
from dbt_bouncer.testing import check_fails, check_passes
def test_pass():
check_passes("check_model_xxx", model={"name": "valid"}, my_param="value")
def test_fail():
check_fails("check_model_xxx", model={"name": "invalid"}, my_param="value")
# For context-dependent checks:
def test_with_context():
check_passes("check_model_xxx",
model={"name": "m1"},
ctx_models=[{"name": "m1"}, {"name": "m2"}])
ctx_* kwargs build the CheckContext automatically__init__.py exists in the test subdirectorymise run generate-schema
mise run generate-rule-codes-doc
mise run test-unit
prek run --all-files
The rule-codes-doc-check hook fails if a check has no code, if a declared code is unused, or if docs/checks/rule_codes.md has drifted.