Claude Auto Dream
Automatic memory consolidation for Claude Code. Replicates Claude Code 2.1.x's
built-in dream + extractMemories features and works with any LLM provider
(Anthropic, OpenAI, DashScope, Ollama, ...). Designed primarily for users who
drive Claude Code with third-party model APIs and don't get the official
features for free.
What It Does
This plugin installs two hooks that work together:
| Hook | Script | Runs | Purpose |
|---|
Stop | trigger-extract.sh | After every assistant turn | Incrementally writes durable facts from the latest conversation window into the memory dir. |
SessionEnd | trigger.sh | When the session ends | Big consolidation pass: re-orders, prunes, and updates the MEMORY.md index. |
Both hooks fire detached (nohup … & disown) so they never block Claude Code.
Quick Start
1. Install (recommended — Claude Code marketplace)
Inside Claude Code, add the marketplace once and install the plugin:
/plugin marketplace add MeCKodo/claude-auto-dream
/plugin install claude-auto-dream@claude-auto-dream
Claude Code copies the source to
~/.claude/plugins/cache/claude-auto-dream/claude-auto-dream/<version>/ and
auto-registers hooks/hooks.json (no manual settings.json edits needed).
Future updates: /plugin update claude-auto-dream@claude-auto-dream — or just
restart Claude Code, since the marketplace is registered with autoUpdate: true.
1b. Seed the default config
Run once to drop a starter file at ~/.claude-auto-dream/config.json:
git clone https://github.com/MeCKodo/claude-auto-dream.git
cd claude-auto-dream
./install.sh
install.sh no longer touches settings.json or the plugin cache; it only
seeds the default config.
2. Configure API
Edit ~/.claude-auto-dream/config.json:
{
"provider": "openai",
"endpoint": "https://api.openai.com/v1/chat/completions",
"model": "gpt-4o",
"apiKey": "sk-...",
"gates": { "minHours": 24, "minSessions": 5 },
"extract": { "enabled": true, "everyTurns": 1, "minProseWords": 3, "maxTurns": 5 }
}
3. Test
The plugin lives under
~/.claude/plugins/cache/claude-auto-dream/claude-auto-dream/<version>/.
# Pick the latest installed version
PLUGIN_DIR=$(ls -d ~/.claude/plugins/cache/claude-auto-dream/claude-auto-dream/*/ | sort -V | tail -1)
# Force a dream pass right now
node "${PLUGIN_DIR}src/dream.js" --force
# Dry-run extract (parses an existing transcript, runs all skip checks, no API call)
CLAUDE_HOOK_PAYLOAD_FILE=/tmp/payload.json \
node "${PLUGIN_DIR}src/extract.js" --dry-run
The payload file should look like a Claude Code Stop hook payload:
{ "transcript_path": "/abs/path/to/session.jsonl",
"cwd": "/abs/path/to/project",
"session_id": "...", "stop_hook_active": false }
Supported Providers
OpenAI
{ "provider": "openai", "model": "gpt-4o", "apiKey": "sk-..." }
Anthropic
{ "provider": "anthropic", "model": "claude-sonnet-4-6", "apiKey": "sk-ant-..." }
DashScope / CCR / Any OpenAI-compatible API
{
"provider": "openai_compat",
"endpoint": "https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions",
"model": "qwen3.6-plus",
"apiKey": "sk-..."
}
Environment Variables
export DREAM_PROVIDER=anthropic
export DREAM_MODEL=claude-sonnet-4-6
export DREAM_API_KEY=sk-ant-...
export DREAM_MIN_HOURS=12
export DREAM_MIN_SESSIONS=3
export DREAM_EXTRACT_ENABLED=true
export DREAM_EXTRACT_EVERY_TURNS=1
export DREAM_EXTRACT_MIN_PROSE=3
Env vars override JSON config. CLI flags (--endpoint, --apiKey, ...) override both.
Configuration