From dreams
Consolidate and curate Claude Code's persistent memory by reflecting on past session transcripts — a local emulation of Anthropic's Dreams API (managed-agents). Use when the user runs /dream or asks to clean up, deduplicate, consolidate, reorganize, or "dream over" Claude's memory, CLAUDE.md files, or claude-mem observations.
How this skill is triggered — by the user, by Claude, or both
Slash command
/dreams:dreamThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Emulates the Anthropic **Dreams** pipeline (`POST /v1/dreams`, research preview) against Claude Code's local storage. A dream reads an existing memory store alongside past session transcripts, then produces a **new, reorganized memory store**: duplicates merged, stale or contradicted entries replaced with the latest value, and new insights surfaced.
Emulates the Anthropic Dreams pipeline (POST /v1/dreams, research preview) against Claude Code's local storage. A dream reads an existing memory store alongside past session transcripts, then produces a new, reorganized memory store: duplicates merged, stale or contradicted entries replaced with the latest value, and new insights surfaced.
Prime directive (identical to the API): the input store is NEVER modified. All output goes to new files/directories. The user reviews the result and either applies it or discards it.
/dream [N] [instructions...]
N (optional integer, first token): number of recent session transcripts to mine. Default 10, max 100 (API limit). 0 means curate the store only, no transcript mining.instructions (optional, everything after N): steering text, equivalent to the API's instructions field. Examples: "focus on coding-style preferences; ignore one-off debugging notes", "preserve all reference memories unchanged".Per the API docs, instructions are synthesis guidance (what to read closely, what to merge or drop, how to structure the output), not line-level edit commands. If the user asks for a targeted edit to one memory ("change X to Y"), edit that file directly instead of running a dream.
Compute the project slug from the current working directory: replace every / and . with - (e.g. /Users/maxgoff/Dreams → -Users-maxgoff-Dreams).
Gather, reporting to the user what was found (file counts, sizes):
~/.claude/projects/<slug>/memory/ — markdown files with frontmatter (name, description, metadata.type) plus the MEMORY.md index.
~/.claude/projects/<slug>/*.jsonl, sorted by mtime descending. Take the N most recent. Note that the newest file is usually the current, in-progress session — include it but weight its content as provisional.*.dream proposals):
<cwd>/CLAUDE.md and <cwd>/CLAUDE.local.md (project)~/.claude/CLAUDE.md (global)~/.claude-mem/claude-mem.db exists): SQLite, read-only. Relevant rows:
sqlite3 -readonly ~/.claude-mem/claude-mem.db \
"SELECT id, type, title, subtitle, facts, created_at FROM observations
WHERE project = '<project>' ORDER BY created_at_epoch DESC"
Discover the project name first: SELECT DISTINCT project FROM observations; and match against the cwd basename. If claude-mem is absent, skip silently.Read every file in the memory store. Build an internal inventory: name, type (user/feedback/project/reference), description, key claims, [[links]], and apparent age. Flag candidates for: exact/near duplicates, mutual contradictions, entries that look stale (reference things that may no longer exist — verify against the repo before dropping), and one-off notes with no durable value.
Transcripts are JSONL and dominated by tool results. Never read raw .jsonl files into the main context. Extract conversational text first:
jq -r '
select(.type == "user" or .type == "assistant")
| .type as $role
| (.message.content // empty)
| if type == "string" then "\($role): \(.)"
else ([.[] | select(.type? == "text") | .text] | select(length > 0) | "\($role): \(join("\n"))")
end
' <transcript>.jsonl
Fan out with parallel subagents (Explore or general-purpose), batching 1–5 transcripts per agent depending on size (split large transcripts across more agents; for files > 5 MB, mine the extracted text in chunks). Each agent receives the steering instructions and returns a structured list of findings:
category: user | feedback | project | referencefact: the durable insight, stated absolutely (convert relative dates to absolute)evidence: short quote or paraphrase from the transcriptcontradicts: name of an existing memory this supersedes, if anyconfidence: high / medium / lowInstruct agents to mine for: explicit user corrections and preferences, confirmed working approaches, recurring project facts and constraints, external references (URLs, tickets, dashboards) — and to ignore one-off debugging noise, transient state, and anything already derivable from the repo or git history.
Write the rebuilt store to a sibling directory: ~/.claude/projects/<slug>/memory.dream-<YYYY-MM-DD>/. If it already exists from an earlier run today, append -2, -3, ….
Rules, mirroring the Dreams pipeline:
name, description, metadata.type), **Why:** / **How to apply:** lines for feedback/project types, [[name]] cross-links (repair links broken by merges/renames).MEMORY.md as the index: one - [Title](file.md) — hook line per memory, ordered by usefulness-at-recall, no memory content in the index itself.CLAUDE.md proposals: for each CLAUDE.md found, if curation would change it (dedupe, remove stale directives, fold in mined feedback that belongs in standing instructions), write the proposal to <path>.dream-<date> next to the original. Be conservative — these are the user's hand-written directives; reorganize and dedupe, don't rewrite voice or drop anything you can't show is stale.
claude-mem report: write ~/.claude/projects/<slug>/memory.dream-<date>/claude-mem-report.md listing duplicate/stale/contradicted observation IDs with reasons, plus a ready-to-run claude-mem-curation.sql (DELETEs/UPDATEs by ID). Never execute it — the DB has FTS triggers and a live worker process; the user applies it manually after stopping claude-mem, or feeds the report to claude-mem's own tooling.
Present a summary the user can judge without opening files:
| input store | output store | |
|---|---|---|
| memories kept as-is | ||
| merged | ||
| updated (latest-wins) | ||
| dropped | ||
| new from sessions |
…plus 3–5 notable examples (the most consequential merge, drop, and new insight), the list of CLAUDE.md proposals written, and claude-mem report counts.
Then ask the user to choose (use AskUserQuestion when available):
mv memory memory.pre-dream-<date> && mv memory.dream-<date> memory
For each approved CLAUDE.md proposal: cp CLAUDE.md CLAUDE.md.pre-dream-<date> && mv CLAUDE.md.dream-<date> CLAUDE.md. Offer per-file choice — the user may want the memory swap but not the global CLAUDE.md change.*.dream-<date> proposals.Never auto-apply. On failure mid-pipeline, leave whatever was written (the API's failed semantics: partial output persists for inspection) and report what completed.
| Dreams API | This skill |
|---|---|
memory_store input | ~/.claude/projects/<slug>/memory/ |
sessions input (1–100) | local .jsonl transcripts (N, default 10) |
instructions | trailing /dream arguments |
output store in outputs[] | memory.dream-<date>/ sibling dir |
| input never modified | input never modified |
| review then attach/discard | review then swap/discard |
| async job, observable session | runs in-session with progress updates |
Creates, edits, and optimizes skills for Claude Code, including drafting, evaluating with test prompts, iterating on performance, and improving skill descriptions for better triggering accuracy.
npx claudepluginhub maxgoff/dreams --plugin dreams