Documentation menu

How rules work

Changed lines only, the introduced-only filter, severities, file classes and the rule packs, and how to propose a new rule.

On this page
  1. Rules report on changed lines
  2. Only what the change introduced
  3. Severities
  4. Scopes
  5. File classes
  6. Packs
  7. Turning rules down
  8. Proposing a rule

Rules report on changed lines

A rule is a pure function of one changed file (or of the whole change, for a few change-level rules). It reads Git objects as data and never runs anything. CodeVeto runs every enabled rule that applies to a file's language and class, and keeps only findings on lines the change added or modified. A line inside a modified hunk counts as changed. A finding about removed code (a deleted test, a removed assertion) is anchored on the old side, or at the place the deletion happened. A file-level finding (a file added, deleted, renamed or made executable) may have no line.

The full catalogue, with every rule's rationale, hint and examples, is on the rules page. From the command line:

shell
codeveto rules                  # every rule: ID, severity, title
codeveto rules --pack python    # one pack
codeveto explain python/print-call

Only what the change introduced

Line rules also run on the old side of each hunk. A new-side finding is dropped when the same rule found the same evidence on the old side of that hunk, or anywhere in the file for moved code. So reformatting, renaming on a line and moving a block do not report debt that was already there. codeveto explain shows whether a rule uses this filter (Introduced-only filter: on).

Severities

Severity Means Blocks
error High confidence and high impact. An error rule must report nothing on CodeVeto's corpus of clean code. Yes, by default.
warning Likely a problem, or a policy change a person should look at. With fail_on = "warning" or --strict.
note Visibility only. Only with fail_on = "note".

A rule's catalogue severity is its maximum. A single hit may carry a lower severity for a weaker case: ci/curl-pipe-shell reports piping a literal https:// download into a shell as a warning, and an http:// or variable URL as an error. Configuration can lower a rule's severity, and the effective severity is the lower of the two, so a hit never exceeds what you configured.

Scopes

Scope Sees Example
line One file, findings on its changed lines security/sql-interpolation
file One file as a whole hygiene/large-file
change Every file of the change together tests/untested-change

File classes

Every changed file gets a language (python, javascript, typescript, go, rust, java, kotlin, shell, dockerfile, sql, yaml, json, jsonc, toml, markdown or text) and exactly one class, chosen in this order:

Class Detected by Rules it skips
agent-config AGENTS.md, CLAUDE.md, GEMINI.md, .github/copilot-instructions.md, .cursorrules, .cursor/rules/**, .windsurfrules, .clinerules, .mcp.json, .claude/**, .codex/**, .vscode/settings.json, .vscode/tasks.json, .devcontainer/** none
workflow .github/workflows/*.y*ml, .forgejo/workflows/*.y*ml, .gitea/workflows/*.y*ml, action.y*ml none
lockfile package-lock.json, yarn.lock, pnpm-lock.yaml, uv.lock, poetry.lock, Cargo.lock, go.sum, Gemfile.lock, composer.lock none
manifest package.json, pyproject.toml, requirements*.txt, Pipfile, Cargo.toml, go.mod, Gemfile, composer.json none
generated, vendored, minified vendor/, third_party/, node_modules/, dist/, *.min.js, *_pb2.py, *.pb.go, plus [classes] in trusted config hygiene and language bug-pattern rules
test test_*.py, *_test.py, conftest.py, tests/, test/, *_test.go, *.test.*, *.spec.*, __tests__/, src/test/ style and language bug-pattern rules that opt in
docs *.md, *.rst, *.txt, docs/ language bug-pattern rules
source code languages otherwise none
config YAML, JSON, JSONC and TOML otherwise none
text everything else none

The secrets, security, agent, ci and deps packs run on every text file whatever its class. In-file markers such as @generated or DO NOT EDIT, and .gitattributes, never change a class: adding such a marker raises hygiene/generated-file-edited, and every rule still runs. .vue and .svelte files take the language of their <script> block.

Packs

Pack Rules Covers
secrets 18 Credentials by provider format, private keys, credential files, .env files with real values, URL credentials, high-entropy assignments. Values are always redacted; known dummy values are downgraded to notes.
security 18 Injection and unsafe calls across languages: SQL, shell, eval, deserialization, TLS verification, archive extraction, XSS sinks, CSRF, cookies, JWT, CORS, debug mode, weak hashes, insecure randomness, permissions.
agent 15 Instructions aimed at AI reviewers, injection phrases, hidden Unicode, confusable identifiers, agent instruction and tool settings, auto-approval, CodeVeto config and gate changes, CODEOWNERS, .gitattributes, ignore rules, added suppressions.
ci 17 GitHub Actions and Forgejo workflows: untrusted checkout, script injection, unpinned actions and images, permissions, persisted credentials, inherited secrets, untrusted artifacts, curl | sh, secret echo, disabled checks.
deps 10 Install scripts, Git and URL dependencies, registry overrides, lockfile source changes, manifest and lockfile mismatch, submodules, unpinned versions, new dependencies.
tests 9 Focused and skipped tests, removed or tautological assertions, deleted tests, test-environment branches in source, lowered coverage thresholds, source changed without tests.
python, js, go, rust, shell, docker, sql 20, 11, 4, 7, 3, 4, 7 Language bug patterns.
config 6 JSON, JSONC, TOML and YAML syntax and duplicate keys.
hygiene 14 Conflict markers, NUL bytes in source, debug artifacts, large and binary files, symlinks, TODOs, blanket suppressions, weakened lint and type gates, generated and minified edits, the executable bit.

That is 163 rules in 15 packs in CodeVeto 0.1.0; codeveto rules prints the current count. Rule IDs (<pack>/<name>) are permanent.

Every rule but one is on by default: python/print-call is off until you list it in [rules] enable. Six rules that protect the review itself are non-waivable.

Turning rules down

  • Disable or downgrade a rule in [rules]: see Configuration.
  • Ignore rules for specific paths with [[ignore]].
  • Waive one finding with an inline ignore, when the person running the review allows them.

Each of these, made in a change, is reported to the reviewers of that change.

Proposing a rule

New rules are welcome when they are precise. Read the rule writing guide first. In short:

  • a rule lives in its pack's module and is found automatically;
  • it is a pure function: no I/O, no subprocesses, bounded regular expressions on single lines or bounded statements;
  • it ships at least two bad and two good examples, which the test suite runs;
  • an error rule must report nothing on the clean corpus and on every good example of every pack. When in doubt, ship a warning.

Open an issue or a pull request on GitHub with the rule's ID, what it catches, why it is high confidence, and its examples.