Skip to content

contextia check

contextia check validates the structural integrity of your .contextia/ directory. It detects broken references, orphan artifacts, malformed frontmatter, and other inconsistencies. Designed for both interactive use and CI/CD pipelines.

contextia check [OPTIONS]
OptionShortDescription
--ciCI mode: exit with code 1 if any errors are found
--baseline <path>Compare against a baseline file; only report new issues
--rule <name>Run only specific rules (repeatable)
--format <fmt>-fOutput format: human, json, context
--json-jShorthand for --format json
--help-hShow help and exit

The following rules are checked. Each rule has a configurable severity in config.yaml:

RuleDefault severityDescription
orphan-specwarningSpec not referenced by any task or code annotation
broken-referrorArtifact references a non-existent ID
broken-linkerrorSpec links field contains a non-existent ID
broken-pathwarningSpec paths field contains a glob matching no files
malformed-frontmattererrorYAML frontmatter fails schema validation
missing-required-fielderrorRequired frontmatter field is absent
oversized-identitywarningidentity.md exceeds recommended token count
duplicate-iderrorTwo or more artifacts share the same ID
stale-taskinfoTask in active status with no session log for 7+ days
empty-scopewarningNorm has no scope pattern defined

Override default severities in config.yaml:

check:
rules:
orphan-spec: error # promote to error for CI
broken-path: info # demote to informational
oversized-identity: error # enforce identity size limits
identity_max_tokens: 800 # threshold for oversized-identity

Run all checks:

Terminal window
$ contextia check
12 artifacts scanned
ERRORS (2):
broken-ref TASK-007 references SPEC-AUTH-999 (not found)
malformed-fm .contextia/system/specs/SPEC-DB-003.md: missing required field "status"
WARNINGS (1):
orphan-spec SPEC-OLD-001 is not referenced by any task or annotation
2 errors, 1 warning, 0 info

CI mode for pipelines:

Terminal window
$ contextia check --ci
ERRORS (2):
broken-ref TASK-007 references SPEC-AUTH-999 (not found)
malformed-fm SPEC-DB-003.md: missing required field "status"
2 errors found. Exiting with code 1.
$ echo $?
1

Run specific rules only:

Terminal window
$ contextia check --rule broken-ref --rule broken-link
12 artifacts scanned (2 rules active)
ERRORS (1):
broken-ref TASK-007 references SPEC-AUTH-999 (not found)
1 error

Baseline comparison (show only new issues):

Terminal window
# Save a baseline
$ contextia check --json > .contextia/.cache/check-baseline.json
# Later, compare against it
$ contextia check --baseline .contextia/.cache/check-baseline.json
14 artifacts scanned
NEW ISSUES (1):
broken-ref TASK-013 references DEC-099 (not found)
1 new error (2 baseline issues suppressed)

JSON output:

Terminal window
$ contextia check --json
{
"scanned": 12,
"issues": [
{
"rule": "broken-ref",
"severity": "error",
"artifact": "TASK-007",
"message": "references SPEC-AUTH-999 (not found)",
"file": ".contextia/work/tasks/TASK-007.md"
},
{
"rule": "orphan-spec",
"severity": "warning",
"artifact": "SPEC-OLD-001",
"message": "not referenced by any task or annotation",
"file": ".contextia/system/specs/SPEC-OLD-001.md"
}
],
"summary": { "errors": 1, "warnings": 1, "info": 0 }
}

Add to your GitHub Actions workflow:

- name: Check context integrity
run: uvx contextia check --ci

Or in a pre-commit hook:

#!/bin/sh
uvx contextia check --ci --rule broken-ref --rule malformed-frontmatter
  • Without --ci, the command always exits with code 0, regardless of findings.
  • With --ci, the command exits with code 1 if any issues at error severity are found.
  • The --baseline option compares issues by rule + artifact + message. Resolved baseline issues are not reported.
  • Running with no .contextia/ directory prints a suggestion to run contextia init and exits with code 2.