Facts in memory often come from a file: a contract, a note, a config. If the file is corrected later and the memory record is not, the agent keeps confidently repeating the old version. The MMW server cannot see your files, so the local agent, mmw-agent, does this check. Every version since 0.1.4 has it, the current one included. Updating the agent explains how to move to the latest version.
On this page:
- how to anchor a fact to a file without computing anything by hand;
- how search notices that the file changed;
- how the Claude Code hooks remind it to save the outcome of its work and load project memory when a session starts.
Anchoring on remember
Section titled “Anchoring on remember”Put the file path in source_id, and that’s it. The agent computes the file’s SHA-256 and sends it as source_hash:
Remember in MMW: the operator is a private individual. Source: site-audit/NOTIFICATION.md{ "content": "the operator is a private individual", "source_id": "site-audit/NOTIFICATION.md", "source_hash": "sha256:5f1c…"}- Paths are resolved against source roots: by default, the folder the client started the agent in (for Claude Code, the project folder). Set your own roots with
MMW_SOURCE_ROOTS(several paths separated by:on Linux and macOS,;on Windows). - Files outside the roots are never read or hashed. An absolute path works too if it is inside a root.
- IDs that do not look like a path (
session:…,https://…,owner-note) are left alone. - If
source_hashis already set, the agent does not change it. - File contents never leave your computer; only the hash is sent.
The check on search
Section titled “The check on search”On every search the agent re-hashes the source files of the records found and adds a local_source field:
local_source | Meaning | status |
|---|---|---|
unchanged | the file is the same as when saved | unchanged |
changed | the file changed after saving | stale |
missing | the file no longer exists | stale |
conflict is the louder status and is never replaced with stale. Records without a source file are left as they are.
Claude Code hooks
Section titled “Claude Code hooks”Since 0.1.12 the agent installs two Claude Code hooks. One reminds Claude to save the outcome of its work, the other loads what memory already knows about the project when a session starts.
Stop hook: do not finish without saving the outcome
Section titled “Stop hook: do not finish without saving the outcome”mmw-agent hook-stop runs when Claude Code is about to end a turn. It reads the session transcript from the end and scores the work done after the last remember call:
- a file edit through Write, Edit or NotebookEdit, in any folder: 2 points;
- a command that changes something: 1 point. Commands that only read (
cat,ls,grep,git status,git logand similar, with no output to a file) score nothing; - an action on a server (
ssh,scp,rsync,sudo,systemctl, a deploy script,curlwith POST, PUT or DELETE): 3 points; - an MCP tool call that does more than read: 1 point.
At 4 points or more (set by MMW_STOP_HOOK_THRESHOLD) the turn does not end. Claude gets the list of recent actions and a request to save the decisions and facts: the file path in source_id, the earlier fact_key for corrections. Secrets in the listed commands are masked.
How it behaves:
- It blocks at most once in a row. If Claude decides there is nothing to save, the second Stop goes through (
stop_hook_active). - It counts only this session’s work. Files that a background agent or a build writes into the same folder do not count when the session itself changed nothing.
- It sees work outside the current folder: edits in other directories, commands on a server, deploys.
- It sends nothing over the network: the check uses the Claude Code transcript and git on your computer.
- It warns about code that exists only on this computer and offers to push it. It pushes only with your permission.
- To turn it off for a while:
MMW_STOP_HOOK=off.
SessionStart hook: project memory at the start of a session
Section titled “SessionStart hook: project memory at the start of a session”mmw-agent hook-session-start runs when a Claude Code session starts, resumes, is cleared or is compacted.
- In a new session it first shows what the previous Claude Code session in the same folder saved: up to 10 latest records. This works in any folder, a home directory included, and needs no server call.
- In a git repository it also searches MMW by the project name and shows up to 8 records: facts with a
fact_keyfirst, then the rest. - After compaction it puts first what Claude saved in this session before compaction: the latest 15 records, one per
fact_key. - Outside a git repository it does not search the server.
- The key comes from
MMW_API_KEYor from the MMW entry in~/.claude.jsonand is never printed. - It never stands in the way of starting work: without a key, without a network, or if the server does not answer within 4 seconds, it quietly skips the step.
- To turn it off:
MMW_SESSION_HOOK=off.
Installing
Section titled “Installing”The one-command install sets up both hooks. By hand:
-
Open
~/.claude/settings.json(all projects) or.claude/settings.jsonin a project. -
Add the hooks:
{"hooks": {"Stop": [{ "hooks": [ { "type": "command","command": "uvx --from https://app.mmwhub.tech/downloads/mmw-agent/mmw_agent-0.1.14-py3-none-any.whl mmw-agent hook-stop" } ] }],"SessionStart": [{ "hooks": [ { "type": "command", "timeout": 30,"command": "uvx --from https://app.mmwhub.tech/downloads/mmw-agent/mmw_agent-0.1.14-py3-none-any.whl mmw-agent hook-session-start" } ] }]}} -
Restart Claude Code.
What it does not do
Section titled “What it does not do”- It does not watch files in the background: a change is noticed on search or at the end of a turn, not when the file is saved.
- It does not fix records by itself: the hook asks the agent to save a new version; the decision stays with the agent and the person.
- It does not check facts saved without
source_id. Always give the source when a fact comes from a file.