The full upstream README, mirrored here for reference. Install config, tool schemas, adoption signals, and an original overview live on the Kg listing page.
Beta - APIs may still change and some bugs are still expected.
kg gives your AI assistant persistent, structured, editable project memory stored locally as a knowledge graph.
Instead of relying only on document chunk retrieval, you can keep architecture, decisions, incidents, rules, dependencies, and workflows in a graph that is readable, reviewable, and Git-friendly.
Use it when you want your assistant to understand an existing project across sessions — not start from zero every time.
*.kg files with readable diffsClassic RAG is good for retrieving text chunks from documents.
kg-mcp is better when you want:
Recommended install:
You can also download a ready binary from GitHub Releases.
kg-mcp to Your AI ClientAdd kg-mcp as a local stdio MCP server.
Example config:
After that:
kg MCP server is available,Full MCP setup and reference: docs/mcp.md
kg understands short, verb-first English commands (SCL — Simple Command Language).
The active graph is resolved from your config automatically.
| Verb | What it does |
|---|---|
find <query> | search nodes by text |
get <id> | fetch one node by id |
add <id> --name "Name" | create a node (type inferred from id prefix) |
modify <id> --field value | update node fields |
remove <id> | delete a node |
connect <src> <REL> <dst> | create an edge (alias: add edge) |
disconnect <src> <REL> <dst> | delete an edge (alias: remove edge) |
list nodes|edges|types|relations|graphs | list graph contents |
stats | show graph statistics |
use <graph> | switch active graph |
help [verb] | get help for a verb or all |
feedback <uid> yes|no|nil|pick <n> | give feedback on search results |
strict | disable defaults for following lines |
Format: <type>:snake_case — e.g. concept:fridge, bug:door_seal, process:compressor_cycle.
HAS USES STORED_IN TRIGGERS CREATED_BY AFFECTED_BY AVAILABLE_IN DOCUMENTED_IN DEPENDS_ON TRANSITIONS DECIDED_BY GOVERNED_BY READS_FROM
; or newlines. Lines starting with # are comments.use <graph> to switch graphs within a script.kg <graph> node find ... commands still work as fallback.docs/scl.mdThis is the first workflow for a new project: ask the assistant to create or extend a graph from your documentation.
By default, graphs are stored in ~/.kg/graphs as *.kg files.
Minimal prompt:
Example prompt with documents:
Longer prompt for this workflow: docs/ai-prompt-graph-from-docs.md
For a ready-made repository example, run cargo run --bin repo-example to generate repo-example.kg from this repo.
kg can turn an existing folder into a graph automatically. It scans the directory tree, recognizes many common file types, extracts symbols for Rust, Java, JavaScript/TypeScript, Python, and C/C++, and keeps the generated structure separate from the manual graph.
For markdown-like documents, it also creates document (GDOC) and chapter (GSEC) nodes with section content.
It is a fast way to get a useful map of a codebase or workspace without modeling everything by hand. The generated index is local, refreshable, and safe to ignore in git.
Example:
This generates repo-example.kg from this repository as a local demo.
Once the graph exists, the normal workflow is to ask the assistant to inspect it and answer questions from it.
Example prompt:
Other useful questions:
payments graph?"You can also ask the assistant to improve the graph while you work.
Example prompt:
This works best when your main system prompt or project prompt already tells the assistant which graph belongs to the project.
Minimal project-level prompt:
.kg.toml)kg looks for .kg.toml in the current directory and its parent directories.
Example:
Notes:
backend = "json" is the default and prefers .kg text graphs.backend = "redb" stores graphs in .db files.graph_dir sets a primary graph directory.graph_dirs adds extra directories scanned by kg list and graph resolution.The default graph directory is ~/.kg/graphs.
You can put that directory under git.
Recommended approach:
*.kg graph files in git,Suggested .gitignore:
In practice:
*.kg is the main graph file you usually want to review and commit,*.kglog is a local access/feedback log,*.kgindex is a generated local index,*.event.log is a local append-only change timeline,*.bak is the previous on-disk version from the last write,*.bck.*.gz are periodic compressed backup snapshots,*.migration.log is a migration report when older graphs are converted.*.kg is git-friendly and intentionally structured to make diffs readable and merges easier when several people work on the same graph.
To generate an interactive HTML view of a graph:
You can keep the generated HTML as a shareable visual snapshot of the current graph.
docs/mcp.md - MCP setup and tool referencedocs/ai-prompt-graph-from-docs.md - longer prompt for document ingestiondocs/build-graph-from-docs.md - graph-building workflow from docsdocs/troubleshooting.md - common issuesFor questions or feedback: nnar10@proton.me