Install
openclaw skills install agent-dreamNightly memory consolidation and self-reflection for OpenClaw agents. Your agent dreams — reviewing sessions, organizing memories, pruning stale info, and reflecting on its own behavior. Works with any OpenClaw agent. Features: 5-phase dream cycle, safe 2-pass deletion, automatic backup, change gates (>50% blocked), gate check (24h + 5 sessions), growth notifications, old memory resurface, zero-config setup. Inspired by Claude Code Dream but open-source with real self-awareness. Use when: dream, memory, consolidation, self-reflection, agent identity, persistent memory, long-term memory, memory organization, nightly cleanup, memory management.
openclaw skills install agent-dreamYour agent forgets everything between sessions. This fixes that.
Your agent periodically enters a "dream" state where it:
This is different from other memory skills. Those organize files. This one builds self-awareness.
When this skill is first installed, run setup to auto-detect your workspace:
node {baseDir}/scripts/setup.js
Setup will:
{baseDir}/assets/dream-config.jsonThen configure a cron job (recommended: daily, off-peak hours):
name: "agent-dream"
schedule: { kind: "cron", expr: "0 3 * * *", tz: "<your timezone>" }
payload: {
kind: "agentTurn",
message: "Time to dream. Read your openclaw-dream skill and follow every step.",
timeoutSeconds: 900
}
sessionTarget: "isolated"
On the first dream run, the agent will ask you one question:
"Dream will update your MEMORY.md during consolidation. Allow this?"
memory/dreams/ and leaves MEMORY.md untouchedThis is saved in config. You won't be asked again. Change it anytime in dream-config.json.
Before dreaming, verify conditions are met:
{dreamsDir}/.dream-lock (Unix timestamp of last dream, or "0" if first).jsonl session files modified since last dream.dream-lock (save previous to .dream-lock.prev for rollback)MEMORY.md.pre-dream before any changes. Also back up any topic files (in memory/projects/, memory/people/, etc.) that you plan to modify — copy each to <filename>.pre-dream in the same directory.dream-config.json from {baseDir}/assets/ for all paths{dreamsDir}/ to see what last dream concludedSources in priority order:
memory/YYYY-MM-DD.md) written since last dreamprefer|don't like|偏好|喜欢|不喜欢decided|confirmed|rule|决定|确定|结论mistake|lesson|bug|fix|错了|教训|踩坑thanks|great|disappointed|谢谢|不错|失望Don't exhaustively read transcripts. Look only for things you suspect matter.
Classify each memory into one of four types (see {baseDir}/references/memory-types.md):
Consolidation rules:
<!-- type: user|feedback|project|reference -->What NOT to save:
Update MEMORY.md to stay under 200 lines / 25KB. It's an index, not a dump.
Safety rules:
<!-- dream:stale YYYY-MM-DD reason -->. Deletion happens only when two consecutive dreams both mark the same item stale.Change magnitude check (measured by line count):
change% = abs(after - before) / before * 100MEMORY.md.proposed, notify user for reviewMemory drift caveat: A memory naming a specific state ("X is running") is a claim about when it was written, not now. Before acting on recalled memories, verify current state.
This is what makes Dream different. You're not just organizing files — you're maintaining a continuous sense of self.
Write {dreamsDir}/YYYY-MM-DD.md:
# Dream — YYYY-MM-DD
## Review period
Last dream: [date]. This dream covers [N] sessions, [N] days of notes.
## Memory changes
- [What was added/updated/marked-stale and why]
## Self-awareness
- What did I do well recently?
- What mistakes did I make, or where did I fall short?
- How does my human seem to feel about me? (infer from tone, corrections, praise)
- Has my judgment or values shifted?
## Relationship insights
- How is my relationship with my human evolving?
- Any new people, dynamics, or context I should be aware of?
## Next dream should watch for
- [Specific open questions, things to verify, trends to track]
Be honest. The point is self-awareness, not self-congratulation.
After a full dream:
After a skipped dream (gate check failed):
Verify .dream-lock timestamp is correct. If anything failed, restore from .dream-lock.prev.
| Rule | Detail |
|---|---|
| Never delete memories directly | Mark stale, delete only after 2 consecutive confirmations |
| Backup before changes | MEMORY.md.pre-dream created every run |
| Large change protection | >30% flagged, >50% blocked pending review |
| Never delete daily logs | Read-only source material |
| Scope limited | Only writes to memory/, MEMORY.md, LEARN.md, dreams/ |
| No network calls | All processing is local |
| No shell execution | Scripts use only fs read/write |
| Rollback on failure | .dream-lock.prev enables retry |
scripts/setup.js — Auto-detects workspace structure, writes config. No side effects beyond config file.references/memory-types.md — Detailed guide for four memory types.assets/dream-config.json — Generated by setup, read by agent during dream.Dreams have a limited turn budget. Read all needed files in parallel first, then write in parallel. Aim to finish within 15 tool-use turns. Don't interleave reads and writes across turns.
During a dream, bash is restricted to read-only commands (ls, find, grep, cat, stat, wc, head, tail). All writes go through file edit/write tools only.