Claude
Skills
Sign in
Back

dream

Included with Lifetime
$97 forever

Use this skill to review recent conversations and consolidate learnings into Sibyl. Activates on mentions of dream, dreaming, consolidate memory, review conversations, what did we learn, sleep cycle, reflect on sessions, consolidate knowledge, memory maintenance, nightly review, digest sessions, or dream mode.

Code Review

What this skill does


# Dream: Conversation Review & Knowledge Consolidation

Bio-inspired two-phase sleep cycle that reviews Claude Code and Codex conversations, extracts structured knowledge, and consolidates it into Sibyl. Like biological dreaming: NREM consolidates, REM discovers.

**Core insight:** Conversations contain ~10x more knowledge than what gets manually captured. Dreams extract decisions, patterns, corrections, anti-patterns, and open questions that would otherwise vanish when sessions scroll off.

**How to read this skill:** the phases below describe the rhythm of a useful dream cycle, not a procedure to march through. Quick naps compress most of it, deep sleeps stretch it out. The non-negotiable bits are extraction quality (Sibyl entries that meet the bar in `references/extraction-guide.md`) and dedup discipline (every write checked against existing entries). Process shape adapts; quality bar doesn't.

## The Shape

```dot
digraph dream {
    rankdir=TB;
    node [shape=box];

    "1. ORIENT" [style=filled, fillcolor="#e8e8ff"];
    "2. HARVEST" [style=filled, fillcolor="#ffe8e8"];
    "3. NREM: Consolidate" [style=filled, fillcolor="#e8ffe8"];
    "4. REM: Explore" [style=filled, fillcolor="#fff8e0"];
    "5. REPORT" [style=filled, fillcolor="#e8e8ff"];

    "1. ORIENT" -> "2. HARVEST";
    "2. HARVEST" -> "3. NREM: Consolidate";
    "3. NREM: Consolidate" -> "4. REM: Explore";
    "4. REM: Explore" -> "5. REPORT";
}
```

### Depth Modes

| Mode           | Sessions             | Focus                         | When                       |
| -------------- | -------------------- | ----------------------------- | -------------------------- |
| **Quick nap**  | Last 1-3             | Extract from today's work     | End of day, `/dream quick` |
| **Full sleep** | Last 5-15            | Standard consolidation cycle  | Default `/dream`           |
| **Deep sleep** | All since last dream | Cross-project synthesis + REM | `/dream deep`              |
| **Lucid**      | Specific session(s)  | Targeted extraction           | `/dream <session-id>`      |

---

## Phase 1: ORIENT

Get the lay of the land before harvesting. Re-processing already-dreamed sessions wastes tokens and creates duplicate entries.

### Common moves

1. **Check dream state**: when was the last dream cycle?

   ```bash
   # Check Claude's auto-dream lock
   stat ~/.claude/projects/*/memory/.consolidate-lock 2>/dev/null | grep -A1 "Modify"

   # Check Sibyl for recent dream entries
   sibyl search "dream report" --type episode --limit 3
   ```

2. **Discover conversation sources:**

   **Claude Code sessions:**

   ```bash
   # Find recent sessions across ALL projects (last 7 days)
   find ~/.claude/projects -name "*.jsonl" -not -path "*/subagents/*" -mtime -7 -exec ls -lt {} + | head -30
   ```

   **Codex sessions:**

   ```bash
   # Find recent Codex rollouts
   find ~/.codex/sessions -name "rollout-*.jsonl" -mtime -7 -exec ls -lt {} + | head -30
   ```

3. **Count the harvest:**
   - How many sessions since last dream?
   - Which projects were active?
   - Any notably long or complex sessions? (file size > 100KB = rich conversation)

4. **Set dream scope** based on depth mode and available sessions.

---

## Phase 2: HARVEST

Read conversations and identify extractable knowledge. The trick is reading targeted segments rather than entire JSONL files; most session content is routine, and only specific patterns carry transferable signal.

### Reading Claude Code sessions

Claude Code JSONL files contain one JSON object per line. Key message types to look for:

