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
| Field | Required | Description |
|---|---|---|
name | Yes | Unique identifier, used in output |
description | Yes | What the rule checks (shown in output) |
type | Yes | llm, regex, or ast |
on_fail | No | warn (default) or fail (exits 1) |
depends_on | No | Skip 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
- LLM rules — full field reference and examples
- Regex rules — pattern syntax and examples
- AST rules — all four check values
- Rule chaining with depends_on