No slash command · from knowledge-graph
Manages a persistent knowledge graph for Claude Code sessions, enabling recall, search, and capture of lessons across conversations. Loads preloaded memory on session start and supports reading, searching, and endorsing nodes.
Ships in knowledge-graph. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
The preload block is a compact core — the top-scored slice of both graphs, not
the whole. The one full kg_read(session_id) renders everything it dropped
without repeating what is already shown (preloaded gists collapse to id-only
anchors). A long read arrives in parts: follow each with
kg_read(session_id, more=true) to the end. The session_id from the preload — or from the first kg_read — goes on
every later kg_* call: it keeps one session, includes the project graph in
searches, and avoids minting spurious sessions.
No preload block (Desktop sessions, server still warming up):
kg_read(cwd="<project root>") returns the full graph plus your session_id.
With no project folder (a general chat), kg_read() opens user memory alone;
passing cwd with that session_id later attaches the project.
The tools start the server themselves and wait out restarts, so a kg tool
that keeps failing to connect means a start that fails — a /kg-ops matter
(kg doctor).
Resuming an earlier conversation: kg_sync(session_id) picks up what other
sessions wrote meanwhile.
After the full read, scan gists for anything touching the task and read those
nodes in depth — several per call: kg_read(session_id, ids=[...]). Lean
toward reading more: a wrong guess costs one call, missing context costs the
task. Node reads return the node's own edges — each a crumb to the next hop —
and reading an archived node promotes it and surfaces its orphaned neighbours.
Three tiers as a graph grows: active (id + gist on the surface), archived (id + edges as crumb trails), orphaned (invisible — only search reaches them).
What kg_read renders is the surface of the graph, not its extent. A young, sparse graph has little beneath — searching it rarely pays. But a graph grown through months of work holds far more than any render shows, and the fact you need now is often exactly the one buried under fresher nodes. That is not a defect — it is how a living memory works — and kg_search is the instrument built for it, reaching all tiers at once.
So before asserting an assumption, before re-deriving from files, when the work enters territory this project has plausibly visited before: search first. The cost is one call. And retrieval is only half the value: a node you had to dig for is a node the surface should have shown you. Say so with kg_useful — being found feeds nothing by itself. A graph that is only ever written to silts up; one that is searched, and that reports its misses, keeps its most-needed facts on top.
Capture mid-conversation, at the moment of learning — a write costs almost nothing now and saves a full re-derivation later. Worth capturing: whatever took effort to obtain (how the project is wired, how the thing work, project how tos, decisions and their rationale, preferences and constraints, where is what), and whatever gives future sessions navigation — a component node for files you explored: what the cluster handles and what it does not.
Placement is the craft:
a-401-in-a-log-is-an-event-not-a-state is a gist wearing
an id's clothes; the subject was auth-401-is-an-event. This is not
tidiness: search weights the id ×3 and matches it for the recall gate, so
every extra word is another token that can drag the node into an unrelated
prompt. Seven words or more is refused at the write boundary.ambient-recall-audit, update it as each audit lands, and let its
touches point at the current handover doc. The document's own filename
carries the date, which is where a date is actually useful.path:line-range (short anchor) — so the
next session reads ten lines instead of the file.kg_rename_node — it carries the
edges, the history and the cross-level references. Writing a new node and
deleting the old one is not a rename; it is a quiet amputation.Documents point INTO memory, never the other way round. A letter, a handover
or a README naming a node id is a stationary artifact taking a dependency on a
moving one: memory keeps evolving — nodes get renamed, merged, archived — and
the doc silently rots. Write what the doc means in its own words, and let the
node carry the doc's path in touches. That direction survives both.
Other memory systems (CLAUDE.md, auto-memory) are supplementary — their exclusion rules govern their own storage. When in doubt, record here.
kg_useful(session_id, ids=[...]) is the only input that keeps a node alive:
archival scoring counts endorsements, and nothing else an agent does — not
reading, not searching, not citing — feeds that signal. One vote per node.
Five per session is guidance, not a quota. It is set where it is because endorsement that costs nothing means nothing, and a number you have to spend carefully is what keeps this from becoming traffic. But it is the wrong number often enough — a session that gets corrected three times in a row has three real misses to report before it has praised a single hit — and a refusal there would destroy exactly the evidence the signal exists to carry. So keep sending when each one genuinely earned it; the reply tells you how far past the guidance you are, and only a flood hits the hard cap.
Two different things earn it.
It helped. The node was on the surface, you used it, and the work went differently for it. Judge these at wrap-up, against actual results — what looked promising mid-flight and led nowhere is not an endorsement.
It was missing. The node existed, this session needed it, and nothing put it in front of you: you re-derived what the graph already held, took a wrong turn it would have prevented, or the user had to say it themselves. Send this one the moment the gap is established, not at wrap-up — the correction in front of you is the evidence, and a session that ends abruptly still records it. Late feedback counts too: if it only becomes clear afterwards that a node belonged in this conversation, that is still a miss, and saying so then is worth more than staying silent because the moment passed.
The asymmetry between the two is the point. A hit confirms a decision the scorer already made right; a miss is the only evidence that ever reaches it about one it got wrong. Without it the loop is one-sided — nodes that surface earn credit and stay up, while a node archived too early has no way to report the sessions it should have been in, and sinks further with each one. Whenever you are rationing — choosing what the guidance is worth spending on — a miss outranks a hit.
An endorsement alone does not put a node back on the surface. Read it in full
as well — kg_read(session_id, ids=[...]) promotes it out of archived or
orphaned — and let the endorsement be what stops it sinking again on the next
pass. If it was stale as well as absent, sharpen the gist while the context is
live: being right and being reachable are separate problems.
user — cross-project wisdom: preferences, principles, patterns that travel. project — this codebase and its operations: architecture, decisions, component nodes, discoveries.
Subagents receive no preload. The dispatching session sizes memory into each prompt: exploration and mining agents get kg_* instructions plus the session_id; ordinary task agents get the few relevant gists pasted; narrow mechanical tasks get nothing.
Server lifecycle, reconnect after restart, backup, troubleshooting — the /kg-ops runbook covers it; don't improvise server management from here.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
knowledge-graph, memory, session-persistence, lesson-capture
Other plugins' skills for the same job
5 skills in this plugin
/kg-extractMap codebase architecture into the knowledge graph/kg-maintainKnowledge graph maintenance — a bounded, resumable pass that pays down the
graph's DEBT line (rendered after HEALTH in every kg_read). Run it when
invoked, when DEBT shows HIGH, or as a dispatched maintenance subagent.
The same work also arrives in a smaller shape: a CHORE, one category and
one or two named targets, dispatched by the server while someone is
working. Chores carry their own runbook in their prompt — this skill is
the full pass, and the place the chore memory is described.
Always-on reactive triggers (no pass needed, act mid-conversation):
User correction → update the stale node before continuing.
Node just proved useful → add one edge to current context.
Gist feels vague after using it → sharpen while context is live.
Just saved a node → check: duplicate? adjacent nodes need updating?
Archival is automatic and reversible — leave archived nodes alone.
Deletion is a last resort, only for the factually wrong and unfixable.
/kg-opsOperations runbook for kg-memory, the `kg` command and its plugins: install
and first run (kg setup, kg doctor), updates (kg update), server lifecycle
(kg start/stop/restart/logs), autostart via systemd, connecting Claude
Desktop/Cowork, Codex CLI, Antigravity, maintenance chores and
their runner, configuration, the quota-gauge
status line (reading your own 5h/7d limits), backup and restore, and
troubleshooting (tools offline, -32000 errors, stale data, Desktop issues).
Use when something needs setting up, breaks, or the user asks to manage the
memory server or "read the docs and do what's needed".
/kg-scoutMine Claude Code, Codex and Antigravity conversation history for patterns and insights worth preservingnpx claudepluginhub mironmax/kg-memory --plugin knowledge-graph