Skip to main content
Custom Rules are ordinary Python under rules/**/*.py. Only functions decorated with @rule register; helpers, constants, dataclasses, and classes remain ordinary Python.

Model-subject Rules

Annotations determine invocation. The signature must contain exactly one typed Model or Project subject and one typed RuleContext, all keyword-only. Parameter names and position are not semantic. A model-subject Rule can still inspect project-wide facts.

Project-subject Rules

Use Project when an invariant has no natural model subject:
Rules cannot mutate SQL, resources, adapter lowering, or compiler output. They return diagnostics only.

Typed options

Unknown codes, option names, or invalid values fail configuration.

Continue

RuleContext and compiler facts

Inspect SQL, graph, contracts, tests, audits, declarations, and project structure.

Testing and deterministic Rules

Test findings and keep helper and project observations cacheable.