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.
context lintOptions
Section titled “Options”| Option | Description | Default |
|---|---|---|
--context-dir <path> | Path to context files | ./context |
--format <type> | Output format: pretty, json, sarif, github, junit | Auto-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 | — |
--fix | Automatically fix problems | Off |
--fix-dry-run | Show what --fix would change without writing | Off |
--cache | Only lint changed files (uses .contextkit-cache) | Off |
--no-cache | Bypass the lint cache | — |
Examples
Section titled “Examples”# Lint all context filescontext lint
# JSON output for CIcontext lint --format json
# Override a rule severitycontext lint --rule governance/grain-required:error
# Auto-fix issuescontext lint --fix
# Fail if more than 5 warningscontext lint --max-warnings 5
# Write results to a filecontext lint --format sarif --output-file results.sarifExample output
Section titled “Example output”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)context fixOptions
Section titled “Options”| Option | Description | Default |
|---|---|---|
--context-dir <path> | Path to context files | ./context |
--format <type> | Output format: pretty, json | pretty |
--dry-run | Show what would be fixed without writing files | Off |
--db <url> | Database URL for data-aware fixes (postgres:// or path.duckdb) | — |
--source <name> | Use a specific data_source from config | — |
Examples
Section titled “Examples”# Preview what would be fixedcontext fix --dry-run
# Apply fixescontext fix
# Apply fixes with database awarenesscontext fix --db postgres://localhost/myappExample output
Section titled “Example output”Dry run: 3 issue(s) would be fixed in 2 file(s): context/models/users.osi.yaml context/governance/orders.governance.yamlRule categories
Section titled “Rule categories”The 37 built-in rules cover:
| Category | Rules | Examples |
|---|---|---|
| Structure | 8 | missing-primary-key, missing-source, duplicate-column |
| Naming | 6 | naming-convention, reserved-word, model-name-match |
| Descriptions | 5 | missing-description, description-too-short |
| Relationships | 7 | invalid-relationship, orphan-foreign-key, circular-ref |
| Types | 5 | type-mismatch, missing-semantic-type, invalid-type |
| Formatting | 6 | trailing-whitespace, sort-columns, indent-style |
Run context rules to see the full list with descriptions.
CI integration
Section titled “CI integration”# GitHub Actions example- name: Lint context files run: context lint --format githubThe github format produces annotations that appear inline on pull requests.
Next steps
Section titled “Next steps”- Auto-fix issues with
context fix - Build the manifest with
context build