Skip to content

Latest commit

 

History

History
10 lines (8 loc) · 2.53 KB

memory.md

File metadata and controls

10 lines (8 loc) · 2.53 KB

Persistent memory

Per-repository memories with a session-injected index. Source: extensions/memory.ts.

  • Memories live under memory/ in pi's agent directory (~/.pi/agent, relocated by PI_CODING_AGENT_DIR), keyed on the repository root, so subdirectory sessions and every worktree of one repository share a store (as Claude does; this is pi's own store, separate from Claude's).
  • The index is injected each session within Claude's 200-line/25KB bound; YAML frontmatter and block HTML comments are stripped before it counts or loads.
  • A save landing near the index read limit reminds Claude to shorten it; over the limit the write still succeeds and an error tells Claude to rewrite the index, per Claude's contract. A memory written with frontmatter gets a modified: ISO timestamp; the tool asks for Claude's documented type vocabulary (user/feedback/project/reference).
  • Honors autoMemoryEnabled (settings) and CLAUDE_CODE_DISABLE_AUTO_MEMORY (env) to turn it off, and autoMemoryDirectory (absolute or ~/) to relocate the store; managed policy settings win over the file chain.
  • autoMemoryStorage: "claude" (user settings, project settings once the project is approved, or managed settings) selects the store Claude Code itself keeps, <claude config>/projects/<project>/memory/, read and written in place, so both tools share one set of memories. The directory is derived as Claude Code derives it (claudeMemoryDir), including CLAUDE_CONFIG_DIR, CLAUDE_CODE_REMOTE_MEMORY_DIR and CLAUDE_CODE_PROJECT_DIR_NAME. A save from pi keeps the index in Claude's shape and gives a new file the name and description frontmatter Claude reads; the type is written under metadata only when the saved content carries a type: field. Known differences: originSessionId is not written, a save replaces the whole file, and CLAUDE_COWORK_MEMORY_PATH_OVERRIDE is not read. An explicit autoMemoryDirectory wins over the storage mode, and nothing is moved or merged when the mode changes.
  • /memory prints the store, index, and every documented memory-file location (user and project CLAUDE.md, CLAUDE.local.md, the .claude/CLAUDE.md alternate), including files that do not exist yet. /memory edit picks one of them and opens it in your editor, the one pi's own external editor uses (its externalEditor setting, then VISUAL, then EDITOR), with the terminal handed over; the editor writes the file itself, so its bytes are never normalised. A symlinked file is listed with its real target. It needs the interactive UI.