vt-c-dream¶
Memory consolidation — clean up contradictions, stale dates, dead references, and duplicates in auto-memory files AND Open Brain persistent thoughts. Ask human before removing uncertain memories.
Plugin: core-standards
Category: Other
Command: /vt-c-dream
Memory Consolidation (/dream)¶
Perform a reflective consolidation pass over Claude Code's auto-memory files and Open Brain persistent thoughts. Fixes contradictions, stale dates, dead references, and duplicates across both local and cloud memory. Rule: ask a human if unsure — never silently delete memories that might still be valid.
When to Use¶
- Memory feels stale (Claude references outdated decisions)
- After a major project restructuring (files moved, branches deleted)
- Periodically (every few weeks) as maintenance
- When MEMORY.md exceeds 200 lines
Invocation¶
/vt-c-dream # Consolidate current project memory (default)
/vt-c-dream user # Consolidate user-level memory
/vt-c-dream all # Consolidate both project and user memory
Execution¶
Phase 0: Open Brain Connectivity¶
Check if Open Brain MCP tools are available for cloud memory consolidation.
- Attempt to call
thought_stats: - If the tool is available and returns data → set
open_brain_available = true -
If the tool is not available, times out, or errors → set
open_brain_available = false -
Display result:
- If connected:
Open Brain: connected ({N} thoughts) - If not connected:
Open Brain: not connected (skipping cloud phases)
All "B" sub-phases below check open_brain_available and skip silently if false.
Phase 1: Orient¶
- Resolve memory directory based on scope.
Note: Claude Code stores memory at
~/.claude/on macOS/Linux,%APPDATA%\claude\on Windows. Use the platform-appropriate path. project(default): Find the current project's memory directory. Runls ~/.claude/projects/and match the current working directory hash. The memory path is~/.claude/projects/{project-hash}/memory/.user:~/.claude/memory/-
all: Process both in sequence (project first, then user) -
List all memory files:
-
Read MEMORY.md index (the file loaded at the start of every session)
-
Count and report:
-
If no memory files found: display "No memory files found in {scope}. Nothing to consolidate." (Continue to Open Brain phases if connected.)
Phase 1B: Open Brain Inventory¶
Skip if open_brain_available is false.
- Reuse
thought_statsresult from Phase 0 (already called for connectivity check) to get overview: - Total thought count
- Top topics/categories
-
Date range (earliest to latest)
-
Call
list_thoughtsto sample recent activity (last 30 days) -
Display alongside local report:
-
If 0 thoughts: display "Open Brain is empty. Nothing to consolidate." and skip remaining B phases.
Phase 2: Gather Signal¶
For each memory file (excluding MEMORY.md itself):
-
Read the file content
-
Check for staleness indicators:
a. File path references — grep for paths like /path/to/file, src/, plugins/, etc.
For each path found:
dead_reference
b. Function/class references — grep for identifiers like functionName(), ClassName, CONSTANT_NAME
For notable identifiers:
dead_reference
c. Branch references — grep for branch names like feature/, fix/
dead_reference
c2. Spec status references — grep for SPEC-NNN patterns
If .design-state.yaml exists:
status: completed but memory says "IN PROGRESS" or "active" → flag as stale_status
- If spec ID not found in design state → flag as dead_reference
- If spec is completed and memory entry only describes that spec's work → flag as ask_human (may no longer be relevant)
d. Date analysis — look for dates in the content:
- Relative dates ("last week", "next Friday", "tomorrow", "yesterday") → flag as stale_date
- Absolute dates older than 90 days → flag as old_date
e. Contradiction detection — compare key statements:
- If two memory files claim different values for the same fact (e.g., "using React" vs "switched to Vue") → flag as contradiction
- Compare against MEMORY.md index entries for consistency
- Classify each finding:
| Classification | Criteria | Action |
|---|---|---|
auto_remove |
Dead file/branch reference, date > 90 days old, clearly contradicted by newer memory | Remove automatically |
ask_human |
Ambiguous context, might still apply, function not found but could be in external dependency | Present to user |
keep |
Verified current, recent dates, references confirmed | No action |
- Report findings:
Phase 2B: Open Brain Staleness Detection¶
Skip if open_brain_available is false.
For recent thoughts (from Phase 1B sample), check for staleness:
a. Dead spec references — For each thought mentioning SPEC-NNN:
- Check .design-state.yaml for the spec's status
- If spec is completed/rejected but thought implies active work → flag as stale_status
- If spec ID not found → flag as dead_reference
b. Contradictions — Use search_thoughts to find thoughts on the same topic:
- If a newer thought reverses an earlier decision (e.g., "switched to X" vs earlier "using Y") → flag as contradiction
- Keep the newer thought, flag the older for removal
c. Duplicates — Look for thoughts with very similar content captured within 24 hours:
- Same topic, same conclusion, different timestamp → flag as duplicate
- These typically come from the same workflow running twice
d. Temporal anomalies — Check thought dates:
- Future dates → flag as anomaly
- Dates older than 1 year → flag as old_thought
Classify each finding: auto_remove / ask_human / keep (same as local memory).
Display:
Phase 2B: Open Brain Signal
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Thoughts checked: {N}
Findings:
{X} clearly stale (auto-remove)
{Y} uncertain (will ask you)
{Z} current (no action)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Phase 3: Consolidate¶
3a. Auto-remove clearly stale items:
For each auto_remove finding:
- If the entire memory file is stale (all content references deleted things) → delete the file
- If only specific lines are stale → edit the file to remove those lines
- Log each removal to the archive file: {memory_dir}/archived-YYYY-MM-DD.log
# Archived by /vt-c-dream on YYYY-MM-DD
## Removed: {filename}
Reason: {reason}
Content:
{original content}
Display: "{X} stale entries auto-removed"
3b. Human confirmation for uncertain items:
For each ask_human finding, present via AskUserQuestion:
Memory: {filename}
Content: "{the relevant memory text}"
Why it might be stale:
{reason — e.g., "References function calculate_total() which was not found in the codebase"}
Options: - Remove — delete this memory entry - Keep — it's still relevant, leave it - Edit — modify the memory (user provides updated text)
3c. Merge duplicates:
If two memory files cover the same topic (similar title, overlapping content): - Show both to the user - Ask: "These memories overlap. Merge into one?" - If yes: combine content, delete the duplicate file
3d. Fix dates:
Convert relative dates to absolute: - "last Friday" → "2026-03-28" (based on file modification date as reference) - "next week" → flag for human review (relative to when?)
Phase 3B: Open Brain Consolidation¶
Skip if open_brain_available is false or no findings from Phase 2B.
3B-a. Present stale thoughts for confirmation:
For each auto_remove finding from Phase 2B, show the batch:
Open Brain — {N} thoughts flagged for removal:
1. "{thought content preview}" — {reason}
2. "{thought content preview}" — {reason}
...
Confirm removal?
Use AskUserQuestion: - Remove all — purge all flagged thoughts - Review individually — present each one for Remove / Keep decision - Keep all — skip removal
3B-b. For ask_human findings, present each individually:
Options: - Remove — purge this thought - Keep — it's still relevant
3B-c. Execute removals:
For each confirmed removal, call purge_content with the thought ID.
Display: "{X} Open Brain thoughts removed, {Y} kept"
Phase 4: Prune and Index¶
- Rebuild MEMORY.md:
- Read all remaining memory files
- For each file, generate a one-line entry (under 150 chars):
- [{Title}]({filename}) — {one-line description} - Sort semantically by topic (not chronologically)
- Remove any entries pointing to files that no longer exist
- Add entries for any memory files not yet in the index
-
Target: under 200 lines
-
If MEMORY.md exceeds 200 lines after rebuild:
- Display warning: "MEMORY.md is {N} lines (limit: 200). Consider consolidating more memories."
-
Suggest which entries could be merged
-
Write the updated MEMORY.md
-
Display summary report (see Report Format below)
Report Format¶
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Memory Consolidation — {scope}
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Local Memory:
Files scanned: {N}
Lines before: {before} → after: {after} (Δ {delta})
Changes: {X} removed, {Y} kept, {W} merged, {D} dates fixed
MEMORY.md: {lines} lines (limit: 200)
Open Brain: {connected | not connected}
Thoughts checked: {N}
Removed: {X} | Kept: {Y}
Duplicates found: {W}
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
If Open Brain was not connected, the Open Brain section shows "not connected (skipped)".
Edge Cases¶
| Scenario | Handling |
|---|---|
| Empty memory directory | Report "no files" and exit (continue to Open Brain if connected) |
| MEMORY.md doesn't exist | Create it from scratch by scanning all memory files |
| Memory file has no frontmatter | Process content as plain text |
| User-level memory directory missing | Report and skip (only process what exists) |
| All memories are current | Report "all current, no changes needed" |
| Memory references external system (Asana, GitHub) | Skip verification — only verify local file/branch refs |
| Open Brain MCP tools unavailable | Skip all B phases silently, display "not connected" |
thought_stats returns 0 thoughts |
Skip 2B/3B, report "Open Brain is empty" |
purge_content fails for a thought |
Log error, continue with remaining removals |
list_thoughts times out |
Skip 2B/3B with warning, report in summary |