okf-open-knowledge-format

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Open Knowledge Format (OKF)

Open Knowledge Format (OKF)

OKF is a vendor-neutral, open spec (v0.1, announced June 12, 2026 by Sam McVeety & Amir Hormati at Google Cloud) for representing knowledge as a directory of markdown files with YAML frontmatter. No SDK required — if you can
cat
a file, you can read OKF.
It formalizes the "LLM Wiki" pattern (Karpathy's gist) into an interoperable format: wikis written by different producers can be consumed by different agents without translation.
For the full spec, see references/spec-v01.md.
OKF是一种厂商中立的开放规范(v0.1版本,由Sam McVeety和Amir Hormati于2026年6月12日在Google Cloud发布),用于将知识表示为带有YAML前置元数据的Markdown文件目录。无需SDK——只要你能使用
cat
命令读取文件,就能读取OKF格式的内容。
它将“LLM Wiki”模式(Karpathy的gist)正式化为一种可互操作的格式:不同生产者编写的wiki可被不同Agent直接使用,无需转换。
完整规范请参阅references/spec-v01.md

Design Principles

设计原则

  1. Minimally opinionated — Only
    type
    is required. The spec defines interoperability surface, not content model.
  2. Producer/consumer independence — Who writes and who reads are decoupled. Human-authored bundles feed agents; LLM-generated bundles are browsed by humans.
  3. Format, not platform — No cloud, SDK, or vendor dependency. Value comes from how many parties speak it.

  1. 最低限度约束——仅
    type
    字段为必填项。该规范定义的是互操作层面,而非内容模型。
  2. 生产者/消费者解耦——编写者和读取者相互独立。人工编写的bundle可供给Agent使用;LLM生成的bundle可供人类浏览。
  3. 仅定义格式,不绑定平台——无需依赖云服务、SDK或特定厂商。其价值在于有多少参与者采用该格式。

Key Terminology

关键术语

  • Bundle — A directory tree of
    .md
    files. The unit of distribution (git repo, tarball, or subdirectory).
  • Concept — One markdown file = one unit of knowledge (table, metric, playbook, API, etc.)
  • Concept ID — File path within the bundle, minus
    .md
    suffix. Example:
    tables/users.md
    → ID
    tables/users
  • Frontmatter — YAML block between
    ---
    delimiters at file top.
  • Body — Everything after the frontmatter. Standard markdown.
  • Link — Standard markdown link expressing a relationship between concepts.
  • Citation — Link to an external source backing a claim in the body.

  • Bundle——包含
    .md
    文件的目录树。是分发的基本单元(Git仓库、压缩包或子目录)。
  • Concept——一个Markdown文件对应一个知识单元(表格、指标、操作手册、API等)。
  • Concept ID——bundle内的文件路径,去除
    .md
    后缀。示例:
    tables/users.md
    → ID为
    tables/users
  • Frontmatter——文件顶部位于
    ---
    分隔符之间的YAML块。
  • Body——前置元数据之后的所有内容,为标准Markdown格式。
  • Link——表示Concept之间关联关系的标准Markdown链接。
  • Citation——指向正文内容中论点的外部来源的链接。

Quick Reference — Frontmatter Fields

快速参考——前置元数据字段

FieldRequired?Description
type
YESKind of concept (free-form string, e.g.
BigQuery Table
,
Metric
,
Playbook
,
API Endpoint
)
title
RecommendedHuman-readable display name
description
RecommendedOne-sentence summary
resource
RecommendedURI identifying the underlying asset (omit for abstract concepts)
tags
OptionalYAML list for cross-cutting categorization
timestamp
OptionalISO 8601 datetime of last meaningful change
Additional producer-defined keys are allowed. Never reject unknown fields.
字段是否必填?描述
type
Concept的类型(自由格式字符串,例如
BigQuery Table
Metric
Playbook
API Endpoint
title
推荐便于人类阅读的显示名称
description
推荐一句话摘要
resource
推荐标识底层资产的URI(抽象Concept可省略)
tags
可选用于跨领域分类的YAML列表
timestamp
可选最后一次重要变更的ISO 8601格式时间戳
允许添加生产者自定义的字段,不得拒绝未知字段。

Reserved Filenames

保留文件名

FilePurposeHas frontmatter?
index.md
Directory listing for progressive disclosureNO*
log.md
Change history, newest firstNO
*Exception: bundle-root
index.md
MAY have frontmatter with
okf_version: "0.1"
to declare spec version.
文件用途是否包含前置元数据?
index.md
用于渐进式展示的目录列表否*
log.md
变更历史,按最新优先排序
*例外:bundle根目录下的
index.md
可包含前置元数据,其中
okf_version: "0.1"
用于声明规范版本。

Conventional Body Headings

常规正文标题

HeadingWhen to use
# Schema
Data assets — describe columns/fields
# Examples
Show concrete usage (code blocks, queries)
# Citations
List external sources backing claims (numbered)

标题使用场景
# Schema
数据资产——描述列/字段
# Examples
展示具体用法(代码块、查询语句等)
# Citations
列出支撑论点的外部来源(编号形式)

Create a Bundle

创建Bundle

When the user wants to create an OKF bundle from scratch:
当用户想要从零开始创建OKF bundle时:

1. Determine scope and structure

1. 确定范围与结构

Ask: What knowledge are we capturing? (tables, metrics, APIs, playbooks, etc.) Organize into a directory tree that makes sense for the domain.
询问:我们要捕获哪些知识?(表格、指标、API、操作手册等) 按照领域逻辑组织为目录树结构。

2. Create concept documents

2. 创建Concept文档

Each concept = one
.md
file. Minimal conformant example:
markdown
---
type: Metric
title: Monthly Recurring Revenue
description: Sum of all active subscription revenue normalized to monthly.
tags: [revenue, saas]
timestamp: 2026-06-13T10:00:00Z
---
每个Concept对应一个
.md
文件。符合规范的最简示例:
markdown
---
type: Metric
title: Monthly Recurring Revenue
description: Sum of all active subscription revenue normalized to monthly.
tags: [revenue, saas]
timestamp: 2026-06-13T10:00:00Z
---

Monthly Recurring Revenue (MRR)

Monthly Recurring Revenue (MRR)

Definition

Definition

Sum of all active subscriptions normalized to a monthly amount. Excludes one-time fees and overages.
Sum of all active subscriptions normalized to a monthly amount. Excludes one-time fees and overages.

Formula

Formula

MRR = Σ(active_subscription_monthly_value)
MRR = Σ(active_subscription_monthly_value)

Related

Related

  • Churn Rate uses MRR as denominator
  • ARR = MRR × 12

For more examples across domains, see [references/examples.md](references/examples.md).
  • Churn Rate uses MRR as denominator
  • ARR = MRR × 12

更多跨领域示例请参阅[references/examples.md](references/examples.md)。

3. Cross-link concepts

3. 交叉链接Concept

Use standard markdown links. Two forms:
  • Absolute (bundle-relative, starts with
    /
    ):
    [customers](/tables/customers.md)
    preferred (stable when files move)
  • Relative:
    [churn](./churn.md)
Links assert relationships. The kind of relationship is conveyed by surrounding prose, not by the link syntax. Broken links are explicitly permitted — they represent knowledge not yet written.
使用标准Markdown链接,有两种形式:
  • 绝对路径(相对于bundle,以
    /
    开头):
    [customers](/tables/customers.md)
    —— 推荐(文件移动时仍保持稳定)
  • 相对路径
    [churn](./churn.md)
链接用于声明关联关系,关联类型由周围的文本表述,而非链接语法。明确允许存在断链——断链代表尚未编写的知识。

4. Generate index.md

4. 生成index.md

Place in any directory for progressive disclosure. No frontmatter. Format:
markdown
undefined
可在任意目录下创建,用于渐进式展示,无需前置元数据。格式如下:
markdown
undefined

Metrics

Metrics

  • MRR - Monthly recurring revenue
  • Churn - Monthly churn rate
  • NPS - Net Promoter Score

Entries should include the description from the linked concept's frontmatter.
  • MRR - Monthly recurring revenue
  • Churn - Monthly churn rate
  • NPS - Net Promoter Score

条目应包含链接Concept的前置元数据中的描述信息。

5. Generate log.md (optional)

5. 生成log.md(可选)

Chronological change history, newest first, ISO 8601 date headings:
markdown
undefined
按时间顺序排列的变更历史,最新优先,使用ISO 8601格式日期作为标题:
markdown
undefined

Update Log

Update Log

2026-06-13

2026-06-13

  • Creation: Added MRR, Churn, and NPS metrics.
  • Creation: Established directory structure.
  • Creation: Added MRR, Churn, and NPS metrics.
  • Creation: Established directory structure.

2026-06-10

2026-06-10

  • Initialization: Bundle created.

The bold leading word (`**Update**`, `**Creation**`, `**Deprecation**`) is convention, not requirement.
  • Initialization: Bundle created.

开头的加粗词汇(`**Update**`、`**Creation**`、`**Deprecation**`)是惯例,而非强制要求。

6. Declare version (optional)

6. 声明版本(可选)

Bundle-root
index.md
may include frontmatter declaring the spec version:
markdown
---
okf_version: "0.1"
---
Bundle根目录下的
index.md
可包含前置元数据以声明规范版本:
markdown
---
okf_version: "0.1"
---

My Knowledge Bundle

My Knowledge Bundle

  • Tables - Database tables
  • Metrics - Business KPIs

This is the only place frontmatter is permitted in an `index.md`.
  • Tables - Database tables
  • Metrics - Business KPIs

这是`index.md`中唯一允许包含前置元数据的场景。

7. Distribution

7. 分发

A bundle can be distributed as:
  • A git repository (recommended — history, attribution, diffs)
  • A tarball or zip archive
  • A subdirectory within a larger repository
Bundle可通过以下方式分发:
  • Git仓库(推荐——包含历史记录、归属信息、差异对比)
  • Tarball或Zip压缩包
  • 大型仓库中的子目录

8. Verify conformance

8. 验证合规性

Three rules — all must pass:
  1. Every non-reserved
    .md
    file has parseable YAML frontmatter
  2. Every frontmatter has a non-empty
    type
    field
  3. Reserved files (
    index.md
    ,
    log.md
    ) follow their defined structure when present

需满足三条规则,全部通过才算合规:
  1. 所有非保留
    .md
    文件均包含可解析的YAML前置元数据
  2. 所有前置元数据均包含非空的
    type
    字段
  3. 保留文件(
    index.md
    log.md
    )在存在时需遵循其定义的结构

Validate a Bundle

验证Bundle

Preferred: okflint (when available)

首选方案:okflint(若可用)

okflint is a dedicated Python linter for OKF bundles with 18 rules across 3 tiers (OKF core, profile, hygiene). If installed, always prefer it over the built-in bash script.
Agent behavior: Before validating, check if okflint is installed (
command -v okflint
). If NOT installed, ask the user:
"okflint (linter dedicado para OKF com 18 regras, profiles via manifesto e suporte a wikilinks) não está instalado. Quer que eu instale? Opções:
  1. uv tool install okflint
    (recomendado, isolado)
  2. pip install okflint
  3. Seguir sem ele (validação básica com o script bash embutido)"
If the user agrees to install:
bash
undefined
okflint是一款专门用于OKF bundle的Python检查工具,包含3个层级(OKF核心、配置文件、卫生检查)的18条规则。若已安装,优先使用它而非内置的bash脚本。
Agent行为:验证前,检查okflint是否已安装(执行
command -v okflint
)。若未安装,询问用户:
"okflint(专为OKF设计的检查工具,包含18条规则、通过清单实现配置文件支持、支持维基链接)未安装。是否需要安装?选项:
  1. uv tool install okflint
    (推荐,隔离环境安装)
  2. pip install okflint
  3. 不安装,使用内置bash脚本进行基础验证"
若用户同意安装:
bash
undefined

Option 1: uv (recommended — installs isolated, no venv needed)

选项1:uv(推荐——隔离安装,无需虚拟环境)

uv tool install okflint
uv tool install okflint

Option 2: pip (installs in current environment)

选项2:pip(安装到当前环境)

pip install okflint
pip install okflint

Verify installation

验证安装

okflint --version

After installation (or if already available):

```bash
okflint --version

安装完成后(或已安装时):

```bash

Full validation with manifest (if okf-base.yaml exists)

若存在okf-base.yaml,使用清单进行完整验证

if [ -f okf-base.yaml ]; then okflint validate --manifest okf-base.yaml ./bundle/ else

Core OKF validation only (no manifest needed)

okflint validate ./bundle/ fi

**okflint advantages over the built-in script:**
- Manifest-driven profiles (enforce custom required fields, status vocabularies, per-type constraints)
- Wikilink resolution against full Obsidian vault
- JSON output (`--json`) for CI pipeline parsing
- Detects broken markdown links and ambiguous wikilinks
- Exit codes: `0` = pass, `1` = conformance failure, `2` = bad manifest
if [ -f okf-base.yaml ]; then okflint validate --manifest okf-base.yaml ./bundle/ else

仅进行OKF核心验证(无需清单)

okflint validate ./bundle/ fi

**okflint相较于内置脚本的优势**:
- 基于清单的配置文件(强制自定义必填字段、状态词汇、按类型约束)
- 针对完整Obsidian库解析维基链接
- 支持JSON输出(`--json`),便于CI流水线解析
- 检测无效Markdown链接和模糊维基链接
- 退出码:`0`=通过,`1`=合规失败,`2`=清单错误

Fallback: built-in bash script

备选方案:内置bash脚本

When okflint is not installed, use scripts/validate.sh which checks the 3 core conformance rules.
When asked to validate, check the 3 conformance rules. Report:
✅ PASS: 12/12 concept files have valid frontmatter with type field
✅ PASS: index.md follows list structure (no frontmatter)
✅ PASS: log.md uses ISO 8601 date headings, newest first

⚠  WARNING: 3 files missing 'description' field (recommended)
⚠  WARNING: 2 broken cross-links (permitted but worth noting)
For a script-based check, see scripts/validate.sh.
当okflint未安装时,使用scripts/validate.sh检查3条核心合规规则。
验证时,检查这3条规则,并输出如下报告:
✅ 通过:12/12个Concept文件均包含带type字段的有效前置元数据
✅ 通过:index.md符合列表结构(无前置元数据)
✅ 通过:log.md使用ISO 8601格式日期标题,按最新优先排序

⚠ 警告:3个文件缺少'description'字段(推荐添加)
⚠ 警告:2个无效交叉链接(允许存在,但值得注意)
基于脚本的检查请参阅scripts/validate.sh

Errors (conformance failures)

错误(合规失败)

  • E1
    : File
    {path}
    has no YAML frontmatter
  • E2
    : File
    {path}
    has frontmatter but no
    type
    field (or empty)
  • E3
    : Reserved file
    {path}
    has unexpected structure
  • E1
    :文件
    {path}
    无YAML前置元数据
  • E2
    :文件
    {path}
    有前置元数据但无
    type
    字段(或为空)
  • E3
    :保留文件
    {path}
    结构不符合预期

Warnings (non-blocking, spec allows these)

警告(非阻塞,规范允许)

  • W1
    : Missing recommended field
    title
    or
    description
  • W2
    : Broken cross-link
    {link}
    in
    {file}
  • W3
    : No
    timestamp
    field
  • W4
    : No
    index.md
    in directory
    {dir}
  • W5
    :
    log.md
    dates not in ISO 8601 format
Consumers MUST NOT reject a bundle because of: missing optional fields, unknown type values, unknown frontmatter keys, broken links, or missing index files.

  • W1
    :缺少推荐字段
    title
    description
  • W2
    :文件
    {file}
    中存在无效链接
    {link}
  • W3
    :无
    timestamp
    字段
  • W4
    :目录
    {dir}
    中无
    index.md
  • W5
    log.md
    中的日期非ISO 8601格式
消费者不得因以下原因拒绝bundle:缺少可选字段、未知type值、未知前置元数据字段、断链或缺少index文件。

Enrich Concepts

增强Concept

When the user has existing OKF concepts that need enrichment:
当用户已有OKF Concept需要增强时:

Add schema section

添加Schema章节

For data assets, add
# Schema
with a columns table:
markdown
undefined
对于数据资产,添加
# Schema
章节并包含列信息表格:
markdown
undefined

Schema

Schema

ColumnTypeDescription
order_id
STRINGUnique identifier
customer_id
STRINGFK to customers
undefined
ColumnTypeDescription
order_id
STRINGUnique identifier
customer_id
STRINGFK to customers
undefined

Add examples section

添加Examples章节

For APIs, queries, or tools, add
# Examples
with fenced code blocks showing usage.
对于API、查询语句或工具,添加
# Examples
章节并包含代码块展示用法。

Add citations

添加Citations

When claims reference external sources, add
# Citations
at the bottom, numbered:
markdown
undefined
当论点引用外部来源时,在底部添加
# Citations
章节,采用编号形式:
markdown
undefined

Citations

Citations


Citations may be absolute URLs, bundle-relative paths, or paths into a `references/` subdirectory.

引用可以是绝对URL、相对于bundle的路径,或指向`references/`子目录的路径。

Add cross-links

添加交叉链接

Weave links into natural prose. Don't create a standalone "links" section — express relationships in context where they're meaningful.
将链接融入自然文本中,不要创建独立的“链接”章节——在有意义的上下文环境中表述关联关系。

Fill recommended fields

补充推荐字段

If
title
,
description
,
tags
, or
timestamp
are missing, add them. Derive values from body content when possible.
若缺少
title
description
tags
timestamp
字段,补充这些信息。尽可能从正文内容中推导值。

Enrichment workflow reference

增强流程参考

The official enrichment agent follows this pattern — apply the same logic manually:
  1. Start with metadata-only docs (just frontmatter + minimal body)
  2. Add schema/structure from source system
  3. Add citations from authoritative documentation
  4. Weave cross-links based on discovered relationships (FKs, shared tags, join paths)
  5. Generate
    index.md
    files for progressive disclosure

官方增强Agent遵循以下模式——手动操作时可应用相同逻辑:
  1. 从仅含元数据的文档开始(仅前置元数据+极简正文)
  2. 从源系统添加Schema/结构信息
  3. 从权威文档添加引用
  4. 根据发现的关联关系(外键、共享标签、关联路径)添加交叉链接
  5. 生成用于渐进式展示的
    index.md
    文件

Convert Sources to OKF

转换为OKF格式

For detailed conversion guides, see references/conversion.md.
详细转换指南请参阅references/conversion.md

Quick rules

快速规则

Notion export: Properties → frontmatter. Remove UUID suffixes from filenames. Convert Notion links → relative markdown links.
Obsidian vault: Convert
[[wikilinks]]
[title](./file.md)
. Ensure
type
field exists. Move inline
#tags
to frontmatter.
CSV/spreadsheet: Each row = one concept. Map columns to frontmatter fields. First column = filename.

Notion导出:属性→前置元数据。移除文件名中的UUID后缀。将Notion链接转换为相对Markdown链接。
Obsidian库:将
[[wikilinks]]
转换为
[title](./file.md)
。确保存在
type
字段。将行内
#tags
移至前置元数据中。
CSV/电子表格:每行对应一个Concept。将列映射到前置元数据字段。第一列为文件名。

Guardrails

约束规则

  1. NEVER invent data. If you don't know the correct
    type
    , ask. If you don't have schema info, leave it out. No fabricated URLs or column names.
  2. Preserve unknown fields. OKF explicitly allows extension. Don't delete fields you don't recognize.
  3. Don't impose taxonomy. Type values are free-form strings. Suggest descriptive values but never reject a bundle for having unexpected types.
  4. Broken links are OK. The spec explicitly permits them — they represent not-yet-written knowledge.
  5. Minimal by default. Generate only
    type
    (required) + recommended fields that are warranted. Don't pad with empty values.
  6. Ask before assuming. If the domain is unclear, ask what types and structure make sense.

  1. 绝不编造数据。若不知道正确的
    type
    值,询问用户。若无Schema信息,留空。不得伪造URL或列名。
  2. 保留未知字段。OKF明确允许扩展,不得删除无法识别的字段。
  3. 不强制分类体系。Type值为自由格式字符串。可建议描述性值,但不得因type值不符合预期而拒绝bundle。
  4. 断链是允许的。规范明确允许断链——断链代表尚未编写的知识。
  5. 默认保持极简。仅生成必填的
    type
    字段+有必要的推荐字段。不得填充空值。
  6. 先询问再假设。若领域不明确,询问用户哪种类型和结构更合理。

Serve via Google Cloud Knowledge Catalog

通过Google Cloud Knowledge Catalog提供服务

Google Cloud's Knowledge Catalog natively ingests OKF bundles and serves them to agents. This is the enterprise path — optional but powerful.
Google Cloud的Knowledge Catalog原生支持导入OKF bundle,并为Agent提供服务。这是企业级方案——可选但功能强大。

kcmd CLI (Metadata as Code)

kcmd CLI(元数据即代码)

kcmd
is a bidirectional sync tool between OKF-like local metadata and Knowledge Catalog. Think "git for metadata."
bash
undefined
kcmd
是一款双向同步工具,用于在类OKF的本地元数据与Knowledge Catalog之间同步。相当于“元数据的Git”。
bash
undefined

Initialize from BigQuery dataset

从BigQuery数据集初始化

kcmd init --bigquery-dataset <project>.<dataset>
kcmd init --bigquery-dataset <project>.<dataset>

Pull current state from catalog

从Catalog拉取当前状态

kcmd pull
kcmd pull

Push local changes

推送本地变更

kcmd push --dry-run kcmd push

Also ships as an **MCP server** for agent integration:

```json
{
  "mcpServers": {
    "kc-mac": {
      "command": "kcmd",
      "args": ["mcp", "--path", "/path/to/root"]
    }
  }
}
MCP tools:
pull
,
push
,
list-entries
,
lookup-entry
,
modify-entry
.
kcmd push --dry-run kcmd push

它还可作为**MCP服务器**供Agent集成:

```json
{
  "mcpServers": {
    "kc-mac": {
      "command": "kcmd",
      "args": ["mcp", "--path", "/path/to/root"]
    }
  }
}
MCP工具命令:
pull
push
list-entries
lookup-entry
modify-entry

Reference Enrichment Agent

参考增强Agent

The official enrichment agent (Python, ADK, Gemini) auto-generates OKF bundles from BigQuery metadata. Two-pass architecture:
  1. BQ pass — one OKF doc per table/view from metadata
  2. Web pass — LLM crawls seed URLs and for each page decides to:
    • (a) Enrich existing concepts with citations/schemas
    • (b) Mint a new
      references/<slug>
      doc
    • (c) Skip irrelevant content
Controls:
--web-seed-file
,
--web-max-pages
,
--web-allowed-host
,
--no-web
.
When to mention this to users: If they're enriching BigQuery datasets, point them to the reference agent. If they want enterprise catalog integration, point to kcmd and the ingest demo.

官方增强Agent(Python、ADK、Gemini)可从BigQuery元数据自动生成OKF bundle。采用两阶段架构:
  1. BQ阶段——从元数据为每个表/视图生成一个OKF文档
  2. Web阶段——LLM爬取种子URL,对每个页面决定:
    • (a) 增强:为现有Concept添加引用/Schema
    • (b) 新建:创建一个新的
      references/<slug>
      文档
    • (c) 跳过:忽略无关内容
控制参数:
--web-seed-file
--web-max-pages
--web-allowed-host
--no-web
何时向用户提及此内容:若用户正在增强BigQuery数据集,可指向参考Agent。若用户需要企业级目录集成,可指向kcmd导入演示

Output Format

输出格式

When creating a bundle, present results as:
  1. Directory tree showing the full structure
  2. Each file's content in fenced code blocks
  3. Conformance check confirming the bundle passes the 3 rules
saas-metrics/
├── index.md
├── log.md
├── mrr.md
├── churn.md
└── nps.md
Then show each file, then confirm: "Bundle is OKF v0.1 conformant ✅"
创建bundle时,结果呈现方式如下:
  1. 目录树展示完整结构
  2. 每个文件的内容放在代码块中
  3. 合规性检查确认bundle通过3条规则
saas-metrics/
├── index.md
├── log.md
├── mrr.md
├── churn.md
└── nps.md
然后展示每个文件内容,最后确认:"Bundle符合OKF v0.1规范 ✅"