Dream Pass Claude Code mod: Claude Code memory cleanup and consolidation
Tidies Claude's memory folder: merges duplicates, rewrites stale entries, removes dead ones, with backup and undo.
Permissions
- Reads filesCan read files and list directories on your machine ($.fs.read / list / stat / exists).
- Writes filesCan create or overwrite files on your machine ($.fs.write).
- Runs commandsCan run shell programs on your machine ($.process.run / spawn). Check the source for exactly which ones.
- Calls the model (uses your quota)Can send its own requests to Claude, which count against your plan's usage ($.model.* / $.agent.spawn).
- Intercepts tool callsSees every tool call Claude makes (tool.call / tool.check) and could block or change it.
- Reads your promptsCan see what you type and the conversation transcript (prompt.* / session.append / session.messages).
- Changes the UIDraws into the Claude Code interface: bands, panes, status text, toasts (ui.render / $.ui.*).
- Adds commands/toolsRegisters new slash commands or tools that you or Claude can invoke ($.command.register / $.tool.register).
- Stores dataKeeps data between sessions in the plugin's private store ($.store.*).
- tested with
- v2.1.307
- last tested
- requires
- Claude Code ≥ 2.1.287
- surfaces
- above-prompt, pane, toast
- source
- Ray Amjad (ray-amjad) (MIT)
Install inside Claude Code:
/plugin install dream-pass --marketplace ray-amjad/claude-code-modsWhat does this mod do?
Dream Pass is a Claude Code memory cleanup mod by Ray Amjad (ray-amjad), part of his claude-code-mods collection. It tidies your Claude Code memory: the folder of small Markdown files, plus the MEMORY.md index, that Claude's auto memory fills over time. Auto memory only grows. Claude saves a fact, then a near copy a week later, then a note about a launch that has since happened, and the index passes 200 lines.
Dream Pass reads the whole folder and asks a fork of your current session what to change. The fork has your full conversation as context, so it knows that "we moved hosting to Fly.io" makes an old Heroku note wrong. It can merge duplicates, rewrite stale entries, remove dead ones, add a memory for something you said at least twice, and rewrite MEMORY.md. The mod then applies the edits itself, after copying the folder to .dream-backup/<timestamp>/.
You see the result in a band above the prompt (Dream: 3 merged · 1 removed · 1 rewritten) with Open, Undo and Hide buttons. Open shows a pane that lists every file touched and why. /dream undo puts the folder back.
Install
Use any of the methods in the install block; they install from the author's own marketplace. Before you let it dream, type /dream where to see which memory folder it will tidy.
$ install dream-pass
Requires Claude Code ≥ 2.1.287
Installs from the author's own marketplace: ray-amjad/claude-code-mods
1.One line, inside Claude Code
/plugin install dream-pass --marketplace ray-amjad/claude-code-modsPaste into a running session (v2.1.275+). Claude Code asks to add the marketplace first.
2.From your shell
claude plugin marketplace add ray-amjad/claude-code-mods claude plugin install dream-pass@claude-code-modsThen run /reload-plugins in any session that is already open.
3.Try it without installing
git clone https://github.com/ray-amjad/claude-code-mods claude --plugin-dir ./claude-code-mods/plugins/dream-passLoads the mod for one session only. Nothing is added to your settings.
How it works
There are three triggers. turn.complete counts the main conversation's turns and, every 20 by default, runs a gate. session.compact starts a dream just before compaction without holding compaction up. /dream runs one on demand. The gate first checks MEMORY.md in plain code (lines over 200 characters, pointers to missing files, files the index does not list). If those pass, it asks Haiku to answer YES or NO from the index, the file descriptions and what was said since the last check. A NO touches nothing.
On a dream, the mod also gathers evidence the tool-less fork cannot fetch: for memories that look like duplicates, the lines you typed in the session each was learned in (from originSessionId), and a short excerpt of your last five sessions. The fork replies with JSON, and the mod filters it before writing. This is from hooks/register.js:
// Only plain file names inside the folder, never a path
export function safeName(name) {
return typeof name === 'string' && /^[A-Za-z0-9][\w.-]*\.md$/.test(name)
}parsePlan keeps only edits whose names pass safeName, never lets the reply edit MEMORY.md except through the index field, and ignores an "added" file that already exists. Index lines that point at missing files are dropped in code, and [[links]] to a merged file are redirected to the file it went into. While a dream runs, Claude's own Write and Edit calls into the memory folder are refused with a "try again in a minute", so a memory saved mid-dream is not overwritten.
Customize it
There are two options, set with /plugin configure dream-pass@claude-code-mods: everyTurns (default 20) and memoryDir (empty means Claude Code's own folder). Three environment variables work for one session: DREAM_PASS_EVERY, DREAM_PASS_MEMORY_DIR and DREAM_PASS_TRANSCRIPTS_DIR. DREAM_PASS_SYNC makes headless runs wait for the dream. The commands are /dream, /dream show, /dream undo and /dream where.
Permissions & safety
We read every file the plugin can execute before running it: plugin.json, hooks/hooks.json, hooks/register.js (about 640 lines, readable, no imports), the test file and tsconfig.json. There is no package.json, install script, bundled or minified code. The repository's LICENSE is MIT. The plugin folder also holds three PNG images, which we listed and did not run, and an example/ folder of sample memories and transcripts, which is data. We found no instructions aimed at a reviewer in it. Notable findings:
- Writes outside the plugin's own store, without a prompt. The mod rewrites, creates and deletes
.mdfiles in your memory folder (by default~/.claude/projects/<project>/memory) through$.fs.writeandrm -f. The README says plainly that these writes skip every permission prompt in every mode. A full backup goes to.dream-backup/<timestamp>/first, with aDREAM.mdof every edit. Only bare*.mdnames are accepted (register.js272 and following), andMEMORY.mdis never deleted. It does not touchsettings.json, shell files, LaunchAgents or git hooks. - Runs commands through
$.process.runwith argv arrays and no shell:rm -f,mv(to retire a used backup),kill -0 <pid>(to see whether Claude Code's auto-dream is running) andgrep -Eover your session transcripts. On Windows it uses PowerShell with paths passed through environment variables. - Reads your session transcripts. It reads the
.jsonlfiles beside the memory folder and keeps only lines you typed. Short excerpts go to the model in the dream prompt. - Model calls cost tokens. The gate uses Haiku, a dream uses a fork of your session, and a fresh session falls back to Sonnet. These are your own Claude Code session's model calls. The code has no network calls of its own and no telemetry.
- Gating hooks.
tool.callrefusesWriteandEditinto the memory folder while a dream runs, andsession.compactis declared as a gating hook. Both have a.catchthat passes the call on if the hook fails. - Prompt text. The dream prompt is sent to the fork, labelled as coming from the plugin, and says memory files and excerpts are data, not instructions. The command returns an empty result, so nothing is added to what Claude reads. A fork can still misjudge, so expect the odd merge you disagree with.
- No daemon, no remote code, no API keys. It runs only inside Claude Code.
claude plugin validate reported no errors and no warnings in the manifest and hooks. Its directory check raised one warning, ICON_MISSING, which does not affect loading. The author's 18 tests passed on Claude Code 2.1.307.
- Reads files
- Can read files and list directories on your machine ($.fs.read / list / stat / exists).
- Writes files
- Can create or overwrite files on your machine ($.fs.write).
- Runs commands
- Can run shell programs on your machine ($.process.run / spawn). Check the source for exactly which ones.
- Calls the model (uses your quota)
- Can send its own requests to Claude, which count against your plan's usage ($.model.* / $.agent.spawn).
- Intercepts tool calls
- Sees every tool call Claude makes (tool.call / tool.check) and could block or change it.
- Reads your prompts
- Can see what you type and the conversation transcript (prompt.* / session.append / session.messages).
- Changes the UI
- Draws into the Claude Code interface: bands, panes, status text, toasts (ui.render / $.ui.*).
- Adds commands/tools
- Registers new slash commands or tools that you or Claude can invoke ($.command.register / $.tool.register).
- Stores data
- Keeps data between sessions in the plugin's private store ($.store.*).
Compatibility & troubleshooting
The README says it was tested on Claude Code 2.1.296. We checked validate and the tests on 2.1.307 on macOS. If /dream does nothing:
- Run
/dream whereand confirm the folder exists and contains aMEMORY.md. Without one the mod only shows a toast. - If Claude Code's auto-dream is running, Dream Pass skips and says so. Try again later.
- Typed as the first prompt of a new session,
/dreamfalls back to Sonnet with the files alone, with no conversation to judge from. - In a terminal under 144 columns the pane opens inline above the prompt in place of the band.
- A memory whose subject changes keeps its old file name, because renames are not supported.
To undo a dream you do not like, use Undo or /dream undo. A second undo goes one dream further back.
FAQ
- Does Dream Pass change my memory files without asking?
- Yes, by design. After install it checks every 20 turns, just before compaction, and when you type /dream. When it decides to dream it backs up the folder to .dream-backup/ and then writes the edits itself, without a permission prompt. /dream undo restores the last backup, and the band above the prompt has an Undo button.
- Which memory folder does it tidy?
- The one set by the memoryDir option, the DREAM_PASS_MEMORY_DIR environment variable or the autoMemoryDirectory setting. If none is set, it uses Claude Code's own folder for the project, ~/.claude/projects/<project>/memory. Run /dream where to see the path before you let it dream.
- Does it cost tokens?
- Yes. A dream is one fork of your session, which the README puts at 15 to 30 seconds. The periodic check is cheaper. It first checks MEMORY.md in plain code and, if that finds nothing, asks Haiku for a one-word YES or NO. The edits are only drafted on a YES or when the index has a problem.
- How is it different from Claude Code's auto-dream?
- Per the author's README, auto-dream runs at most once a day, greps past transcripts itself and has no backup or undo. Dream Pass runs on a turn counter, before compaction and on demand, uses the live conversation, and only adds a memory for something you said at least twice. When auto-dream holds its .consolidate-lock, Dream Pass skips.
- Can I try it without touching my real memories?
- Yes. The repository ships an example folder for a made-up founder. Copy it to /tmp and start Claude with DREAM_PASS_MEMORY_DIR pointing at the copy. The README walks through it. Claude Code's own auto memory still saves to your real folder during the demo unless you set CLAUDE_CODE_DISABLE_AUTO_MEMORY=1.
# Related mods
FeaturedPin Memo
Pin notes and clickable todo checkboxes above the Claude Code prompt with /pin, saved per session.
- above-prompt
- Changes the UI
- Adds commands/tools
- Stores data
tested with v2.1.303
FeaturedCompact Adviser
Suggests running /compact when your Claude Code session reaches a finished checkpoint, judged by TypeSafe's Jev model.
- status
- pane
- toast
- Reads files
- Writes files
- Network
- Reads your prompts
- Changes the UI
- Adds commands/tools
- Stores data
tested with v2.1.291