| Content Type                | Where to Find                            | What to Extract                      |
| --------------------------- | ---------------------------------------- | ------------------------------------ |
| **User corrections**        | User messages following assistant errors | Anti-patterns, wrong assumptions     |
| **Technical decisions**     | Assistant text blocks with rationale     | Decision + alternatives considered   |
| **Tool invocations**        | `tool_use` blocks (Bash, Edit, etc.)     | Commands that worked, error patterns |
| **Debugging chains**        | Sequences of failed → fixed attempts     | Error patterns, root causes          |
| **Architecture discussion** | Longer text blocks with design reasoning | Patterns, system relationships       |
| **Thinking blocks**         | `type: "thinking"` content               | Reasoning chains, hidden insights    |

**Extraction strategy, don't read whole files.** Use targeted python extraction:

```bash
# Extract all user prompts (most reliable method)
python3 -c "
import json, sys
with open('session.jsonl') as f:
    for line in f:
        obj = json.loads(line)
        if obj.get('type') == 'user':
            content = obj.get('message', {}).get('content', '')
            if isinstance(content, str) and len(content) > 20 and not content.startswith('<'):
                print(content[:300])
"

# Extract assistant decisions and rationale
python3 -c "
import json
with open('session.jsonl') as f:
    for line in f:
        obj = json.loads(line)
        if obj.get('type') == 'assistant':
            for block in obj.get('message', {}).get('content', []):
                if isinstance(block, dict) and block.get('type') == 'text':
                    text = block['text']
                    if any(kw in text.lower() for kw in ['because', 'root cause', 'the issue', 'approach', 'trade-off']):
                        if len(text) > 100:
                            print(text[:400])
                            print('---')
"

# Get session titles (best way to understand session topics at a glance)
for f in ~/.claude/projects/-Users-bliss-dev-*/*.jsonl; do
  title=\$(grep -m1 '"ai-title"' "\$f" 2>/dev/null | python3 -c "import sys,json; print(json.loads(next(sys.stdin)).get('aiTitle',''))" 2>/dev/null)
  [[ -n "\$title" ]] && echo "\$(du -h "\$f" | cut -f1)  \$(basename "\$(dirname "\$f")"): \$title"
done | sort -rh | head -20
```

**Why python over grep:** Claude Code JSONL has nested JSON structures (content arrays inside message objects). Simple grep patterns like `'"role":"user"'` match across the entire line, producing false positives from assistant messages that quote user content. Python parsing is slower but precise. Use grep only for initial signal scoring (counts), then python for actual extraction.

For promising sessions (high correction count, long duration, many tool calls), read key segments more deeply using `Read` tool on the JSONL file with offset/limit.

### Reading Codex Sessions

Codex rollouts at `~/.codex/sessions/YYYY/MM/DD/rollout-*.jsonl` use a different format. See `references/conversation-formats.md` for the full schema.

```bash
# Find Codex sessions with substantial content
find ~/.codex/sessions -name "rollout-*.jsonl" -mtime -7 -size +10k

# Get Codex session metadata (cwd, branch, model)
python3 -c "
import json
with open('rollout.jsonl') as f:
    for line in f:
        obj = json.loads(line)
        if obj.get('type') == 'session_meta':
            p = obj['payload']
            print(f'cwd: {p.get(\"cwd\")}')
            print(f'model: {p.get(\"model_provider\")}')
            print(f'branch: {p.get(\"git\", {}).get(\"branch\")}')
            break
"

# Extract user messages from Codex (payload.role == 'user')
python3 -c "
import json
with open('rollout.jsonl') as f:
    for line in f:
        obj = json.loads(line)
        if obj.get('type') == 'response_item':
            p = obj.get('payload', {})
            if p.get('role') == 'user':
                for c in p.get('content', []):
                    if c.get('type') == 'input_text':
                        text = c['text']
                        if not text.startswith('#') and not text.startswith('<') and len(text) > 20:
                            print(text[:200])
"

# Extract function calls
grep '"function_call"' rollout.jsonl | grep -v '"function_call_output"'
Files: 3
Size: 36.9 KB
Complexity: 45/100
Category: Code Review

Related in Code Review