Skip to content

fix(prompt): write memories in Claude Code's current frontmatter format - #54

Merged
kuitos merged 1 commit into
fix/memory-edit-guardrailsfrom
fix/claude-code-frontmatter-format
Oct 7, 2026
Merged

kuitos merged 1 commit into
fix/memory-edit-guardrailsfrom
fix/claude-code-frontmatter-format

Conversation

@kuitos

@kuitos kuitos commented Oct 7, 2026 •

Copy link
Copy Markdown
Owner

Problem

#47: memories the main agent wrote did not match Claude Code's current format.

before Claude Code 2.1.289
name: a title (No autouse pytest fixtures) a kebab-case slug, normally the file name
type: top level under metadata:
file name snake_case kebab-case

In the report, all 12 files the main agent wrote used the old shape. The prompts taught it:

  • FRONTMATTER_EXAMPLE (name: {{memory name}}, top-level type:);
  • the user_role.md / feedback_testing.md examples;
  • name: short title and snake_case file names in the extraction prompt;
  • "Human-readable name" and "Use snake_case" in memory_save's args;
  • the README example.

A memory folder shared with Claude Code ended up holding two formats.

Fix

  • Every prompt, the memory_save arg descriptions and the README now show the current format: a kebab-case slug name, metadata:\n type:, and kebab-case file names. The examples are user-role.md and no-db-mocks-in-tests.md.
  • name is not forced to equal the file name; real Claude Code files differ.
  • A slug makes a poor index title, so memory_save gains an optional title for the MEMORY.md line, defaulting to name. It names a new line or a line the plugin generated, never a hand-written one (fix(store): keep hand-written MEMORY.md index lines #51).
  • The main-agent prompt says memory_save does both steps (file and index line), so the agent should not edit MEMORY.md itself afterwards. If it ever edits the index by hand, it changes one line and never rewrites the file. See the verification below for why.
  • Old files are read as before and are not migrated.
  • AGENTS.md notes the format.

Tests

  • test/prompt.test.ts:
    • main and extraction prompts teach the slug and metadata.type, and the old shapes are gone;
    • the main agent leaves MEMORY.md to memory_save.
  • test/store/MemoryStore.test.ts:
    • a title names a new index line while the file keeps the slug;
    • a titled generated line follows a new description;
    • a title retitles a line generated from the name;
    • a title never replaces a hand-written line.
  • test/tools.test.ts: memory_save writes a slug name and metadata.type and titles the index line with title, falling back to name.
  • bun run lint, bun run typecheck, bun test and bun run build pass.

Real-environment verification (OpenCode 2.0.22, isolated DB/config, memory agents on opencode/gpt-6-luna)

Format: in the extraction and fact-statement scenarios (the ones that create memories), every new memory file used a kebab-case slug name and metadata.type, 20/20. That covers extraction forks and memory_save calls from big-pickle and gpt-6-luna main agents. Forks passed a readable title (e.g. [Billing database](billing-postgres.md)).

Main agent editing MEMORY.md itself (big-pickle, after memory_save had already written the index line):

  • Before the "do not edit MEMORY.md yourself" sentence, 3 of the 6 inspected runs:
    • one overwrote the whole file with write, dropping a hand-written line;
    • one edit appended a duplicate line;
    • one more edit touched the index.
  • After it: 0/3, with the hand-written line kept each time.
  • Small sample, and the model's own file tools remain outside the plugin's control.

Refs #47

🤖 Generated with Claude Code

@kuitos
kuitos added this pull request to stack #55 October 7, 2026 14:53
@kuitos
kuitos force-pushed the fix/claude-code-frontmatter-format branch 3 times, most recently from 966c574 to ddfe6ff Compare October 7, 2026 15:23
The prompts taught the old format: `name: {{memory name}}` and a top-level
`type:` in FRONTMATTER_EXAMPLE, `user_role.md` / `feedback_testing.md`
examples, `name: short title` and snake_case file names in the extraction
prompt, "Human-readable name" and "Use snake_case" in memory_save's args,
and the same in the README. In #47 all 12 files the main agent wrote used
a title as `name` and a top-level `type`, while Claude Code writes a
kebab-case slug and `metadata.type`, so a shared folder ended up with two
formats.

Every prompt, the memory_save arg descriptions and the README now show the
current format (kebab-case slug `name`, `metadata:\n  type:`) with
kebab-case file names. `name` is not forced to equal the file name (real
Claude Code files differ). memory_save gains an optional `title` for the
MEMORY.md line, since the slug makes a poor title; it only names a new
line or one the plugin generated, never a hand-written one. Old files are
read as before and not migrated.

Refs #47
@kuitos
kuitos force-pushed the fix/claude-code-frontmatter-format branch from ddfe6ff to c62f2ec Compare October 7, 2026 15:33
@kuitos
kuitos marked this pull request as ready for review October 7, 2026 15:35
@kuitos
kuitos merged commit 0917399 into main Oct 7, 2026
6 checks passed
@kuitos
kuitos deleted the fix/claude-code-frontmatter-format branch October 7, 2026 15:35
@github-actions

github-actions Bot commented Oct 7, 2026

Copy link
Copy Markdown

🎉 This PR is included in version 2.1.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant