Skip to content

feat: pre-commit hook to block commits with missing dbt YAML property files #3595

@cbini

Description

@cbini

Summary

Add a git pre-commit hook that checks staged .sql files for matching YAML property files.

Motivation

Developers can accidentally commit new SQL models without creating the companion YAML, bypassing contract enforcement entirely. A pre-commit check catches this before the commit lands.

Proposed behavior

  • New SQL files: block the commit if no matching YAML exists; instruct the developer to create one first (via the dbt Core Tools extension's "Toggle SQL/Properties" command or manually)
  • Modified SQL files: print a non-blocking reminder to run column sync if columns may have changed

Implementation

  • Vanilla .git/hooks/pre-commit shell script (not a Trunk action)
  • Checks properties/<model>.yml (or .yaml) relative to each staged SQL file
  • Covers extracts/ and staging/ model directories

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions