Create bkn

From openbkn-ai/bkn-sdk · View interactive version

Create bkn is an AI agent skill from the GitHub repository openbkn-ai/bkn-sdk. Guides creation of BKN (Business Knowledge Network) definition files in either spec version: BKN 3.0 (default) or BKN 2.x. Covers network, value_type, object_type, relation_type, action_type, concept_group, including property declarations (semantic, required, constraints), value types and enums, ali

How to use this skill

Skill file

Create BKN

Generate well-formed BKN directories (Markdown + YAML frontmatter) in either spec version: BKN 3.0 (default) or BKN 2.x.

Works with the openbkn skill

create-bkn authors the .bkn tree; the openbkn skill runs openbkn auth login and openbkn bkn push / pull after files exist.

What is BKN

BKN is Markdown + YAML frontmatter for schema; one file per definition under typed subfolders. Details (sections, required tables, types, every declaration) live in references/SPECIFICATION.llm.md.

Spec version: 3.0 or 2.x

Pick the spec version before writing anything:

| Write | When | network.bkn | Example |

|-------|------|---------------|---------|

| BKN 3.0 (default) | Target platform 0.2.2 or later; 0.2.1 too, without ### Operation Config (see below) | bkn_spec: "3.0" | references/examples/clinic-lab/ |

| BKN 2.x | The user asks for 2.x, or the target platform only reads 2.x (0.2.0) | no bkn_spec | references/examples/clinic-lab-2.x/ |

Directory layout

Do not hand-write a CHECKSUM, and delete it when you copy the example and change its files: a stale one only makes push warn, but a package with object metrics is refused. openbkn bkn pull writes a fresh one.

{network_dir}/
├── SKILL.md
├── network.bkn
├── CHECKSUM                 # optional; generated on export — do not write or copy one
├── value_types/             # 3.0 only: enums, formats, ranges reused by properties
├── object_types/
├── relation_types/
├── action_types/
├── risk_types/
└── concept_groups/

Workflow

  1. Spec version — 3.0 or 2.x (see Spec version)
  2. Gather requirements — objects and their key properties, relations (and which ones are reliable), actions, code tables / dictionaries, optional concept groups
  3. Read spec — references/SPECIFICATION.llm.md (format rules, sections, declarations)
  4. Pick templates — copy/adapt from assets/templates/
  5. Create network.bkn — root file; bkn_spec: "3.0" for 3.0, none for 2.x; title and network description only
  6. Create value_types/*.bkn (3.0 only) — one per code table (enum), fixed format (pattern / length) or bounded number (range / unit) that properties share
  7. Create object_types/*.bkn — one file per object, {id}.bkn; for 3.0 declare semantic, required, aliases and constraints
  8. Create relation_types/*.bkn — one file per relation; for 3.0 declare reverse name, cardinality, constraints; mark helper relations secondary and link fallback paths with fallback_for
  9. Create action_types/*.bkn — one file per action, one tool per action; ### Operation Config says whether it acts on an object (object), links or unlinks two objects (relation) or just calls a tool (tool)
  10. Create concept_groups/*.bkn — optional
  11. Add root SKILL.md in the BKN directory — same folder as network.bkn (this is not the create-bkn skill file); agent-facing guide for that network (see Delivered BKN: root SKILL.md)
  12. Review (MUST) — cross-check Validation checklist and Business rules placement; fix IDs, cross-refs, headings
  13. Validate (MUST) — openbkn bkn validate <dir> (see Validation)
  14. Import (optional) — openbkn bkn push <dir>

Import (openbkn CLI)

Requires the openbkn CLI from @openbkn/bkn-sdk (npm install -g @openbkn/bkn-sdk; Node.js 22.19.0+). push uses tar; on macOS COPYFILE_DISABLE=1 is set by the tool.

openbkn bkn push <dir> [--branch main] [--binding-policy detach]

Export: openbkn bkn pull <kn-id> [<dir>]. More subcommands: openbkn bkn --help (see the openbkn skill if loaded).

Validation

openbkn bkn validate <dir> — must pass before delivery or upload. It is an offline structural check: it loads network.bkn and sibling .bkn files, checks frontmatter, ids, table shape, relation endpoints and each action's Operation Config (a missing one only warns, for platforms 0.2.1 and earlier), and prints counts (object types, relation types, concept groups, value types). The 3.0 declaration rules are checked by the platform on push; follow the spec to get them right the first time.

A capabilities: section in network.bkn never fails validation. Read capabilities.skipped and the warnings instead: an entry listed there binds on no platform. After push, the answer's capabilities.skipped names what this platform could not resolve.

Per-type reference

| Kind | Template | Example (clinic-lab, 3.0) |

|------|----------|----------------------|

| Network | network_type.bkn.template | network.bkn |

| Value type | value_type.bkn.template | lis_apply_status.bkn (enum), cn_id_card.bkn (format), amount_cny.bkn (range) |

| Object | object_type.bkn.template | lab_order.bkn, patient.bkn |

| Relation (direct) | relation_type.bkn.template | order_for_patient.bkn, department_under.bkn (self, transitive) |

| Relation (indirect, with properties) | relation_type_indirect.bkn.template | doctor_in_department.bkn |

| Fallback path / lifecycle | — | order_for_patient_by_id_card.bkn, order_by_legacy_doctor.bkn |

| Action | action_type.bkn.template | revoke_lab_order.bkn |

| Concept group | concept_group.bkn.template | lab.bkn |

Templates are complete 3.0 files: replace every {placeholder}, and delete rows, columns, keys or sections you do not need (a column no property uses, such as Semantic or Aliases, is left out whole). Full rules and optional sections: references/SPECIFICATION.llm.md.

Declarations: when to use what

Naming conventions

Business rules placement

Rules must sit in spec-defined places so import persists them. Full wording: references/SPECIFICATION.llm.md.

Validation checklist

Output rules

  1. Emit raw .bkn content — do not wrap the whole file in a fenced markdown block
  2. Reuse IDs consistently across relations/actions/value types
  3. IDs: lowercase + underscores; display text Chinese unless asked otherwise
  4. Keep heading order and column names per spec

Examples

Delivered BKN: root SKILL.md

When you build a knowledge network directory {network_dir}/, add {network_dir}/SKILL.md at the root (alongside network.bkn). Short overview + index tables with file paths (value type | object | relation | action | path) so agents route to the right .bkn without scanning, and how to use the declarations (enum codes, fallback paths, deprecated definitions). Example: references/examples/clinic-lab/SKILL.md.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.