Overview

Safety#

Code Name Description Default
SC-S01 update-without-where UPDATE without WHERE affects all rows Error
SC-S02 delete-without-where DELETE without WHERE affects all rows Error
SC-S03 no-select-star SELECT * makes queries fragile when columns change Warn
SC-S04 unused-params Declared parameter placeholders ($N) not all used Warn
SC-S05 missing-returning DML with :one/:many command should have a RETURNING clause Warn
SC-S06 ambiguous-column-in-join SELECT with JOIN has unqualified column references Warn
SC-S07 unbound-sql-param SQL placeholder $N present in query body but absent from generated parameter signature Error

Codegen#

Code Name Description Default
SC-C01 missing-returns-annotation Query should have a @returns annotation Off
SC-C02 exec-with-returning :exec command but query has RETURNING clause Warn
SC-C03 duplicate-query-names Multiple queries share the same @name Error

Naming#

Code Name Description Default
SC-N01 prefer-snake-case-columns Column aliases should use snake_case Warn
SC-N02 prefer-snake-case-tables Table names should use snake_case Warn
SC-N03 query-name-convention Query name should start with an action verb Warn
SC-N04 consistent-alias-casing Table aliases should be lowercase Warn

Antipattern#

Code Name Description Default
SC-A01 not-equal-null Comparing with NULL using = or != always yields NULL Error
SC-A02 implicit-type-coercion Implicit type coercion may cause unexpected behavior Off
SC-A03 or-in-join-condition OR in JOIN ON condition usually prevents index usage Warn

Performance#

Code Name Description Default
SC-P01 order-without-limit ORDER BY without LIMIT may cause unnecessary sorting Warn
SC-P02 like-starts-with-wildcard LIKE pattern starting with % prevents index usage Warn
SC-P03 not-in-subquery NOT IN (SELECT …) has unexpected NULL behavior Warn

Style#

Code Name Description Default
SC-T01 prefer-explicit-join Implicit join — prefer explicit JOIN syntax Warn
SC-T02 prefer-coalesce-over-case CASE WHEN x IS NULL THEN y ELSE x END can be COALESCE(x, y) Warn
SC-T03 prefer-count-star COUNT(1) is equivalent to COUNT() — prefer COUNT() for clarity Warn

Configuration#

Override severity in scythe.toml per-rule or per-category — see Linting. Priority: per-rule override, then per-category override, then the rule's built-in default shown above.

Provenance rules (11, check-time only)#

SC-PRV* rules compare an already-generated artifact's provenance header against the current schema, queries, engine, backend, and scythe version.

Code Name Description Default
SC-PRV01 schema-drift Generated artifact was produced from a different schema Error
SC-PRV02 scythe-version-drift Generated artifact produced by a different scythe version Warn
SC-PRV03 backend-drift Generated artifact produced by a different backend Error
SC-PRV04 engine-drift Generated artifact produced for a different engine Error
SC-PRV05 missing-provenance-header Generated artifact has no provenance header Warn
SC-PRV06 malformed-provenance-header Provenance header missing required fields Warn
SC-PRV07 unverifiable-provenance Generation target could not be verified Warn
SC-PRV08 query-drift Generated artifact's query fingerprint differs Error
SC-PRV09 gen-target-invalid A [[sql.gen]] target could not be constructed Error
SC-PRV10 empty-query-file Query file produced zero query blocks Error
SC-PRV11 options-drift Generated artifact produced with different options Error

Schema drift rules (7, check-time only, PostgreSQL only)#

SC-DRF* rules compare the committed DDL against a live database's catalog, running from scythe check --database-url.

Code Name Description Default
SC-DRF01 table-missing-from-database Table declared in DDL does not exist in live database Error
SC-DRF02 table-missing-from-ddl Table exists in live database but not declared in DDL Warn
SC-DRF03 column-missing-from-database Column declared in DDL does not exist on live table Error
SC-DRF04 column-missing-from-ddl Column exists on live table but not declared in DDL Error
SC-DRF05 column-type-mismatch Column's DDL type does not match live database type Error
SC-DRF06 column-nullability-mismatch Column's DDL nullability does not match live database Error
SC-DRF07 enum-values-mismatch Enum type's DDL value set does not match live database Error

Sqruff rules#

Formatting and style rules integrated from sqruff carry an SQ- prefix followed by the sqruff rule code. Selected families: AL01-AL09 (aliasing), AM01-AM09 (ambiguity), CP01-CP05 (capitalization), CV01-CV12 (convention), JJ01 (Jinja), LT01-LT15 (layout), RF01-RF06 (reference), ST01-ST12 (structure). SQ-LT01 is excluded by default under both scythe lint and scythe fmt due to an upstream sqruff issue with compound operators.

  • Linting — how these rules are grouped, configured, and run.
  • Security Audit — the 35 SC-SEC/SC-RLS/SC-MIG/SC-CHK rules that share this same default registry.

Updated

Was this page helpful?