Short-term memory: session history
The current conversation is held in aVec<Message> in the cc-query loop. It accumulates user messages, assistant responses, tool use blocks, and tool result blocks as the session progresses.
Sessions are persisted to disk at ~/.claude/conversations/<uuid>.json after each completed turn via cc_core::history::save_session(). The ConversationSession struct carries:
--resume <session-id> on the CLI.
Long-term memory: memdir
Long-term memory is stored as markdown files with YAML frontmatter in a per-project directory:user, feedback, project, and reference. The type field controls how the memory is scoped in combined (personal + team) mode.
The MEMORY.md entrypoint index is always loaded into the system prompt. It is kept under 200 lines / ~25 KB by the AutoDream pruning phase.
Memory scanning
Before each query, Claurst scans the memory directory:scanMemoryFiles()reads the frontmatter of every.mdfile (first 30 lines only) to build aMemoryHeader[]manifest without loading full content.- The manifest is passed to a side-query (
selectRelevantMemories()) using a Sonnet model call with max 256 tokens. It returns up to 5 filenames that are clearly relevant to the current query. - The selected files are read in full and injected into the context. Memories older than 1 day include a
<system-reminder>freshness caveat warning that citations may be outdated.
AutoDream consolidation
AutoDream is a background memory consolidation process. It runs as a forked sub-agent and performs a reflective pass over the memory files to synthesise recent signal into durable, well-organised memories.AutoDream uses a three-gate trigger to prevent both over-dreaming and under-dreaming. All three gates must pass before a dream run begins:
- Time gate — at least 24 hours have elapsed since the last dream.
- Session gate — at least 5 sessions have occurred since the last dream.
- Lock gate — a consolidation lock can be acquired (prevents concurrent dreams).
The four dream phases
Orient
The dream agent runs
ls on the memory directory, reads MEMORY.md, and skims existing topic files to understand the current state of memory before making any changes.Gather recent signal
The agent searches for new information worth persisting. Sources are checked in priority order: daily logs (KAIROS mode) → drifted memories → transcript search. Relative dates are noted for later conversion to absolute dates.
Consolidate
The agent writes new memory files or updates existing ones. It converts relative date references to absolute dates, deletes facts that have been contradicted, and merges redundant entries.
“You are performing a dream — a reflective pass over your memory files. Synthesize what you’ve learned recently into durable, well-organized memories so that future sessions can orient quickly.”
The dream sub-agent is given read-only bash access. It can observe the project (run
ls, git log, grep) but cannot modify source files. Memory consolidation is the only write operation it performs, and it is confined to the memory directory.Memory index constraints
TheMEMORY.md entrypoint is kept within strict limits by the prune phase:
| Constraint | Limit |
|---|---|
| Maximum lines | 200 |
| Maximum bytes | ~25 KB (25,000 bytes) |
truncateEntrypointContent() line-truncates first, then byte-truncates at the last newline before the cap. A warning is appended naming which cap fired.
What not to store in memory
The memory system is designed for information that is not derivable from the codebase itself. The following should not be saved as memories:- Code patterns, architecture, or file structure (read the code directly)
- Git history or recent changes (use
git log) - Debugging solutions or fix recipes (the fix is in the code)
- Anything already in
CLAUDE.md - Ephemeral task details or in-progress work