Prompt file imported from zotoio/CRUX-Compress (
.cursor/commands/crux-dream.md). Fill in{{arguments}}before use. Copyright stays with the author.
crux-dream
Post-execution memory extraction and REM sleep rebalancing.
Repository: github.com/zotoio/CRUX-Compress
Usage
/crux-dream <spec-name> - Extract memories from a completed spec
/crux-dream --rem - Run REM sleep (rebalance all memories)
/crux-dream --rem --yolo - Run REM sleep, auto-apply non-conflict changes
Instructions
When this command is invoked, spawn a crux-cursor-memory-manager subagent to handle the memory workflow. The manager orchestrates the six memory skills to perform extraction or rebalancing.
User input escalation — CRITICAL: This command uses Pattern B (work first, then escalate) — the subagent must analyse artifacts and rank candidates before the user can make decisions. The subagent NEVER calls AskQuestion directly. ALL user-facing questions (accepting candidates, applying REM changes, resolving conflicts, archiving) are handled by the parent agent (you) using AskQuestion. The subagent returns its analysis and any needs_user_input sections; you collect answers from the user and resume the subagent with them.
Foreground execution — CRITICAL: The subagent MUST run in the foreground (run_in_background: false). Background subagents only return a truncated summary notification to the parent — the full analysis is lost. Foreground execution blocks the parent until the subagent completes and returns its complete response, which the parent then displays verbatim to the user.
Full output relay — CRITICAL: The parent agent MUST relay the subagent's complete response to the user without summarizing, truncating, or paraphrasing. The subagent's response contains the full spec analysis — artifact examination, candidate ranking, conflict reports, resolved bug detection — and all of this must be visible to the user before any decisions are requested. If the response is long, display it in full; do not condense it.
Candidate visibility: The subagent MUST return its ranked candidates (or REM recommendations) and the full analysis that produced them in its final response. This includes: verification results, diff analysis summary, artifact examination findings, comparison results against existing memories, and the ranked candidates with full rationale. The parent agent displays all of this, then asks the user for decisions using AskQuestion — never before the full analysis is displayed.
Proposal artefacts — CRITICAL: For spec-name invocations, the parent agent MUST instruct the subagent to write its full analysis to <spec-dir>/memory-proposals/dream-analysis-<yyyymmdd>.md (create the memory-proposals/ directory if absent). This serves two purposes: (1) it gives the parent a reliable channel to read the complete analysis when the Task tool's response body strips long content, and (2) it leaves a durable proposal artefact alongside the spec for audit. The subagent's <response> body need only return the path to the written file plus a short status; the parent reads the file directly to relay content to the user. The memory-proposals/ directory and its contents move with the spec when it is archived. For --rem invocations there is no spec directory; the subagent writes to .crux/memory-proposals/rem-analysis-<yyyymmddHHMM>.md instead.
User decisions: Whenever user approval is needed (accepting candidates, applying REM changes, archiving), use the AskQuestion tool in the parent agent (not the subagent) to present structured multiple-choice options instead of free-text prompts. This ensures clean, single-click interaction.
Argument Handling
- No arguments (just
/crux-dream): The parent agent discovers available specs by scanning the configuredworkDirfrom.crux/crux-memories.json(cruxMemories.dream.workDir, defaultspecs). It lists all subdirectories in that directory (excluding.gitkeepand hidden files), and presents them as structured options usingAskQuestionso the user can select which spec to dream about. If theworkDiris empty or contains no spec directories, inform the user and stop. Do not accept spec names from other directories — only specs present in the configuredworkDirare valid targets. - Spec name (e.g.
20260403-crux-memories): Validate that the named spec exists as a subdirectory of the configuredworkDir. If it does not exist there, report the error and show the available specs fromworkDirinstead. Do not search other directories. Once validated, the manager runs the dream extraction workflow on the completed spec. Pass{{arguments}}to the subagent as the spec name. --rem: The manager runs REM sleep — a full rebalance of the memory corpus. It scans all memories and trackers, checks consistency, detects conflicts, recommends promotions/demotions/archival/consolidation, and presents a structured report for approval.--rem --yolo: Same as--rembut auto-applies all non-conflict recommendations. Conflicts still require manual resolution — they are never auto-resolved.
What Happens
Dream Extraction (spec name)
- Verifies the spec completed successfully (checks
_execution-state.yml) - Analyses repository changes since spec start for scope assessment
- Reads all spec artifacts (subtask files, execution reports, work logs, diffs)
- Extracts candidate facts — learnings, red flags, goals, ideas, core patterns
- Compares candidates against existing memories for novelty and conflicts
- Subagent writes its complete analysis and ranked candidates to
<spec-dir>/memory-proposals/dream-analysis-<yyyymmdd>.mdand returns the path - Parent reads the proposal file and displays its content verbatim to the user — do not summarize or omit any part of the analysis
- Parent agent uses the
AskQuestiontool to collect the user's accept/skip decision with structured options (e.g. "Accept all", "Select individually", "Skip all") and whether to archive the spec directory - Parent resumes the subagent with the user's decisions; subagent creates accepted memories via
crux-skill-memory-crud - Writes a dream summary to the spec directory (the proposal file is retained alongside it as an audit artefact)
- Rebuilds the memory index
- Archives the spec directory if the user opted in (the
memory-proposals/directory moves with it)
REM Sleep (--rem)
- Loads all memories and reference trackers
- Verifies data consistency (orphaned trackers, broken strength chains)
- Detects conflicts between existing memories
- Evaluates promotions, demotions, archival, and consolidation candidates
- Detects uncompressed memories for CRUX compression (when
enableMemoryCompressionis enabled) - Subagent writes its complete analysis and recommendations to
.crux/memory-proposals/rem-analysis-<yyyymmddHHMM>.mdand returns the path - Parent reads the proposal file and displays its content verbatim to the user; parent agent then uses the
AskQuestiontool to collect the user's approval decision with structured options (e.g. "Apply all", "Select individually", "Skip all") — conflicts always require individual resolution - Parent resumes the subagent with the user's decisions; subagent applies confirmed changes (including compression via
crux-skill-memory-compress) - Writes a REM summary
- Rebuilds the memory index
After Dreaming
- Use
/crux-recallto view created or modified memories - Run
/crux-dream --remperiodically to keep the memory corpus healthy - Memories with high reference counts may be flagged for promotion to permanent rules
Related
crux-cursor-memory-manageragent — The specialist that manages the memory lifecyclecrux-skill-memory-extractskill — Dream extraction analysiscrux-skill-memory-rebalanceskill — REM sleep rebalancing/crux-recall— View and query memories/crux-forget— Remove memories from the corpus/crux-remember— Create ad-hoc memories outside of spec workflows/crux-meditate— Recursive memory-informed exploration
