CLI · judge
okf validate
The hard gate: is this a legal OKF bundle?
When to use it
- Before you trust a directory as a bundle: after cloning, after a big edit, before a PR merges.
- In CI, as the conformance gate. It exits
1on a non-conformant bundle,0otherwise. - As the first half of the quality question.
validateanswers "is it legal?";okf lintanswers "is it well curated?". The conformance model explains why those stay separate.
How it works
validate implements the spec's section 9 conformance definition exactly. Three conditions are hard errors, and the bundle is non-conformant until every one is fixed:
- 9.1: every non-reserved file has a parseable YAML frontmatter block;
- 9.2: every such block has a non-empty
type; - 9.3: any
index.md/log.mdpresent follows the reserved-file rules: a nestedindex.mdhas no frontmatter, a rootindex.mdcarries onlyokf_version, andlog.mddate headings are ISOYYYY-MM-DD.
Everything the spec marks as soft guidance is a warning and never fails the bundle: missing recommended fields, non-list tags, an unparseable timestamp, and broken cross-links, which section 5.3 explicitly tells consumers to tolerate. Fix warnings when it is cheap. Never block on them.
Try it
okf validate docs/
OKF v0.1 conformance — docs
concepts: 37 index.md: 10 log.md: 1
! warn features/link-suggestions.md: cross-link target not found: `/graph-view.md` (tolerated under §5.3)
✓ conformant (33 warning(s))
For CI or an agent, --json emits the same result as compact single-line JSON:
okf validate docs/ --json
Pitfalls
- Do not expect broken links to fail validation. They are warnings by design; the spec forbids a validator from rejecting them. If dead links should block your pipeline, gate on
okf lint --fail-on warninstead. - A directory with zero frontmatter files is not "invalid", it is empty. Start with one concept file and validate again.
- Reserved files play by different rules. If validation fails on an
index.md, the fix is usually removing frontmatter from a nested index or trimming a root index down tookf_version. The bundle anatomy page shows both shapes.