Skip to content

context lint & context fix

The lint command checks your context files for errors, inconsistencies, and missing metadata. The fix command auto-repairs violations that have deterministic fixes.

Terminal window
context lint
OptionDescriptionDefault
--context-dir <path>Path to context files./context
--format <type>Output format: pretty, json, sarif, github, junitAuto-detected
--rule <ruleId:severity>Override rule severity (repeatable), e.g. governance/grain-required:error
--max-warnings <count>Exit with error if warning count exceeds threshold
--output-file <path>Write formatted output to a file
--fixAutomatically fix problemsOff
--fix-dry-runShow what --fix would change without writingOff
--cacheOnly lint changed files (uses .contextkit-cache)Off
--no-cacheBypass the lint cache
Terminal window
# Lint all context files
context lint
# JSON output for CI
context lint --format json
# Override a rule severity
context lint --rule governance/grain-required:error
# Auto-fix issues
context lint --fix
# Fail if more than 5 warnings
context lint --max-warnings 5
# Write results to a file
context lint --format sarif --output-file results.sarif
context/models/users.osi.yaml
3:5 warn missing-description Column "id" has no description
7:5 warn missing-description Column "email" has no description
12:3 error invalid-relationship Relationship "orders" references non-existent model
context/governance/sessions.governance.yaml
1:1 error missing-primary-key No primary key defined
4 problems (2 errors, 2 warnings)
Terminal window
context fix
OptionDescriptionDefault
--context-dir <path>Path to context files./context
--format <type>Output format: pretty, jsonpretty
--dry-runShow what would be fixed without writing filesOff
--db <url>Database URL for data-aware fixes (postgres:// or path.duckdb)
--source <name>Use a specific data_source from config
Terminal window
# Preview what would be fixed
context fix --dry-run
# Apply fixes
context fix
# Apply fixes with database awareness
context fix --db postgres://localhost/myapp
Dry run: 3 issue(s) would be fixed in 2 file(s):
context/models/users.osi.yaml
context/governance/orders.governance.yaml

The 37 built-in rules cover:

CategoryRulesExamples
Structure8missing-primary-key, missing-source, duplicate-column
Naming6naming-convention, reserved-word, model-name-match
Descriptions5missing-description, description-too-short
Relationships7invalid-relationship, orphan-foreign-key, circular-ref
Types5type-mismatch, missing-semantic-type, invalid-type
Formatting6trailing-whitespace, sort-columns, indent-style

Run context rules to see the full list with descriptions.

Terminal window
# GitHub Actions example
- name: Lint context files
run: context lint --format github

The github format produces annotations that appear inline on pull requests.

  • Auto-fix issues with context fix
  • Build the manifest with context build