Tasks
Set up automatic maintenance
For knowmind to grow valuable over time, the AI has to query it regularly and write new insights back. This guide shows three levers — from a fully automatic default with no setup to a hard guarantee via hooks.
Prerequisites
- knowmind connected as an MCP server (see your client's integration guide)
- For lever 2 (knowmind init): knowmind CLI installed and logged in, Node.js 20 or newer
- For lever 2 with Claude Code: a project folder with .claude/ (created if absent)
The three levers
| Lever | Setup | Effect |
|---|---|---|
| MCP instructions | none — works automatically | Universal across every MCP client. Soft: the model follows the instruction, it is not enforced. |
knowmind init | one command per project | Hard, but only in clients with a hook mechanism (e.g. Claude Code). Enforces recall and prompts for saving. |
| MCP prompts | none — available as slash commands | Manual: you invoke them when needed (e.g. /knowmind status). |
Steps
- 1
Lever 1: MCP instructions — no setup
As soon as your client connects to the knowmind MCP server, the server sends an instructions field during the handshake (
initialize). The client places that text into the model's system context. It contains the memory-first rule: recall first withknowmind_recall, then answer, and save new insights withknowmind_store_memory.This is fully automatic. You configure nothing. The knowmind CLI proxy (variant A of the Claude Code integration) also passes the server's instructions through to the client.
Outcome: In every new conversation the model takes the rule into account — it calls
knowmind_recallmore often on its own for factual questions and offers to store insights. - 2
Lever 2: knowmind init — hard hooks per project
In clients with a hook mechanism — Claude Code first and foremost — a single command sets up maintenance as a binding rule:
bash# Run inside the project folder knowmind init # Preview what would happen without writing anything knowmind init --dry-run # Choose the client explicitly (otherwise auto-detected) knowmind init --client claude-codeThe command detects the client and creates:
- Claude Code: a UserPromptSubmit hook (calls
knowmind_recallbefore real questions and injects the hits) and a Stop hook (reminds you to save when the turn contained something worth keeping), both registered in.claude/settings.json; plus a memory-first block inCLAUDE.md. - Cursor: a rule
.cursor/rules/knowmind.mdcwithalwaysApply. - Generic / Claude Desktop / Codex: prints the memory-first block for manual insertion (no hook mechanism available).
The command is idempotent (a second run creates no duplicates; inserted blocks carry
BEGIN/ENDmarkers) and non-destructive (foreign files without a knowmind marker are never overwritten).Outcome:
knowmind initlists every action with a symbol (+new,~changed,=unchanged,!skipped). After restarting the client the hooks take effect. - Claude Code: a UserPromptSubmit hook (calls
- 3
Lever 3: MCP prompts as slash commands
The knowmind MCP server provides predefined prompts that appear as slash commands in your client — in Claude Code, for example, as
/mcp__knowmind__recall. Invoke them manually to trigger a maintenance action on demand:status— health check plus corpus statistics for the workspace.recall— hybrid recall: pulls the best matches for a question before you continue.store— creates a new memory (title + content).relations— lists the relationships of a memory in the knowledge graph.recall_at_time— point-in-time recall: what did the workspace know on a given date?
Outcome: The prompts show up in your client's slash-command or prompt picker and trigger the matching tool call.
Honest limit: what can be hard-enforced and what cannot
Verify the result
Automatic maintenance is working when:
- A factual question in the chat leads to a visible
knowmind_recallcall without you asking for it. - After a turn with new insights, the AI offers to save them — or does so when prompted by the gate if the Stop hook is active.
- For Claude Code:
knowmind initcreated two hook entries in.claude/settings.json, and.claude/hooks/containsknowmind_recall.mjsandknowmind_capture.mjs. knowmind statsshows a rising memory count over time.
Troubleshooting
| Error message | Cause | Resolution |
|---|---|---|
| AI does not call knowmind_recall on its own | Instructions are soft; the model judges relevance per turn. With some models/clients the rule fires less often. | Set up the hard hook with knowmind init (lever 2) if the client supports it. Otherwise ask explicitly: “Search knowmind first for …”. |
| knowmind init: file exists without knowmind marker | A target file (e.g. your own hook script) already exists but carries no knowmind marker. It is not overwritten for safety. | The message is expected behavior. Add the knowmind entry manually if needed, or rename the foreign file and run knowmind init again. |
| settings.json is not valid JSON | The existing .claude/settings.json cannot be parsed — init leaves it untouched. | Fix the JSON error in .claude/settings.json, then run knowmind init again. |
| Hooks do not take effect after knowmind init | The client loads hooks only at startup. | Restart the AI client. For Claude Code, start a new session. |