Skip to main content

Rules Overview

Rules are the core of Comply. Each rule defines a convention to enforce and how to evaluate it against a git diff.

Rule anatomy

Every rule in .comply.yml has this shape:

rules:
- name: rule-name
description: Human-readable description of what this checks
type: llm | regex | ast
# type-specific fields...
on_fail: warn | fail

Common fields

FieldRequiredDescription
nameYesUnique identifier, used in output
descriptionYesWhat the rule checks (shown in output)
typeYesllm, regex, or ast
on_failNowarn (default) or fail (exits 1)
depends_onNoSkip rule if another rule failed

Three rule types

llm — semantic checks

Uses an LLM to evaluate the diff against a natural-language prompt. Best for intent-based checks that are hard to express as patterns.

- name: meaningful-commit-scope
type: llm
prompt: "Does this diff represent a single, coherent concern? Answer YES or NO."
on_fail: warn

regex — pattern matching

Runs a regex against the diff text locally. No API calls, fast, deterministic.

- name: no-console-log
type: regex
pattern: 'console\.log\('
match: false
on_fail: fail

ast — Python static analysis

Parses Python files in the diff using the ast module and checks structural properties.

- name: no-bare-except
type: ast
check: bare_except
on_fail: warn

Rule evaluation order

Rules run in the order they appear in .comply.yml. If a rule has depends_on, it is skipped when the referenced rule has not passed.

Next steps