Generate or revise one dbt artifact set from deterministic migration context.
Do not use this skill for batch orchestration. /generate-model owns batching, review loops, commits, and summaries.
-
Check readiness.
uv run --project "${CLAUDE_PLUGIN_ROOT}/packages/ad-migration-internal" migrate-util ready generate \
--object <table_fqn> \
--project-root <project_root>
If ready is false, stop and report the returned code and reason.
-
Assemble deterministic context and choose the generation source.
uv run --project "${CLAUDE_PLUGIN_ROOT}/packages/ad-migration-internal" migrate context \
--table <table_fqn> \
--writer <writer_fqn> \
--project-root <project_root>
Follow context-selection.md. Never generate from proc_body.
-
Generate target dbt SQL that preserves the transformed logic.
Apply dbt-project-standards, sql-style, cte-structure, model-naming, and model-artifact-invariants.
Compute model_name before writing anything. Use the exact model_name for the SQL filename, YAML models[].name, rendered unit test model field, dbt validation selector, catalog writeback, and returned artifact_paths. Do not use dbt-style word splitting for CamelCase legacy object names.
Preserve target column names exactly as listed in catalog context. Do not snake_case, rename, drop, or re-order locked target columns while applying SQL style.
Add required dbt control columns in the final projection before writing: _dbt_run_id as '{{ invocation_id }}' for every generated model, and _loaded_at as {{ current_timestamp() }} for ordinary table marts and snapshots. These columns are generation metadata; add them even when they are absent from the legacy target table schema.
Use project defaults for ordinary mart tables. Add model-level config( only for exceptions: aliases, schemas, incremental models, snapshots, or view materialization. For source/seed refs and missing wrapper handling, follow artifact-writing.md. For snapshots, follow snapshot-generation.md.
-
Run a logical equivalence pass against the selected transformed SQL.
Follow context-selection.md. Record EQUIVALENCE_GAP in warnings[] if a semantic gap remains.
-
Build schema YAML.
Apply yaml-style and artifact-writing.md. Add deterministic tests from context: PK -> unique and not_null, FK -> relationships, PII -> meta, watermark -> recency.
-
Render canonical unit tests from the approved test spec.
Follow artifact-writing.md. The CLI is the source of truth for canonical unit_tests:. Do not hand-write them.
-
Write artifacts through the CLI.
If the caller supplied a handoff object, use artifact_paths and revision_feedback exactly as given.
Follow artifact-writing.md. Use the CLI-returned written paths. Do not hardcode output paths or use direct file writes.
After writing, verify ordinary migrated targets landed under models/marts/. If the artifact is under models/staging/, do not return success; rewrite through the correct mart path or return status: "error" with GENERATION_FAILED.
-
Compile-validate with dbt using the manifest runtime roles.
Follow validation.md. Record the compile result in execution.dbt_compile_passed. Set execution.dbt_test_passed: false.
-
Record test gaps without mutating approved specs.
If canonical tests expose missing branch coverage, add a warning that names the uncovered branch and leave new scenario creation to /generate-tests.
-
Write generation status to catalog.
The generator owns generation facts, not reviewer judgment.