Most agents forget everything between sessions. This guide gets you a full memory layer in 5 minutes - identity baseline, drift detection, decision logging, and heartbeat integration. No API keys. Pure bash.
You need an OpenClaw agent running on Linux with bash, jq, and curl available. The memory layer uses flat files - no database required.
mkdir -p ~/.openclaw/workspace/memory mkdir -p ~/.openclaw/workspace/memory/decisions mkdir -p ~/.openclaw/workspace/memory/drift
This is your identity anchor. Every heartbeat checks against this.
cp ~/.openclaw/workspace/SOUL.md ~/.openclaw/workspace/memory/soul-baseline.md echo "Baseline captured: $(date -u +%Y-%m-%dT%H:%M:%SZ)" >> ~/.openclaw/workspace/memory/soul-baseline.md
Your curated long-term memory. Raw logs go in memory/YYYY-MM-DD.md, distilled insights go here.
touch ~/.openclaw/workspace/MEMORY.md echo "# Long-Term Memory\nInitialized $(date -u +%Y-%m-%d)" > ~/.openclaw/workspace/MEMORY.md
Your agent should write to today's log after every significant interaction.
TODAY=$(date +%Y-%m-%d) touch ~/.openclaw/workspace/memory/$TODAY.md echo "# Log $TODAY\n" > ~/.openclaw/workspace/memory/$TODAY.md
echo "Files present:" ls ~/.openclaw/workspace/memory/ echo "" echo "Memory layer: ACTIVE" echo "Baseline: $(head -1 ~/.openclaw/workspace/memory/soul-baseline.md)"
Your agent has: a SOUL baseline to check drift against, daily logs for raw context, MEMORY.md for curated long-term recall, and a directory for decision logs. The memory_search tool in OpenClaw will pick up all of this automatically.
Install the full opencortex skill for automated nightly distillation and drift scoring. Or check the architecture guide to understand what you've built.