okf-generate
GitHub用于创建、更新或验证 Open Knowledge Format (OKF) v0.3 知识库包,支持文档生成、数据资产记录及合规性检查。
触发场景
安装
npx skills add open-knowledge-format/open-knowledge-format --skill okf-generate -g -y
SKILL.md
Frontmatter
{
"name": "okf-generate",
"license": "Apache-2.0",
"metadata": {
"version": "0.1.0",
"publisher": "google"
},
"description": "Create, update, migrate, repair, or validate an Open Knowledge Format (OKF) v0.3 bundle, including recording a verification. An OKF bundle is a directory of Markdown files with YAML frontmatter that documents data assets, metrics, policies, and procedures for people and agents. Use this skill when the user asks to write, generate, bootstrap, enrich, or migrate OKF documents or a knowledge bundle; to document tables, datasets, metrics, APIs, or playbooks in OKF; to add provenance, trust, lifecycle, or attested-computation fields; or to check a bundle for OKF conformance. Use this skill, not okf-consume, to repair a bundle or to record a verification."
}
Generate an OKF bundle
This skill produces an OKF v0.3 bundle that conforms to the specification and records the source of each fact. The specification is SPEC.md in the OKF repository. references/frontmatter.md lists every field. references/templates.md gives a template for each document type.
An OKF bundle is a directory tree. A concept is a Markdown file whose frontmatter has a non-empty type. A Markdown file without frontmatter or without type, such as a README.md, is not a concept. A file whose name does not end in .md is an asset. The file names index.md and log.md are reserved at every level.
To answer questions from a bundle, use the okf-consume skill.
Rules
- Write only what a source supports. Do not invent columns, partitions, URLs, owners, numbers, policies, or review dates. If a fact has no source, omit it or ask the user.
- Record provenance. List the sources of each concept in
sources. Attach each specific claim to its source with a footnote whose label is the sourceid. - Record authorship honestly. Set
generated.byto your own actor,<tool>/<model>, where<tool>is the agent product, such asclaude-code,codex, orantigravity. - Do not claim a verification that did not occur. Do not add a
verifiedentry to content that you generated in this run. Add ahuman:<id>entry only when that person confirmed the content, asked you to record it, and stated their id. Never infer an id from the machine, such as a login name or git configuration. Without an id, record no verification and say why. - Never write the computation of an Attested Computation. Copy it exactly from a sanctioned source, such as an approved SQL file, a dbt model, or a query from its owner. Cite that source. If no sanctioned computation exists, describe the metric without one and report the gap. Do not store an unreviewed query in the bundle unless the user explicitly asks; then store it as a Reference with
status: draft, never linked as a computation. - Keep what you do not own. When you update a file, keep its unknown keys, its
verifiedhistory, and text that a person wrote. Do not rewrite values that you did not change.
Procedure
1. Set the scope
- Find or choose the bundle root. If the bundle exists, read its root
index.mdandlog.mdfirst, and note itsokf_version. - List the sources that you can read. Examples are schema metadata, such as
INFORMATION_SCHEMAviews or an OpenAPI file, documentation pages, runbooks, and notes from the user. - Tell the user which sources you cannot read.
- If the scope is not clear, ask the user which assets or topics to include.
2. Plan the tree
- Plan one concept per file. The concept ID is the file path without
.md. - Group concepts in directories by kind, for example
datasets/,tables/,metrics/,computations/,policies/,playbooks/, andreferences/. Reuse the directory names that the bundle already has. - Use stable lowercase file names, and never two paths that differ only by case.
- Do not name a concept
index.mdorlog.md. - If you plan more than 10 files, show the planned tree to the user before you write them.
3. Write each concept
- Start the file with a line that is exactly
---, and end the frontmatter with the next---line. - Set
typeto a short descriptive name, for exampleBigQuery Table,Metric,Playbook,Reference, orAttested Computation. Reuse the type names that the bundle already uses. - Write
descriptionas one sentence. - If the concept describes an asset, set
resourceto the canonical URI of that asset. - Write
tagsas a YAML list, for example[sales, orders]. A consumer reads a scalartagsvalue as one tag, sotags: sales, ordersis the single tagsales, orders. - Write
generated.atandverified[].atas RFC 3339 date-times with an offset, such as"2026-06-30T14:00:00Z". Other timestamps can also be a date, such as"2026-12-31", which means 00:00 UTC on that day. - Follow the syntax rules in references/frontmatter.md. Quote timestamps, actors, and values that look like numbers or booleans. Do not repeat a key.
- Start the body with one to three paragraphs. Tell what the concept is, its grain or scope, how people use it, and its caveats.
- Use the conventional headings when they apply:
# Schemafor columns or fields,# Examplesfor usage, and# Computationfor an Attested Computation.
4. Link concepts and write paths
- When the text names another concept in the bundle, link to it with a standard Markdown link, once per section and not from headings or code.
- Write links in the body relative to the file, for example
../tables/orders.md, because that form displays correctly on GitHub. - Write path fields (
resource,sources[].resource,computation,executor.resource,attester.resource,superseded_by) with a leading/, for example/references/attesters/sql-equality.py. A path field without a leading/resolves from the directory of its file, not from the bundle root. - Percent-encode spaces in paths, such as
my%20concept.md. - Link only to concepts that exist or that you create in this run.
5. Record provenance, trust, and lifecycle
- Give each
sourcesentry a stableid, the requiredresource, and atitle. - Add
author(an actor),usage_count, orlast_modifiedonly when you have the real value. Give eachusage_countausage_window. - List the concept's own
resourceas a source when the content came from it. - Cite a specific claim with a footnote, for example
Revenue excludes tax.[^rev-policy]. Define it as[^rev-policy]: Revenue recognition policy. The label must equal asources[].id. Do not use numbered labels such as[^1]. - Set
generated: { by: "<your actor>", at: "<current UTC time>" }on each concept that you create or change in meaning. If your change only fixes format, whitespace, or links, keep the existinggeneratedvalue. - Write actors as
<producer>/<version>or<scheme>:<id>, with the schemeshuman:,team:, andprocess:. Onlyhuman:gives the human-reviewed trust tier. - For normal content, omit
status. A missingstatusmeansstable. - If the content is incomplete or needs review by its owner, set
status: draft. - If a concept is retired, keep the file with its definition and
verifiedhistory, and setstatus: deprecated. If a replacement exists, setsuperseded_byto its path, and state the reason in the body. - To move or rename a concept, keep its
generatedandverifiedvalues, because a move does not change its meaning. Keep a short deprecated concept at the old path withsuperseded_byset to the new path. - Set
stale_afteronly when a source has a known review or refresh cycle. Do not guess a date.
6. Write an attested computation
Do this step only when you have a sanctioned computation (rule 5).
- Write the computation as its own concept with
type: Attested Computation, usually incomputations/, and set itsruntime. - Write its parameters, computation block, executor, and attester as references/attested-computations.md describes.
- Link to the computation from each concept that uses its value, for example from a
Metric.
7. Write index and log files
- Write or update
index.mdin each directory that you changed. Group the entries under headings. - Write each entry as
* [Title](path) - description. Copy the description from the concept's frontmatter. - Do not put frontmatter in an
index.mdbelow the bundle root. - Give the root
index.mdfrontmatter withokf_version: "0.3", atitle, a one-sentencedescriptionof the scope of the bundle and when to use it, and alicensewhen you know it. Agents use the description to choose a bundle. - When you regenerate the root
index.md, keep its existing frontmatter. - Add an entry to
log.mdfor the change. Do not put frontmatter inlog.md. Use a## YYYY-MM-DDheading and put the newest date first.
8. Validate
-
Run the validator from this skill's directory:
python3 scripts/validate.py <bundle-root> -
Fix each error. Errors mark conformance failures (section 11.1).
-
Fix each warning, or tell the user why you kept it. Warning
W120, a file that is not a concept, is correct only for documentation such as aREADME.md. -
Read the info findings, such as stale concepts and verifications older than the content.
-
If you cannot run the script, check the conformance rules of section 11.1 by hand.
The validator needs Python 3.9 or later and PyYAML (pip install pyyaml). Use --json for structured output and --strict to fail on warnings.
9. Report
Tell the user:
- the files that you created or changed,
- the concepts that you marked
draftordeprecated, - the concepts that now need a new verification,
- the facts that you could not source,
- the validation result.
Update an existing bundle
- Change only what your sources support. Keep the other content and its exact form.
- Update
generated.atonly for a change in meaning. - Keep each
verifiedentry. A verification counts only when it is not older thangenerated.at, so a change in meaning needs a new verification. Tell the user.
Migrate an older bundle
To migrate a v0.1 or v0.2 bundle to v0.3, follow references/migration.md.
版本历史
- 527e81a 当前 2026-11-24 11:34


