Memory consolidation for Claude Code. Scans session transcripts for corrections, decisions, preferences, and patterns, then merges findings into persistent memory files. Inspired by how sleep consolidates human memory.
Consolidates scattered auto-memory notes into a clean, organized knowledge base by scanning recent session transcripts for corrections, decisions, preferences, and patterns.
Run manually with /dream. Auto-triggers every 24 hours via the Stop hook managed by otto-workbench sync.
Dream runs 4 sequential phases. Execute them in order. Do not skip phases.
ORIENT --> GATHER SIGNAL --> CONSOLIDATE --> PRUNE & INDEX
Goal: Understand the current state of memory before changing anything.
ls -d ~/.claude/projects/*/memory/ 2>/dev/null
Read MEMORY.md in each project's memory directory. Note:
Read each topic file to understand what's already stored.
A mental map of which projects have memory, what topics are covered, how large the files are, and what's potentially stale or contradictory.
Goal: Extract important information from recent sessions using targeted grep.
find ~/.claude/projects/*/sessions/ -name "*.jsonl" -mtime -7 2>/dev/null | sort -t/ -k6 -r
User corrections (highest priority):
grep -il "actually\|no,\|wrong\|incorrect\|not right\|stop doing\|don't do\|I said\|I meant\|that's not\|correction" ~/.claude/projects/*/sessions/*.jsonl 2>/dev/null
Preferences and configuration:
grep -il "I prefer\|always use\|never use\|I like\|I don't like\|I want\|from now on\|going forward\|remember that\|keep in mind\|make sure to\|default to" ~/.claude/projects/*/sessions/*.jsonl 2>/dev/null
Important decisions:
grep -il "let's go with\|I decided\|we're using\|the plan is\|switch to\|move to\|chosen\|picked\|decision\|we agreed" ~/.claude/projects/*/sessions/*.jsonl 2>/dev/null
Recurring patterns:
grep -il "again\|every time\|keep forgetting\|as usual\|same as before\|like last time\|we always\|the usual" ~/.claude/projects/*/sessions/*.jsonl 2>/dev/null
For each file that matches, read ONLY the surrounding context of the match. JSONL files have one JSON object per line. Focus on lines where type is "human" (user messages) and the immediately following "assistant" response.
For each finding, note:
Goal: Merge new findings into existing memory.
Never duplicate. Check if it already exists. If it does, update the existing entry.
Convert relative dates to absolute. "Yesterday" in a session from March 15 becomes "2026-03-14". Never store relative dates.
Delete contradicted facts. If memory says "Prefers tabs" but a recent session says "Use spaces", remove the old entry and write the new one. Add a note: (Updated YYYY-MM-DD, previously: tabs).
Preserve source attribution. Note where each new entry came from: (from session YYYY-MM-DD).
Topic file organization. Group related memories:
preferences.md — How the user likes things donedecisions.md — Choices and their rationalecorrections.md — Things the user correctedpatterns.md — Recurring workflows, common tasksfacts.md — Project-specific knowledge, architecture notesEntry format. Each memory entry should be concise:
- [YYYY-MM-DD] The fact or preference. (source: session, confidence: high/medium)
Goal: Keep MEMORY.md lean. Remove stale content. Enforce size limits.
MEMORY.md is an index file, not a content store:
Remove or archive entries that are:
~/.claude/projects/After completing all 4 phases:
date +%s > ~/.claude/projects/<project>/memory/.last-dream
rm -f ~/.claude/.dream-pending
cp -r ~/.claude/projects/<project>/memory/ ~/.claude/projects/<project>/memory-backup-$(date +%Y%m%d)/
After running, verify:
wc -l on MEMORY.md — should be under 200 lines