Original Reddit post

Anthropic’s agent memory research has a name for fixing stale memory: "dreaming” and they published it recently, the idea is that an agent decides what to save in the middle of a task, before it knows what’ll matter later, usually some of those notes are wrong from the start, and others go stale as things change. The idea is when the agent’s idle, it goes back, rereads what actually happened, and corrects its notes. They compare it to how your brain replays the day while you sleep. Claude Code already saves every session as JSONL in ~/.claude/projects, so all the raw material was just sitting there unused, and making proper use of it is what kinda made me try this. Why do this? The root cause is that memory only gets written mid-session, when Claude can’t know what’ll matter later, and nothing ever goes back to check it. How I adapted the dream idea: This is an hourly launchd job that reads a list of project paths. It skips any project that hasn’t been idle for 2 hours or has no transcripts newer than its last dream. A small Python script condenses the new JSONL files. User and assistant text stay, each tool call shrinks to one line (Bash command, file path), tool results get cut to a 300-char preview, and then sessions are capped at 15 per run. That’s what keeps this cheap enough to run on Sonnet, an excellent model for this in my opinion. It creates a git worktree on a dream/<timestamp> branch and runs claude -p --model sonnet with the dream skill appended to the system prompt, --add-dir pointing at the condensed transcripts, and tools limited to Read/Glob/Grep/Edit/Write, more of a guardrail. The skill tells Claude what memory is for and lets it judge what to write. This bit came straight from the Anthropic research that I read, where rigid rules like “only record failures” hurt stronger models. It verifies each note against the transcripts (latest session wins), records what I had to repeat, prunes finished one-offs, keeps CLAUDE.md under ~150 lines, pushes detail into docs/memory/, and logs every change with evidence in DREAM_LOG.md. Before it commits, a guardrail checks git status and reverts anything outside CLAUDE.md, DREAM_LOG.md and docs/memory/. It’s never allowed to touch code, even if it spots a bug. It notes the bug in the log instead. If the last dream hasn’t been merged yet, the next one builds on top of it, so after a two-week break it’s still one merge. How I’m planning to use it: only on projects I come back to after long gaps, I mean, daily projects don’t need it right cause the discussion is usually fresh, and dead ones aren’t worth the tokens. My routine when I pick a project back up is to run git diff main…dream/<latest>, skim DREAM_LOG.md, merge, then start the session. The idea is Claude opens already knowing where I left off, instead of me spending 15 minutes re-explaining. It’s on trial for a week on my Mac. The expectation is simple: do the diffs catch real mistakes, or is it mostly rewording? I’ll post what it actually caught either way. Have you folks tried anything similar, or more efficient ways of learning from your own projects? I did it because I thought “dream” was a very interesting idea. Link to the research paper: https://www.anthropic.com/research/components-of-agent-memory submitted by /u/Sweet-Helicopter2769

Originally posted by u/Sweet-Helicopter2769 on r/ClaudeCode