Open Knowledge Format (OKF) skill
OKF represents knowledge as a directory of markdown files with YAML frontmatter.
It is minimal by design: no schema registry, no runtime, no SDK. Your job is to
produce, maintain, and consume OKF bundles conformant with the spec, not your
memory of it.
Always read the canonical spec before non-trivial work:
reference/SPEC.md. It is the verbatim OKF v0.2 specification
and the source of truth for every rule below.
The one hard rule
A bundle is conformant (§11) iff: every non-reserved .md file has a parseable
YAML frontmatter block, and every such block has a non-empty type field.
Everything else is soft guidance. Consumers MUST tolerate missing optional
fields, unknown types, and broken links — never reject a bundle over them.
Conventions to apply
- One concept = one file. The file path (minus
.md) is the concept ID.
- Frontmatter:
type is required. Add title, description, tags when
they aid consumption; add resource (a canonical URI) only for concepts bound
to a real asset — omit it for abstract concepts.
- Body: prefer structural markdown (headings, tables, lists, fenced code).
Conventional headings:
# Schema, # Examples, # Computation.
- Cross-links: standard markdown links; prefer absolute bundle-relative
form (
/services/auth-api.md). A link asserts a relationship; its kind lives
in the surrounding prose, not the link.
- Reserved files:
index.md (directory listing, no frontmatter, except the
bundle-root index, which may carry okf_version and this plugin's
upkeep: enforced opt-in flag) and log.md (ISO-dated change history, newest
first). Never use these names for concepts.
The v0.2 families (all optional, all worth filling)
- Trust (§5.2):
generated: { by, at } — who produced the current content
and when. verified: [{ by, at }] — who confirmed it since (a bare mapping is
one entry). Write by in the actor convention (§7): <producer>/<version>
for an agent, human:<id> for a person, process:<id> for an automated job.
Use human: whenever a person authored or signed off — consumers key trust
tiers off that prefix.
- Lifecycle (§5.4–5.5):
status: draft|stable|deprecated (absent means
stable) and stale_after: YYYY-MM-DD, an absolute date, not a TTL.
- Provenance (§5.1):
sources: [{ id, resource, title, author, usage_count, last_modified }] plus a usage_window: { from, to } sibling of
sources framing every usage_count (an entry may carry its own to override
it); a usage_count without a window warns. resource is required per entry
and may be a URL, a bundle path, or a scope descriptor. Attribute a specific
claim with a markdown footnote whose label is the source's id:
…sharded daily.[^ga4-schema] plus a [^ga4-schema]: … definition. The label
is the join key, it must match a sources[].id.
- Attestation (§10): a sanctioned computation is its own concept,
type: Attested Computation, carrying runtime (required), parameters,
executor, attester, and the computation itself under # Computation (or a
computation: path). Concepts that need the value link to it. Never inline a
number's SQL into the concept that narrates it.
Reading a v0.1 bundle? Two constructs were superseded (§13.1): timestamp
is now generated.at, and a body # Citations list is now sources. Read both,
write v0.2 — and when you touch a legacy concept in maintain mode, migrate
its frontmatter as part of the edit. The validator warns on both.
Templates to copy: concept, index,
log.
Default bundle location
Use .okf/ at the repository root unless the project already uses another
location. Commit it alongside the code it describes — knowledge as code.
Modes
produce — create or extend a bundle
Starting a brand-new bundle? Use the init fast-path instead of hand-writing
the first files — it scaffolds a conformant index.md, log.md, and a
getting-started.md concept with full recommended frontmatter in one shot:
uv run "${CLAUDE_SKILL_DIR}/scripts/okf_init.py" <target-dir> [--title "..."]
It refuses to touch a directory that already has .md files unless --force
is given. Then extend it:
- Read reference/SPEC.md.
- Pick the source(s): code (derive concepts from source, READMEs,
docstrings, config), docs/wiki (distill pages into concepts, record the
originals in
sources), manual (decisions, playbooks, metrics).
- Choose a directory layout by domain (e.g.
services/, datasets/,
decisions/). One concept per file.
- Write each concept from templates/concept.md: set a
descriptive
type, fill recommended fields, record generated and the
sources you actually read, cross-link related concepts.
- Add/refresh
index.md per directory (and okf_version: "0.2" in the root
index). Append a dated entry to log.md.
- Validate (see below). Fix every error before finishing.
maintain — keep a bundle in sync with reality
- Identify which concepts the change affects (search by
resource, path, or
topic). This bookkeeping is exactly what agents are good at — touch every
affected file in one pass.
- Update the body and
generated.at (with your own actor in generated.by);
fix or add cross-links; create new concepts for new assets; mark removed
assets status: deprecated and note the deprecation in log.md rather than
silently deleting context. Facing a whole v0.1 bundle rather than a stray
field? Do not hand-edit it — run the validator's --migrate once.
- Update the relevant
index.md files and append a dated log.md entry
describing what changed.
- Validate.
consume — use a bundle as context
- Read the bundle-root
index.md first for progressive disclosure, then follow
links only into the concepts relevant to the task.
- Weigh what you read:
status: draft/deprecated, a stale_after already
past, or no verified entry all mean "check before relying on this". Treat
broken links as not-yet-written knowledge, not errors.
- Need a number an
Attested Computation covers? Run its computation with
values bound to the declared parameters — never write your own query.
- If you learn something durable while working, switch to maintain and
write it back.
Validation (do this before declaring done)
Never eyeball conformance — run the deterministic checker. Invoke the companion
validate skill (/okf:validate <bundle-dir> --strict), which ships the
checker. If that skill is not installed, run it directly:
uv run "${CLAUDE_SKILL_DIR}/../validate/scripts/okf_validate.py" <bundle-dir> --strict
Resolve every ERROR (hard §11 failures). Under --strict warnings also fail
the run (exit 1), so clear them too; drop --strict (or use --max-warnings N)
if you only want §11 conformance gated.
1---2name: okf3description: Author, maintain, and consume Open Knowledge Format (OKF) knowledge bundles — portable markdown + YAML frontmatter that both humans and agents read. Use when capturing project knowledge (services, APIs, schemas, metrics, runbooks, decisions) into an OKF bundle, when updating one after code or docs change, or when a repository contains an `.okf/` (or other OKF) bundle that should inform the task. Triggers on: "document this in OKF", "update the knowledge bundle", "capture this as a concept", or any work in a repo that has an OKF bundle.4---5
6# Open Knowledge Format (OKF) skill
7
8OKF represents knowledge as a directory of markdown files with YAML frontmatter.
9It is minimal by design: no schema registry, no runtime, no SDK. Your job is to
10produce, maintain, and consume OKF bundles **conformant with the spec**, not your
11memory of it.
12
13**Always read the canonical spec before non-trivial work:**
14[reference/SPEC.md](reference/SPEC.md). It is the verbatim OKF v0.2 specification
15and the source of truth for every rule below.
16
17## The one hard rule
18
19A bundle is conformant (§11) iff: every non-reserved `.md` file has a parseable
20YAML frontmatter block, and every such block has a **non-empty `type`** field.
21Everything else is soft guidance. Consumers MUST tolerate missing optional
22fields, unknown types, and broken links — never reject a bundle over them.
23
24## Conventions to apply
25
26- **One concept = one file.** The file path (minus `.md`) is the concept ID.
27- **Frontmatter:** `type` is required. Add `title`, `description`, `tags` when
28 they aid consumption; add `resource` (a canonical URI) only for concepts bound
29 to a real asset — omit it for abstract concepts.
30- **Body:** prefer structural markdown (headings, tables, lists, fenced code).
31 Conventional headings: `# Schema`, `# Examples`, `# Computation`.
32- **Cross-links:** standard markdown links; prefer absolute bundle-relative
33 form (`/services/auth-api.md`). A link asserts a relationship; its *kind* lives
34 in the surrounding prose, not the link.
35- **Reserved files:** `index.md` (directory listing, no frontmatter, except the
36 bundle-root index, which may carry `okf_version` and this plugin's
37 `upkeep: enforced` opt-in flag) and `log.md` (ISO-dated change history, newest
38 first). Never use these names for concepts.
39
40## The v0.2 families (all optional, all worth filling)
41
42- **Trust (§5.2):** `generated: { by, at }` — who produced the current content
43 and when. `verified: [{ by, at }]` — who confirmed it since (a bare mapping is
44 one entry). Write `by` in the **actor convention** (§7): `<producer>/<version>`
45 for an agent, `human:<id>` for a person, `process:<id>` for an automated job.
46 Use `human:` whenever a person authored or signed off — consumers key trust
47 tiers off that prefix.
48- **Lifecycle (§5.4–5.5):** `status: draft|stable|deprecated` (absent means
49 stable) and `stale_after: YYYY-MM-DD`, an absolute date, not a TTL.
50- **Provenance (§5.1):** `sources: [{ id, resource, title, author,
51 usage_count, last_modified }]` plus a `usage_window: { from, to }` sibling of
52 `sources` framing every `usage_count` (an entry may carry its own to override
53 it); a `usage_count` without a window warns. `resource` is required per entry
54 and may be a URL, a bundle path, or a scope descriptor. Attribute a specific
55 claim with a markdown footnote whose label is the source's `id`:
56 `…sharded daily.[^ga4-schema]` plus a `[^ga4-schema]: …` definition. The label
57 is the join key, it must match a `sources[].id`.
58- **Attestation (§10):** a sanctioned computation is its own concept,
59 `type: Attested Computation`, carrying `runtime` (required), `parameters`,
60 `executor`, `attester`, and the computation itself under `# Computation` (or a
61 `computation:` path). Concepts that need the value link to it. Never inline a
62 number's SQL into the concept that narrates it.
63
64**Reading a v0.1 bundle?** Two constructs were superseded (§13.1): `timestamp`
65is now `generated.at`, and a body `# Citations` list is now `sources`. Read both,
66write v0.2 — and when you touch a legacy concept in **maintain** mode, migrate
67its frontmatter as part of the edit. The validator warns on both.
68
69Templates to copy: [concept](templates/concept.md), [index](templates/index.md),
70[log](templates/log.md).
71
72## Default bundle location
73
74Use `.okf/` at the repository root unless the project already uses another
75location. Commit it alongside the code it describes — knowledge as code.
76
77## Modes
78
79### produce — create or extend a bundle
80
81**Starting a brand-new bundle?** Use the init fast-path instead of hand-writing
82the first files — it scaffolds a conformant `index.md`, `log.md`, and a
83`getting-started.md` concept with full recommended frontmatter in one shot:
84
85```bash
86uv run "${CLAUDE_SKILL_DIR}/scripts/okf_init.py" <target-dir> [--title "..."]
87```
88
89It refuses to touch a directory that already has `.md` files unless `--force`
90is given. Then extend it:
91
921. Read [reference/SPEC.md](reference/SPEC.md).
932. Pick the source(s): **code** (derive concepts from source, READMEs,
94 docstrings, config), **docs/wiki** (distill pages into concepts, record the
95 originals in `sources`), **manual** (decisions, playbooks, metrics).
963. Choose a directory layout by domain (e.g. `services/`, `datasets/`,
97 `decisions/`). One concept per file.
984. Write each concept from [templates/concept.md](templates/concept.md): set a
99 descriptive `type`, fill recommended fields, record `generated` and the
100 `sources` you actually read, cross-link related concepts.
1015. Add/refresh `index.md` per directory (and `okf_version: "0.2"` in the root
102 index). Append a dated entry to `log.md`.
1036. Validate (see below). Fix every error before finishing.
104
105### maintain — keep a bundle in sync with reality
1061. Identify which concepts the change affects (search by `resource`, path, or
107 topic). This bookkeeping is exactly what agents are good at — touch every
108 affected file in one pass.
1092. Update the body and `generated.at` (with your own actor in `generated.by`);
110 fix or add cross-links; create new concepts for new assets; mark removed
111 assets `status: deprecated` and note the deprecation in `log.md` rather than
112 silently deleting context. Facing a whole v0.1 bundle rather than a stray
113 field? Do not hand-edit it — run the validator's `--migrate` once.
1143. Update the relevant `index.md` files and append a dated `log.md` entry
115 describing what changed.
1164. Validate.
117
118### consume — use a bundle as context
1191. Read the bundle-root `index.md` first for progressive disclosure, then follow
120 links only into the concepts relevant to the task.
1212. Weigh what you read: `status: draft`/`deprecated`, a `stale_after` already
122 past, or no `verified` entry all mean "check before relying on this". Treat
123 broken links as not-yet-written knowledge, not errors.
1243. Need a number an `Attested Computation` covers? Run *its* computation with
125 values bound to the declared `parameters` — never write your own query.
1264. If you learn something durable while working, switch to **maintain** and
127 write it back.
128
129## Validation (do this before declaring done)
130
131Never eyeball conformance — run the deterministic checker. Invoke the companion
132**`validate`** skill (`/okf:validate <bundle-dir> --strict`), which ships the
133checker. If that skill is not installed, run it directly:
134
135```bash
136uv run "${CLAUDE_SKILL_DIR}/../validate/scripts/okf_validate.py" <bundle-dir> --strict
137```
138
139Resolve every `ERROR` (hard §11 failures). Under `--strict` warnings also fail
140the run (exit 1), so clear them too; drop `--strict` (or use `--max-warnings N`)
141if you only want §11 conformance gated.