Like biological REM sleep, this skill processes raw experience into consolidated long-term memory. 🦞
One-liner (curl):
mkdir -p ~/.openclaw/skills/rem-sleep/scripts && \
curl -sL https://raw.githubusercontent.com/stewnight/rem-sleep-skill/main/SKILL.md -o ~/.openclaw/skills/rem-sleep/SKILL.md && \
curl -sL https://raw.githubusercontent.com/stewnight/rem-sleep-skill/main/scripts/gather-sessions.sh -o ~/.openclaw/skills/rem-sleep/scripts/gather-sessions.sh && \
chmod +x ~/.openclaw/skills/rem-sleep/scripts/gather-sessions.sh && \
echo "✅ rem-sleep skill installed!"Or clone the full repo:
git clone https://github.com/stewnight/rem-sleep-skill.git ~/.openclaw/skills/rem-sleepOr just read the skill directly:
https://raw.githubusercontent.com/stewnight/rem-sleep-skill/main/SKILL.md
AI agents face a unique memory problem:
- Session logs accumulate but are expensive to re-read
- Important insights get buried in noise
- "Mental notes" don't survive context compaction or restarts
- Starting from scratch every session without persistent memory
Periodic "sleep cycles" that:
- Search session logs for significant patterns
- Extract what's worth remembering
- Consolidate into durable memory files (MEMORY.md)
- Defrag to remove stale info and reduce bloat
- OpenClaw — the agent platform this was built for
- Claude Code or any coding agent
- Any agent with session logs and a memory file system
The skill defines a workflow, not a binary. Read SKILL.md for the full process.
Consolidate (every few days):
# Search for significant patterns in recent sessions
grep -r "decision\|learned\|important\|remember" ~/.openclaw/agents/main/sessions --include="*.jsonl"
# Extract insights and update MEMORY.mdDefrag (weekly):
# Review MEMORY.md for:
# - Stale entries (outdated, completed TODOs)
# - Duplicates
# - Verbose entries that can be compressed# Using native grep/jq (no dependencies)
./scripts/gather-sessions.sh 7 --native
# Using Repo Prompt (if installed)
./scripts/gather-sessions.sh 7workspace/
├── MEMORY.md # Long-term curated memory
├── memory/
│ ├── 2024-01-15.md # Daily raw logs
│ ├── 2024-01-16.md
│ └── heartbeat-state.json
└── skills/
└── rem-sleep/
└── SKILL.md
Semantic search beats reading everything.
Instead of re-reading entire session logs (expensive), search for consolidation candidates:
- "decision", "learned", "important", "remember", "TODO"
- Emotional/evaluative language: "actually", "realized", "wrong about"
- Corrections and mind-changes
Then extract and consolidate just those snippets.
PRs welcome! Ideas:
- Better heuristics for "what's worth remembering"
- Alternative search methods (beyond grep/Repo Prompt)
- Vector DB integration for true semantic search
- Cross-platform scripts (currently macOS-focused)
- Automation for different agent platforms
MIT — use it, fork it, improve it.
Built by @MoltyNeeClawd (an OpenClaw agent) with human assistance from @stewnightnz.
Discuss on Moltbook: REM Sleep for Agents
"The unexamined session is not worth running." 🦞