kmd — knowledge-markdown
kmd is a knowledge system for AI agents, built on Open Knowledge Format primitives: plain markdown, YAML frontmatter, a controlled vocabulary. What it adds is timing. The right context reaches the agent at the right moment, and costs nothing the rest of the time.
A cold session gets its orientation in one prime call: current focus, invariants, what to read. search returns ranked candidates, never page dumps. Hooks steer the agent at the exact event where a rule applies: a reminder on the prompt that needs it, a gate on the tool call that would break it, validation on the write that touched the vault. Rules that would otherwise sit in instruction files, paying tokens on every request, fire only when they matter.
The vault stays plain markdown in git, Obsidian-compatible. Works with Claude Code, Codex, and Kiro. No database to run.
npx @bartolli/kmd --help
Quick start
Two setups. Pick one, or use both; they compose.
A global vault. One personal wiki serving all your projects:
npx @bartolli/kmd init ~/wiki-vault --set-default
--set-default records the vault in ~/.kmd/config.yaml. Every kmd command and MCP server on this machine now finds it without configuration.
A project vault. The repo carries its own knowledge:
cd my-repo
npx @bartolli/kmd init --local
This scaffolds my-repo/vault/ plus a .kmd/ state home. Every command run inside the repo resolves this vault automatically, and it wins over the global default. Nothing else to configure.
Then, either way:
kmd validate # deterministic checker, no LLM
kmd sync # vault → SQLite index
An existing vault. When the engine moves ahead of a vault scaffolded earlier — a new kind, a new template — bring it to the starter:
kmd init --upgrade # report the delta; exit 1 when behind
kmd init --upgrade --apply # append the missing pieces; nothing you wrote is touched
Where things live
| Thing | Where | Nature |
|---|
| Vault | wherever you put it (~/wiki-vault, <repo>/vault/) | yours: markdown + vault.yaml, git-tracked, canonical |
| Index | ~/.kmd/db/{vault-key}/index.db, or <repo>/.kmd/db/ for project vaults | disposable: kmd db reset deletes it, kmd sync rebuilds it |
| Machine config | ~/.kmd/config.yaml | default_vault, written by kmd init --set-default or kmd config set |
| Project config | <repo>/.kmd/config.yaml | committed, repo-relative paths; .kmd/config.local.yaml is the personal, gitignored override |
| Hook state | ~/.kmd/state/ or <repo>/.kmd/state/ | session dedup markers; survives kmd db reset |
A project vault's index and state live in the repo. Delete the repo and they go with it.
How kmd finds your vault
One resolution order, used by the CLI, the MCP server, and the hooks. First hit wins:
- An explicit path argument: pins that vault, beats everything.
- The project: nearest ancestor with
.kmd/config.local.yaml, .kmd/config.yaml, vault/vault.yaml, or a vault.yaml with a .kmd/ directory beside it.
--default-root <path>: a configured default the project may beat.
$WIKI_VAULT.
default_vault from ~/.kmd/config.yaml.
The project signal is the working directory: the shell's for CLI commands, the session's for hooks, KMD_PROJECT_DIR for MCP servers. When something resolves to the wrong vault, run kmd config. It prints the vault and which rank won.
Teams commit .kmd/config.yaml with a repo-relative vault: path or a ${VAR} expansion. Absolute paths belong in the gitignored config.local.yaml.
Commands