Project

From inkeep/open-knowledge · View interactive version

Project is an AI agent skill from the GitHub repository inkeep/open-knowledge. Authoritative agent-runtime contract for working inside an OpenKnowledge project — a markdown-CRDT knowledge base exposed over MCP. Use whenever reading, listing, searching, editing, or linting any `.md` or `.mdx` file in the project, and before any `mcp__open-knowledge*` tool call (`exec`, `search`

How to use this skill

Skill file

OpenKnowledge — agent guidance

OpenKnowledge (OK) is a markdown-CRDT collaboration platform exposed via MCP. This skill is the single source of OK agent guidance. Every rule below is a MUST unless marked otherwise. Depth lives in references/*.md — one level deep; load a reference when its task comes up.

Skill version tracks @inkeep/open-knowledge-server. cat ~/.ok/skill-state.yml shows what's installed. ok seed needs @inkeep/open-knowledge >= 0.4.0; if it errors unknown command, npm install -g @inkeep/open-knowledge.

CLI name. Commands here use Stable's ok (open-knowledge) and ~/.ok/. With OpenKnowledge Beta, use ok-beta (open-knowledge-beta) and ~/.ok-beta/ instead; preview_url's okOpenCommand already names the right one.

Setup (not connected yet?). If the mcp__open-knowledge* tools aren't available in your client, this project isn't wired up on this machine — see CODE1 for the rung ladder (approve .mcp.json → ok start CLI → optional desktop app) and the canonical quickstart.

TL;DR — the 90% case

  1. Reads: exec("cat …") for one doc, exec("ls -A …") for a directory (folder defaults + template menu), exec("grep …") for literal, search for ranked retrieval. Native Read / Grep only on source code (.ts / .py / …), never on in-scope .md / .mdx.
  2. Writes: write({ document: { path, content } }) for a new or full-replace doc; edit({ document: { path, find, replace } }) for a body find/replace; edit({ document: { path, frontmatter } }) for a frontmatter merge-patch (null deletes a key). delete({ document }) removes, move({ from, to }) moves/renames. Body find/replace is body-only. Pass a one-line summary (≤80 chars, user-facing outcome) on every content write.
  3. Preview / open a doc — determine your ONE surface FIRST (once per session). Stop at first match: OK_DESKTOP_TERMINAL or OK_HOSTED_AGENT set → you're inside OpenKnowledge (desktop terminal / in-app agent panel) → ok open <name> (switches the window the user is already looking at); never paste a localhost URL into your reply here · in-app browser (Claude Code Desktop's Browser pane, Cursor, Codex) → preview_url, then open/navigate it to the doc · else plain CLI → ok open <name>. ok open <name> opens a doc or folder (auto-detected); --skill <name> for a skill. The previewUrl field is a route id, not your open mechanism. Don't preview_screenshot to confirm edits. Full Step-0 procedure + per-surface how-to: references/preview.md.
  4. Direct questions: a plain business question ("which customers…", "what did we decide about…") routes to search / exec + a cited chat answer — no "research" keyword needed. Persist only when durable + multi-doc + not already covered, and offer first. See references/corpus-qa.md.
  5. Authoring or improving a skill ("write/make/improve a skill", "turn this into a skill"): STOP and invoke /open-knowledge-write-skill for scope (project/global), contract, evaluation, and install. Author through write({ skill }), never a document path. Skills are real folders under editor skills/ dirs (.claude · .cursor · .codex · .github · .opencode · .pi · .agents): one source plus managed copies/symlinks. Read/edit via skills and edit({ skill }) — they route to the source. Never hand-edit a non-source copy: recorded, unedited copies refresh from the source when the skill watcher runs or the server starts, so a source edit can precede the refresh. Editing a copy directly forks it and stops refresh.

Tool index — 19 tools (router; calling contracts live in tool descriptions and input schemas)

Read ran on successful lint/audit results: a family absent from ran was not checked, and [] means no checks were selected. For link VALIDATION use audit; links reports relationships and raw dead-link state. Caveats: references/linking.md.

Skill placement is separate from skill content: the source folder IS the skill, and removing an installed copy does not delete the skill. For a Project↔Global move, history resets; only what the destination level can host re-projects; the rest is removed at source, returned as droppedLocations (success: re-add with install). Read the returned outcome before recovery. A folder's frontmatter is open-shape and self-only (does NOT cascade); templates are what new docs start with.

Self-correcting on misuse: constraints JSON Schema can't express ("exactly one target", "find needs a replace", body-XOR-frontmatter) return isError: true with a one-line corrective shape. Read it and retry with that shape; don't guess.

Tools NOT in OK MCP (your host's): preview_start, preview_screenshot, WebFetch, WebSearch, native Read / Grep / Glob / Edit. The STOP rule governs which you may use on in-scope markdown.

STOP — native tools on in-scope `.md` / `.mdx`

Route every in-scope markdown read and write through OK's MCP tools — never your host's native file tools. Native Edit / sed / direct Write on in-scope markdown bypasses the CRDT and loses agent attribution in the shadow repo; native reads skip frontmatter, backlinks, shadow-repo activity, and project git history that OK returns for every matched file. When this workspace has OpenKnowledge MCP configured, do not use native file tools on markdown paths inside the content directory. The ban covers every common rationalization:

Not seeing exec is NOT the escape hatch. Wiring, labels, and tool visibility vary by client; some (notably Codex) defer MCP tools behind lazy discovery. Registration is the test, not top-level-symbol visibility — run tool discovery for open-knowledge first. Detail: references/setup.md.

Escape hatch. Native Read / Grep / Glob on .md / .mdx is allowed only when, after running tool discovery (above), no OpenKnowledge MCP server is registered for this project, or immediately after you actually invoked an MCP call and it failed — then begin a user-visible sentence with OpenKnowledge MCP unavailable:. "Not registered" is a conclusion you may only reach after tool discovery turned it up empty — never from the initial tool list alone. Never use the hatch because you skipped your client's MCP path, didn't see exec as a top-level tool, didn't run tool discovery, or rationalized the skill wasn't necessary.

Source code and non-markdown files (.ts, .py, package.json, …): native Read / Grep / Glob always.

Writing

Call write / edit as soon as you have content (route through MCP per the STOP rule).

Persist incrementally — the knowledge base IS your checkpoint (MUST). On any multi-step or long-running task — a research sweep, a multi-source synthesis, a batch of docs — write completed work to the KB as you finish each unit: per section, per source, per doc. Never hold finished findings only in your context waiting for one final write at the end. A rate limit, crash, or context compaction mid-task discards everything still unwritten; work already persisted survives, and you resume by reading the doc back. Create the target doc early (skeleton + frontmatter), then edit each section in as it firms up.

Pass a summary on every content write (SHOULD) — a one-line (≤80 char) user-facing note; it becomes the timeline entry. Reach for visual structure (Callout, mermaid, table, html preview) where it carries the point better than prose; call palette as you draft. Advisory write-warnings, MDX authoring, delete/move mechanics, and visual authoring: references/writing.md + references/components-and-visuals.md + references/media-and-assets.md.

Grounding — every factual claim needs a source (MUST)

KB docs are factual artifacts: every claim traceable, and the source lives inside the knowledge base, not on the public web.

Ingest is a procedure, not a tool — binary-vs-text classification, SSRF-safe fetch flags, size + executable gates, wrapper frontmatter — in CODE0. Read it before your first capture; a naive fetch-and-paste skips every gate.

Linking — standard markdown links (MUST)

Link every noun-phrase that names another document — [text](./relative/path.md) — and link liberally. To point at one section of a long doc, in chat replies too, link ./path.md#heading-slug. Every link must resolve to a doc that exists by the time you're done (a same-pass forward-reference you create later in the pass is fine; for one that genuinely won't exist, leave the mention as plain prose + a tracked task). Never backtick a link (` text is a bug) and never use HTML <a>. **After every write/edit, read brokenLinks: fix reported hrefs; [] means all links resolve unless brokenLinkSuppression withheld reserved-log findings (not yours to repair) or a link-check-deferred warning says nothing was checked yet (the server was still starting or busy with other writes; that doc is re-checked only by a later write/edit of it or an audit, which may time out while the server is still starting).** audit is authoritative; its same marker carries the same meaning. External web sources are NOT inline body links (see Grounding). Full rule set, slug rule + the [[Page]] legacy note: references/linking.md`.

Folders, frontmatter, templates

Every .md / .mdx needs YAML frontmatter — title + description required, tags recommended. OKF projects (okf pack) are the exception: pack rules win — a non-root index.md carries NO frontmatter (the frontmatter-reserved-index lint warns on any key), log.md needs none, and concept docs need only a non-empty type; title/description are optional there. Two opt-in, nested folder mechanisms: folder frontmatter (<folder>/.ok/frontmatter.yml — the folder's own open-shape properties; self-only, does NOT cascade into child docs) and templates (<folder>/.ok/templates/ — what new docs start with). Most folders have NO .ok/. A doc's frontmatter is exactly its own on-disk YAML. Structural model + the full pre-write checklist: references/folder-model.md. Template authoring + folder editing: references/template-authoring.md. Frontmatter-vs-body edit rules: references/doc-editing.md.

Write outcomes

For every write result, read outcome and follow nextStep (references/conflict-resolution.md has each outcome's move): never repeat a write that landed (merged-first, both-kept, projection-held), and when a refusal says nextStep: none, nothing you send changes it: tell the user which file and what the result says, and carry on.

Anti-patterns — the top offenders

| Task | Don't | Do |

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

| List / find / read markdown | Bash: ls/Glob: **/*.md/Read: foo.md | exec("ls -A …") / exec("find …") / exec("cat …") |

| Explore a markdown-heavy dir | Agent(Explore) (bypasses OK) | exec/search yourself |

| Reference another doc | ` text (backticked) or HTML <a> | text` |

| Embed an image | <img>, a localhost/preview_url URL, hot-link | save locally + ![meaningful alt](./path) |

| Factual claim in a KB doc | prose with no citation, OR inline [src](https://…) | ingest the source (references/ingest-and-sources.md), cite the local path |

| Confirm an edit landed | preview_screenshot / verification loop | trust the CRDT tool response |

| Delete a markdown doc | Bash: rm / native deletion | delete({ document }) (checkpoint() first if risky) |

| Write in an unfamiliar folder | straight to write | exec("ls -A <folder>") first |

Full table: references/anti-patterns.md.

Knowledge layers — the shape most KB work takes

Three recurring practices, not tool calls — each a full procedure that ships as skill guidance.

| Layer | When | Procedure |

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

| ingest | Preserve a shared URL/PDF/file verbatim, or you fetched a URL to ground a claim (binary sources preserved, not scraped). | references/ingest-and-sources.md — ships here, §Grounding depends on it |

| research | Investigate / compare / synthesize sources → status: provisional article + sources:. | /research-with-sources skill |

| consolidate | A decision was made → canonical source-of-truth with a supersedes: chain. | /consolidate-notes skill |

Research and consolidate arrive with ok seed --pack knowledge-base. Without that pack you do not have those procedures — don't improvise one; do the work as an ordinary grounded write, or offer to seed it (ok seed --pack knowledge-base --dry-run shows what it would add).

Don't chain silently: let the user drive ingest → research → consolidate, and a procedure's STOP gates override session-level "don't stop to ask" hints. After any turn that changes KB content, check for a log.md and follow its contract (references/cadence-and-logs.md). Interleave a multi-doc batch so the preview shows narrative progress.

Onboarding a repo that already has content: references/onboard-existing-repo.md. Layer model + packs: references/starter-packs.md.

Capabilities beyond this skill

OK does more than this skill describes, and it changes between releases. Not covered here? Read rather than guess:

Scope recap

OK looks for documents under the resolved content.dir (runtime: config({ key: 'content.dir' })); .gitignore and .okignore (at root or any folder depth) define exclusions. Every .md / .mdx under content.dir not excluded is an OpenKnowledge document — including under specs/, reports/, docs/. Folder metadata + templates live in nested <folder>/.ok/, not in .ok/config.yml. Working in a git worktree? Pass the worktree's absolute path as cwd on your OK tool calls once — it sticks for the session, so reads, writes, and the preview all target that worktree.

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.