Auto memory: option to keep custom top-level frontmatter keys (e.g. Open Knowledge Format)
What happens
In the auto-memory directory, the Edit and Write tools rewrite YAML frontmatter inside the tool call:
- Every top-level key except
nameanddescriptionis moved undermetadata:. metadata.typeoverrides a top-leveltype.node_type,originSessionIdandmodifiedare added.
Files written with Bash, or outside the auto-memory directory, are not touched.
This was reported in #61099 (closed as not planned) and #80328 (closed as duplicate). In #61099 the behaviour was confirmed as intentional, and documenting the format was mentioned.
Why it matters
We keep auto memory in a git repository (autoMemoryDirectory) that other agents and a company knowledge base also read. The files use the Open Knowledge Format (OKF v0.2, github.com/GoogleCloudPlatform/open-knowledge-format), which needs type, title, sources and so on at the top level. Every Edit or Write breaks that.
Workaround today
A PostToolUse hook on Edit|Write moves the keys back right after each call. It works, but Claude's copy of the file then differs from the disk, so the next Edit must re-read the file.
Request
- A setting to keep unknown top-level keys where they are, e.g.
"autoMemoryFrontmatter": "preserve", or a list of keys to keep at the top level. - Or: only add Claude Code's own keys and leave all other keys untouched.
- Either way: document the memory file format.
Environment: Claude Code 2.1.289 (desktop app, Code tab), macOS.