Auto memory: option to keep custom top-level frontmatter keys (e.g. Open Knowledge Format)

Status Open
Reported on v2.1.289
Maintainer reply None cached
Activity 0 comments · opened Oct 8, 2026

What happens

In the auto-memory directory, the Edit and Write tools rewrite YAML frontmatter inside the tool call:

  • Every top-level key except name and description is moved under metadata:.
  • metadata.type overrides a top-level type.
  • node_type, originSessionId and modified are 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

  1. 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.
  2. Or: only add Claude Code's own keys and leave all other keys untouched.
  3. Either way: document the memory file format.

Environment: Claude Code 2.1.289 (desktop app, Code tab), macOS.

View original on GitHub ↗