Context documents
Use the khotan CLI to operate Khotan context documents. Add --json for machine-readable output; results go to stdout, diagnostics to stderr.
Commands
khotan context create
Usage: khotan context create --title <string> --kind <string> --content <string> [--slug <string>] [--description <string>] [--tags <a,b>] [--properties <json>] [--folder-id <string>]
Create a markdown context document.
Arguments & options:
--title— Document title. (required, body)--kind— instructions, knowledge, or record. (required, body)--content— Canonical markdown content. (required, body)--slug— Optional slug; derived from the title when omitted. (optional, body)--description— One-line purpose statement. (optional, body)--tags— Flat tag list. (optional, body)--properties— Structured facts beside the markdown: any JSON object, up to 50 KB. Example: '{"owner":"platform"}'. (optional, body)--folder-id— Folder placement; omit for the organization root. (optional, body)
khotan context delete
Usage: khotan context delete <slug>
Soft-delete a context document.
Arguments & options:
<slug>— The document slug. (required, path)
Safety: destructive — prompts for confirmation in a terminal and refuses in non-interactive sessions unless you pass --yes.
khotan context folders create
Usage: khotan context folders create --name <string> [--parent-id <string>]
Create a folder under an optional parent (omit parentId for the organization root).
Arguments & options:
--name— The folder name; must be unique among active siblings. (required, body)--parent-id— Parent folder id; omit for the organization root. (optional, body)
khotan context folders delete
Usage: khotan context folders delete <id> [--recursive]
Soft-delete a folder. A non-empty folder requires --recursive, which also soft-deletes its subfolders and documents.
Arguments & options:
<id>— The folder id. (required, path)--recursive— Delete a non-empty folder and all of its contents. (optional, query)
Safety: destructive — prompts for confirmation in a terminal and refuses in non-interactive sessions unless you pass --yes.
khotan context folders list
Usage: khotan context folders list
List the organization's context folders as a flat list, each carrying parentId, path, depth, and its direct active-document count.
khotan context folders update
Usage: khotan context folders update <id> [--name <string>] [--parent-id <string>]
Rename a folder (name) and/or move it under a new parent (parentId).
Arguments & options:
<id>— The folder id. (required, path)--name— New folder name. (optional, body)--parent-id— New parent folder id. (Sending null to move to the root is not reachable via CLI flags.) (optional, body)
khotan context get
Usage: khotan context get <slug>
Get a context document including its markdown content, properties, and links, in a JSON envelope.
Arguments & options:
<slug>— The document slug. (required, path)
khotan context links list
Usage: khotan context links list <slug>
List the projects and resources a document links to, each with its current name. A deleted target shows removed: true.
Arguments & options:
<slug>— The document slug. (required, path)
khotan context links set
Usage: khotan context links set <slug> --links <json>
Replace a document's complete link set. Links not listed are removed, and every new target must be live in the organization.
Arguments & options:
<slug>— The document slug. (required, path)--links— The complete link set as a JSON array of { type, id }. Types: project, deployment, pipeline, postgres, redis, turso, r2. Example: '[{"type":"project","id":"..."}]'. Pass '[]' to remove all links. (required, body)
khotan context list
Usage: khotan context list [--kind <string>] [--q <string>]
List the context document manifest (metadata only, never content).
Arguments & options:
--kind— Filter by kind: instructions, knowledge, or record. (optional, query)--q— Full-text search query. (optional, query)
khotan context raw
Usage: khotan context raw <slug>
Get exactly the document's markdown text, with no JSON envelope.
Arguments & options:
<slug>— The document slug. (required, path)
khotan context revisions get
Usage: khotan context revisions get <slug> <revision>
Get a single captured revision including its markdown snapshot and properties.
Arguments & options:
<slug>— The document slug. (required, path)<revision>— The revision number. (required, path)
khotan context revisions list
Usage: khotan context revisions list <slug>
List a document's revision history, newest first (metadata only, never snapshot content).
Arguments & options:
<slug>— The document slug. (required, path)
khotan context revisions restore
Usage: khotan context revisions restore <slug> <revision>
Restore a document to an earlier revision by writing a new forward revision matching that snapshot (history is never rewritten).
Arguments & options:
<slug>— The document slug. (required, path)<revision>— The revision number to restore. (required, path)
khotan context search
Usage: khotan context search --q <string> [--k <number>] [--kind <string>]
Hybrid semantic + full-text search; returns ranked passages with their source slug.
Arguments & options:
--q— Natural-language search query. (required, query)--k— Maximum number of snippets to return (1-50). (optional, query)--kind— Filter by kind: instructions, knowledge, or record. (optional, query)
khotan context update
Usage: khotan context update <slug> --expected-revision <number> [--title <string>] [--kind <string>] [--content <string>] [--description <string>] [--tags <a,b>] [--properties <json>] [--folder-id <string>] [--change-summary <string>]
Update a context document with compare-and-swap on expectedRevision.
Arguments & options:
<slug>— The document slug. (required, path)--expected-revision— Revision this edit is based on; a mismatch returns 409. (required, body)--title— New title. (optional, body)--kind— New kind. (optional, body)--content— New markdown content. (optional, body)--description— New description (null clears it). (optional, body)--tags— New tag list. (optional, body)--properties— New properties as a JSON object. This replaces the whole object; omit it to keep the current properties. (optional, body)--folder-id— Move the document to this folder; omit to leave unchanged. (Sending null to move to the root is not reachable via CLI flags.) (optional, body)--change-summary— Optional revision-history note. (optional, body)