|
| 1 | +# TAGLINE |
| 2 | + |
| 3 | +Git-native OKF knowledge bundles for AI agent memory |
| 4 | + |
| 5 | +# TLDR |
| 6 | + |
| 7 | +**Scaffold** agent memory into a project (`knowledge/`, skill, `AGENTS.md`, Makefile) |
| 8 | + |
| 9 | +```okf bootstrap [path/to/project] --name "[My Project]"``` |
| 10 | + |
| 11 | +Initialize a **bare OKF v0.2 bundle** (`index.md` and `log.md`) |
| 12 | + |
| 13 | +```okf init [path/to/knowledge]``` |
| 14 | + |
| 15 | +**Validate** a bundle (defaults to `./knowledge` if that directory exists) |
| 16 | + |
| 17 | +```okf validate [knowledge]``` |
| 18 | + |
| 19 | +Treat broken links, orphans, and provenance gaps as **errors**, and check index drift |
| 20 | + |
| 21 | +```okf validate [knowledge] --strict --drift``` |
| 22 | + |
| 23 | +**Search** concepts with in-memory BM25 ranking |
| 24 | + |
| 25 | +```okf search "[architecture layers]" [knowledge]``` |
| 26 | + |
| 27 | +Limit search hits and print **JSON** |
| 28 | + |
| 29 | +```okf search "[auth]" [knowledge] --limit [5] --json``` |
| 30 | + |
| 31 | +**Show** a concept (id is the path without `.md`) |
| 32 | + |
| 33 | +```okf show [architecture/layers] [knowledge]``` |
| 34 | + |
| 35 | +Dump the **raw markdown** of a concept |
| 36 | + |
| 37 | +```okf show [architecture/layers] [knowledge] --raw``` |
| 38 | + |
| 39 | +**Create** a concept and update `index.md` / `log.md` |
| 40 | + |
| 41 | +```okf create [decisions/auth-flow] [knowledge] --type Decision --title "[OAuth2 Authorization Flow]" --desc "[Standardized on PKCE for client authentication.]"``` |
| 42 | + |
| 43 | +**Update** an existing concept |
| 44 | + |
| 45 | +```okf update [decisions/auth-flow] [knowledge] --desc "[Updated PKCE token refresh interval.]"``` |
| 46 | + |
| 47 | +**Link** two concepts |
| 48 | + |
| 49 | +```okf relate [architecture/tooling] [architecture/layers] [knowledge] --desc "[Tooling implements the five-layer architecture]"``` |
| 50 | + |
| 51 | +Run the **MCP server** on stdio for Claude Code, Cursor, and similar clients |
| 52 | + |
| 53 | +```okf mcp [knowledge]``` |
| 54 | + |
| 55 | +Print the **CLI version** |
| 56 | + |
| 57 | +```okf version``` |
| 58 | + |
| 59 | +# SYNOPSIS |
| 60 | + |
| 61 | +**okf** _command_ [_arguments_] [_flags_] |
| 62 | + |
| 63 | +**okf** {**version** | **-v** | **--version**} |
| 64 | + |
| 65 | +**okf** {**help** | **-h** | **--help**} |
| 66 | + |
| 67 | +# PARAMETERS |
| 68 | + |
| 69 | +**--json** |
| 70 | +> Emit machine-readable JSON instead of terminal text. Accepted by **validate**, **search**, **show**, **create**, **update**, and **relate**. |
| 71 | +
|
| 72 | +**--strict** |
| 73 | +> On **validate**, treat connectivity warnings (orphans, broken relative links, provenance gaps) as a failed producer gate (exit 1). |
| 74 | +
|
| 75 | +**--drift** |
| 76 | +> On **validate**, fail when a concept's frontmatter description does not match its listing in the parent **index.md**. |
| 77 | +
|
| 78 | +**--limit** _N_ |
| 79 | +> On **search**, maximum hits to return (default **10**). |
| 80 | +
|
| 81 | +**--raw** |
| 82 | +> On **show**, print the concept file exactly as stored on disk. |
| 83 | +
|
| 84 | +These flags are parsed per subcommand (Go `flag`), not as a global option parser. Put them after the subcommand and its positional arguments. |
| 85 | + |
| 86 | +# COMMANDS |
| 87 | + |
| 88 | +**validate** [_bundle_] |
| 89 | +> Audit an OKF bundle for structural conformance, graph health, and provenance. Default _bundle_ is **./knowledge** if that directory exists, otherwise **.**. Exit **0** if conformant (and the producer gate passed), **1** if non-conformant or the gate failed, **2** if the bundle could not be loaded. |
| 90 | +
|
| 91 | +**search** _query_ [_bundle_] |
| 92 | +> Rank concepts with in-memory BM25 over titles, descriptions, tags, ids, and body text. _query_ is required. |
| 93 | +
|
| 94 | +**show** _concept-id_ [_bundle_] |
| 95 | +> Print metadata, trust provenance, inbound/outbound links, and the markdown body. _concept-id_ is the bundle-relative path without **.md** (a trailing **.md** is stripped). |
| 96 | +
|
| 97 | +**create** _concept-id_ [_bundle_] |
| 98 | +> Write a new concept file and, unless disabled, append **log.md** and update the parent **index.md**. **--type** _Type_ (default **Fact**; examples: **Decision**, **Architecture**, **Entity**, **Runbook**), **--title** _text_ (default: last path component of the id), **--desc** _sentence_, **--body** _markdown_, **--tags** _tag1,tag2_, **--actor** _who_ (default **agent/cli**), **--no-log**, **--no-index**. |
| 99 | +
|
| 100 | +**update** _concept-id_ [_bundle_] |
| 101 | +> Change **--title**, **--desc**, and/or **--body** on an existing concept, refresh timestamps, and record the change in **log.md** unless **--no-log** is set. **--actor**, **--no-index**, and **--json** as on **create**. |
| 102 | +
|
| 103 | +**relate** _source-id_ _target-id_ [_bundle_] |
| 104 | +> Add a relative markdown link from source to target. **--desc** _context_ explains the relationship. **--actor** and **--json** as on **create**. |
| 105 | +
|
| 106 | +**init** [_directory_] |
| 107 | +> Create a bare OKF v0.2 bundle: **index.md** (declaring **okf_version: "0.2"**) and **log.md**. Default directory is **./knowledge** if present, otherwise **.**. |
| 108 | +
|
| 109 | +**bootstrap** [_target-dir_] |
| 110 | +> Scaffold a full agent-memory stack into _target-dir_ (default **.**): **knowledge/**, **.agents/skills/okf-memory/**, **AGENTS.md**, and a convenience **Makefile**. **--name** _project_ (default: directory name). **--overwrite-agents-md** replaces an existing **AGENTS.md** instead of appending a delimited section. **--no-skill**, **--no-agents-md**, **--no-makefile**, and **--no-bundle** skip individual pieces. |
| 111 | +
|
| 112 | +**mcp** [_bundle_] |
| 113 | +> Run an embedded Model Context Protocol server on **stdio**. Tools: **okf_search**, **okf_show**, **okf_create**, **okf_update**, **okf_relate**, **okf_validate**. |
| 114 | +
|
| 115 | +**version** |
| 116 | +> Print `okf version … (OKF v0.2 specification)`. Also accepted as **-v** / **--version**. |
| 117 | +
|
| 118 | +**help** |
| 119 | +> Print the command list. Also accepted as **-h** / **--help**. With no arguments, **okf** prints help and exits **1**. |
| 120 | +
|
| 121 | +# DESCRIPTION |
| 122 | + |
| 123 | +**okf** is the command-line tool from **OKF Agent Memory**, a Git-native persistent memory layer for AI coding agents. It reads and writes **Open Knowledge Format (OKF) v0.2** bundles: a directory of Markdown files with YAML frontmatter, plus hierarchical **index.md** files and a dated **log.md**. The usual bundle root in a project is **knowledge/**. |
| 124 | + |
| 125 | +The binary is a single Go program with no third-party Go modules. It parses the corpus, validates the concept graph, searches with in-memory BM25 (lexical ranking, not embeddings), creates and updates concepts with automatic index/log bookkeeping, and can expose the same operations over MCP stdio for clients such as Claude Code and Cursor. |
| 126 | + |
| 127 | +Concept ids are paths relative to the bundle root without the **.md** suffix (for example **architecture/layers** for **architecture/layers.md**). When a command omits the bundle path, **okf** uses **./knowledge** if that directory exists, otherwise the current directory. |
| 128 | + |
| 129 | +A companion **okf-benchmark** binary in the same repository measures progressive-disclosure token and latency effects against local LLM runtimes; it is not installed as **okf**. |
| 130 | + |
| 131 | +# CONFIGURATION |
| 132 | + |
| 133 | +**knowledge/** |
| 134 | +> Default project bundle. **okf bootstrap** creates it; most subcommands default to it when present. |
| 135 | +
|
| 136 | +**knowledge/index.md** |
| 137 | +> Root progressive-disclosure index. Declares **okf_version: "0.2"** and lists child concepts. |
| 138 | +
|
| 139 | +**knowledge/log.md** |
| 140 | +> Dated change log (ISO 8601 **YYYY-MM-DD**). **create**, **update**, and **relate** append here unless **--no-log** is set. |
| 141 | +
|
| 142 | +**.agents/skills/okf-memory/** |
| 143 | +> Agent skill files installed by **bootstrap** (unless **--no-skill**). |
| 144 | +
|
| 145 | +**AGENTS.md** |
| 146 | +> Project instructions for coding agents. **bootstrap** creates the file or appends a delimited section unless **--overwrite-agents-md** or **--no-agents-md** is set. |
| 147 | +
|
| 148 | +**Makefile** |
| 149 | +> Optional convenience targets (**validate**, **search**) written by **bootstrap** unless **--no-makefile**. |
| 150 | +
|
| 151 | +There is no global config file or environment-variable overlay. MCP clients point at the **okf** binary with arguments **mcp** and the bundle path. |
| 152 | + |
| 153 | +# CAVEATS |
| 154 | + |
| 155 | +Several unrelated projects ship a binary named **okf** (other OKF bundle CLIs and a Ruby gem). Confirm **okf version** mentions **OKF v0.2 specification** and **okf help** lists **bootstrap** / **mcp** before relying on a distro or `PATH` install. |
| 156 | + |
| 157 | +Search is **lexical BM25**, not vector similarity. It does not call an embedding API. |
| 158 | + |
| 159 | +**--json**, **--strict**, and **--drift** are not global flags: they must follow the subcommand that accepts them. Unknown flags on that subcommand cause the process to exit. |
| 160 | + |
| 161 | +**mcp** speaks MCP only over **stdio**. It is meant to be launched by an editor or agent host, not as a network daemon. |
| 162 | + |
| 163 | +The in-tree Homebrew formula targets **okf-memory/tap/okf** and GitHub release assets for **v0.1.0**. Distro packages may be missing or may refer to a different **okf**. Building from source needs a Go toolchain (**go.mod** requires **1.22**); **make build** writes **bin/okf**, **make install** uses **go install**. |
| 164 | + |
| 165 | +# HISTORY |
| 166 | + |
| 167 | +**Open Knowledge Format** is a vendor-neutral Markdown-plus-YAML spec from **Google Cloud** (Knowledge Catalog / open-knowledge-format), published in **June 2026** (v0.1, then v0.2). **okf** is a separate MIT-licensed Go implementation by **sknr** and the **OKF Memory** contributors. The **okf-agent-memory** repository was created on **5 September 2026**; the project announced **v0.1.0** on Hacker News the following day as a zero-dependency CLI and MCP server for Git-tracked agent memory. |
| 168 | + |
| 169 | +# SEE ALSO |
| 170 | + |
| 171 | +[git](/man/git)(1), [claude](/man/claude)(1), [codex](/man/codex)(1), [opencode](/man/opencode)(1), [codeknow](/man/codeknow)(1) |
| 172 | + |
| 173 | +# RESOURCES |
| 174 | + |
| 175 | +```[Source code](https://github.com/okf-memory/okf-agent-memory)``` |
| 176 | + |
| 177 | +```[Documentation](https://github.com/okf-memory/okf-agent-memory/blob/main/docs/CLI.md)``` |
| 178 | + |
| 179 | +<!-- verified: 2026-09-06 --> |
0 commit comments