Dream: Memory Consolidation
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.
Environment
- Memory directory: !
echo "${CLAUDE_MEMORY_DIR:-$HOME/.claude/projects/$(pwd | sed 's|/|-|g')/memory}"
- Session transcripts: !
echo "${CLAUDE_PROJECT_DIR:-$HOME/.claude/projects/$(pwd | sed 's|/|-|g')}" (JSONL files — each file is one past session)
Phase 1 — Orient
ls the memory directory to see what already exists
- Read
MEMORY.md to understand the current index
- Skim existing topic files so you improve them rather than creating duplicates
- If
logs/ or sessions/ subdirectories exist (assistant-mode layout), review recent entries there
Phase 2 — Gather recent signal
Look for new information worth persisting. Sources in rough priority order:
- Daily logs (
logs/YYYY/MM/YYYY-MM-DD.md) if present — these are the append-only stream
- Existing memories that drifted — facts that contradict something you see in the codebase now
- Session transcripts — the transcript directory contains JSONL files of past sessions. Grep them for relevant context:
grep -rn "<narrow term>" <transcript-dir>/ --include="*.jsonl" | tail -50
Use narrow, specific terms relevant to what you found in Phase 1 (e.g., a project name, a tool, a decision topic). Read surrounding lines when a match looks valuable.
Phase 3 — Consolidate
For each thing worth remembering, write or update a memory file at the top level of the memory directory.
Memory file format
---
name: {{memory name}}
description: {{one-line description — used to decide relevance in future conversations, so be specific}}
type: {{user | feedback | project | reference}}
---
{{memory content}}
Memory types
| Type |
What to store |
Scope |
| user |
Role, goals, preferences, knowledge |
Always private |
| feedback |
User's guidance on approach — corrections AND confirmations |
Private or team |
| project |
Ongoing work, goals, bugs, incidents — NOT derivable from code/git |
Bias toward team |
| reference |
Pointers to external systems (Linear, Grafana, Slack, etc.) |
Usually team |
What NOT to save
- Code patterns, architecture, file paths, project structure (derivable from code)
- Git history, recent changes (use
git log)
- Debugging solutions (the fix is in the code)
- Anything already in CLAUDE.md
- Ephemeral task details
Consolidation rules
- Merge new signal into existing topic files rather than creating near-duplicates
- Convert relative dates ("yesterday", "last week") to absolute dates so they remain interpretable
- Delete contradicted facts — if today's investigation disproves an old memory, fix it at the source
- For feedback and project types, structure as: rule/fact, then
**Why:** and **How to apply:** lines
Phase 4 — Prune and index
Update MEMORY.md so it stays under 200 lines AND under ~25KB.
MEMORY.md is an index, not a dump — each entry should be one line under ~150 characters:
- [Title](file.md) — one-line hook
Never write memory content directly into MEMORY.md.
Pruning checklist
Output
Return a brief summary of what you consolidated, updated, or pruned. If nothing changed (memories are already tight), say so.
Format:
## Dream Summary
**Reviewed:** N memory files
**Updated:** file1.md, file2.md
**Created:** new-topic.md
**Pruned:** old-stale.md
**MEMORY.md:** added 2 entries, removed 1, now at X/200 lines
### Changes
- Merged feedback about X into existing feedback_testing.md
- Created project_migration.md for the ongoing DB migration context
- Removed user_old_role.md (outdated, user changed teams)
- Converted relative dates in 3 files to absolute dates
1---2name: aio-dream3description: Memory consolidation — review, merge, prune and re-index memory files so future sessions orient quickly.4---56# Dream: Memory Consolidation78You 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.910## Environment1112- Memory directory: !`echo "${CLAUDE_MEMORY_DIR:-$HOME/.claude/projects/$(pwd | sed 's|/|-|g')/memory}"`13- Session transcripts: !`echo "${CLAUDE_PROJECT_DIR:-$HOME/.claude/projects/$(pwd | sed 's|/|-|g')}"` (JSONL files — each file is one past session)1415## Phase 1 — Orient16171. `ls` the memory directory to see what already exists182. Read `MEMORY.md` to understand the current index193. Skim existing topic files so you **improve them rather than creating duplicates**204. If `logs/` or `sessions/` subdirectories exist (assistant-mode layout), review recent entries there2122## Phase 2 — Gather recent signal2324Look for new information worth persisting. Sources in rough priority order:25261. **Daily logs** (`logs/YYYY/MM/YYYY-MM-DD.md`) if present — these are the append-only stream272. **Existing memories that drifted** — facts that contradict something you see in the codebase now283. **Session transcripts** — the transcript directory contains JSONL files of past sessions. Grep them for relevant context:29 ```bash30 grep -rn "<narrow term>" <transcript-dir>/ --include="*.jsonl" | tail -5031 ```32 Use narrow, specific terms relevant to what you found in Phase 1 (e.g., a project name, a tool, a decision topic). Read surrounding lines when a match looks valuable.3334## Phase 3 — Consolidate3536For each thing worth remembering, write or update a memory file at the top level of the memory directory.3738### Memory file format3940```markdown41---42name: {{memory name}}43description: {{one-line description — used to decide relevance in future conversations, so be specific}}44type: {{user | feedback | project | reference}}45---4647{{memory content}}48```4950### Memory types5152| Type | What to store | Scope |53|------|--------------|-------|54| **user** | Role, goals, preferences, knowledge | Always private |55| **feedback** | User's guidance on approach — corrections AND confirmations | Private or team |56| **project** | Ongoing work, goals, bugs, incidents — NOT derivable from code/git | Bias toward team |57| **reference** | Pointers to external systems (Linear, Grafana, Slack, etc.) | Usually team |5859### What NOT to save6061- Code patterns, architecture, file paths, project structure (derivable from code)62- Git history, recent changes (use `git log`)63- Debugging solutions (the fix is in the code)64- Anything already in CLAUDE.md65- Ephemeral task details6667### Consolidation rules6869- **Merge** new signal into existing topic files rather than creating near-duplicates70- **Convert** relative dates ("yesterday", "last week") to absolute dates so they remain interpretable71- **Delete** contradicted facts — if today's investigation disproves an old memory, fix it at the source72- For **feedback** and **project** types, structure as: rule/fact, then `**Why:**` and `**How to apply:**` lines7374## Phase 4 — Prune and index7576Update `MEMORY.md` so it stays under **200 lines** AND under **~25KB**.7778`MEMORY.md` is an **index**, not a dump — each entry should be one line under ~150 characters:7980```81- [Title](file.md) — one-line hook82```8384Never write memory content directly into `MEMORY.md`.8586### Pruning checklist8788- [ ] Remove pointers to memories that are now stale, wrong, or superseded89- [ ] Demote verbose entries: if an index line is over ~200 chars, move detail to the topic file90- [ ] Add pointers to newly important memories91- [ ] Resolve contradictions — if two files disagree, fix the wrong one92- [ ] Remove empty or near-empty memory files9394## Output9596Return a brief summary of what you consolidated, updated, or pruned. If nothing changed (memories are already tight), say so.9798Format:99100```markdown101## Dream Summary102103**Reviewed:** N memory files104**Updated:** file1.md, file2.md105**Created:** new-topic.md106**Pruned:** old-stale.md107**MEMORY.md:** added 2 entries, removed 1, now at X/200 lines108109### Changes110- Merged feedback about X into existing feedback_testing.md111- Created project_migration.md for the ongoing DB migration context112- Removed user_old_role.md (outdated, user changed teams)113- Converted relative dates in 3 files to absolute dates114```