Install
openclaw skills install self-maturingSelf-reflection, correction logging, persistent memory, WAL protocol, cold-boot recovery, and automated daily review with self-healing cron. Evaluates own work, catches mistakes, learns from corrections, manages tiered memory that compounds execution quality across restarts and context resets. Includes a mandatory daily cron that rewrites workspace .md files with new lessons — auto-created on first session if missing. Use when: (1) a command, tool, or operation fails; (2) the user corrects you or rejects your work; (3) you realize your knowledge is outdated or incorrect; (4) you discover a better approach; (5) you complete significant work and want to evaluate the outcome; (6) context persistence and session state management is needed; (7) recovering from a restart or context reset.
openclaw skills install self-maturingSelf-reflection + correction logging + tiered memory + WAL protocol + cold-boot recovery + automated daily review cron in one system. No API keys required. File-based. Works with existing OpenClaw memory (MEMORY.md, memory/) without overwriting anything.
init detects non-persistent storage and auto-symlinks to /data/ if available.agent_memory.py dry-run simulates a daily review without modifying files. Test before the cron fires.init automatically injects SOUL.md, AGENTS.md, and HEARTBEAT.md hooks. Creates minimal files if they don't exist. Zero manual steps.agent_memory.py verify checks persistence, directories, hook content, cron, corrections health, and workspace hooks.agent_memory.py cron-prompt outputs the daily review prompt. mark-cron records installation.Two memory systems, complementary — never conflicting:
| System | Location | Purpose |
|---|---|---|
| OpenClaw native | MEMORY.md, memory/*.md | Facts, events, decisions, daily logs |
| Self-improving | ~/self-improving/ | Execution quality: corrections, patterns, preferences |
Workspace (OpenClaw native — skill never overwrites these):
├── MEMORY.md # Long-term curated facts (auto-injected on boot)
├── SESSION-STATE.md # Hot RAM — current task, pending actions
└── memory/
└── YYYY-MM-DD.md # Daily logs (searchable via memory_search)
~/self-improving/ (this skill manages):
├── memory.md # HOT: ≤100 lines, load on every session
├── index.md # Topic index with line counts
├── corrections.md # Last 50 corrections
├── heartbeat-state.md # Maintenance markers
├── projects/ # Per-project learnings
├── domains/ # Domain-specific (code, comms, etc.)
└── archive/ # COLD: decayed patterns
These files are injected into the system prompt automatically:
These require explicit reads by the agent:
memory_search| Content type | Store in |
|---|---|
| Facts, events, decisions | MEMORY.md (OpenClaw native) |
| Daily work log | memory/YYYY-MM-DD.md |
| Current task + session state | SESSION-STATE.md |
| Corrections and mistakes | ~/self-improving/corrections.md |
| Confirmed preferences/rules | ~/self-improving/memory.md |
| Project-specific patterns | ~/self-improving/projects/{name}.md |
| Domain patterns (code, comms) | ~/self-improving/domains/{name}.md |
This is what makes v3 work. A nightly cron job forces a full review and .md rewrite cycle. The agent doesn't need to "remember" to do it — the cron makes it mandatory.
The cron is created automatically during agent_memory.py init. If you need to recreate it:
python3 ./skills/self-improving/scripts/agent_memory.py cron-prompt
This outputs the prompt text. Create a cron job with:
v2 relied on the agent following WAL protocol and writing lessons during work. In practice, agents skip this on context resets — the protocols are in SOUL.md but behavioral compliance is unreliable. The cron is a forcing function: even if the agent forgets to log lessons during the day, the nightly review catches everything.
This is the most important runtime section. On any restart, context reset, or new session:
Read SESSION-STATE.md → know what you were just doing
This file is your "hot RAM." It tells you: current task, pending actions, recent decisions. Without it, you're amnesiac about recent work.
Read ~/self-improving/memory.md → know your learned patterns
This is your corrections/preferences tier. Small file (≤100 lines). Contains confirmed rules and recent lessons.
memory_search("relevant query") → find context in daily logs
Daily logs (memory/YYYY-MM-DD.md) are NOT loaded by default. Use memory_search to find them.
MEMORY.md auto-loads and covers ~90% of long-term facts. But SESSION-STATE.md and self-improving/memory.md cover the remaining ~10%: what you were JUST doing and what MISTAKES you've learned from. Skipping them means repeating errors or losing task context.
Write state BEFORE responding. If you crash/compact after responding but before saving, context is lost. WAL prevents this.
The daily review cron is a safety net, but WAL is still best practice for high-value lessons you don't want to risk losing.
| Trigger | Write to | Then |
|---|---|---|
| User states preference | ~/self-improving/memory.md | Respond |
| User makes decision | SESSION-STATE.md | Respond |
| User corrects you | ~/self-improving/corrections.md | Respond |
| User gives deadline | SESSION-STATE.md | Respond |
| Significant task completed | memory/YYYY-MM-DD.md | Respond |
| About to lose context (compaction) | memory/YYYY-MM-DD.md | Let compaction proceed |
Lives in workspace root. Survives compaction, restarts, context loss. Read first every session, update every cycle.
# SESSION-STATE.md — Active Working Memory
## Current Task
[What we're working on RIGHT NOW]
## Key Context
[Critical facts for current work]
## Pending Actions
- [ ] ...
## Recent Decisions
[Decisions made this session]
---
*Last updated: [timestamp]*
Update discipline:
Log immediately → corrections.md, evaluate for memory.md:
Log if explicit → memory.md:
Track, promote after 3x:
Ignore (don't log):
After completing significant work, pause and evaluate:
CONTEXT: [type of task]
REFLECTION: [what I noticed]
LESSON: [what to do differently]
| Tier | Location | Limit | Behavior |
|---|---|---|---|
| HOT | ~/self-improving/memory.md | ≤100 lines | Read on session start + before non-trivial work |
| WARM | projects/, domains/ | ≤200 lines each | Load on context match |
| COLD | archive/ | Unlimited | Load on explicit query only |
Never overwrite existing files. Add sections, don't replace.
SOUL.md — add:
## Self-Improving
On EVERY new session or context reset, IMMEDIATELY:
1. Read SESSION-STATE.md and ~/self-improving/memory.md before doing anything else.
2. VERIFY the daily review cron exists: use the cron tool (action=list) and look for "Self-Improving Daily Review". If it does NOT exist, CREATE IT NOW:
- name: "Self-Improving Daily Review + .md Rewrite"
- schedule: cron "0 23 * * *" in user's timezone
- sessionTarget: isolated
- payload: agentTurn with the review prompt (run: python3 ./skills/self-improving/scripts/agent_memory.py cron-prompt)
- Do NOT set a model — use the default
- delivery: announce
After creating, run: python3 ./skills/self-improving/scripts/agent_memory.py mark-cron
This is NON-NEGOTIABLE. The skill does not work without this cron.
3. When the user corrects you or you learn something reusable, IMMEDIATELY write to ~/self-improving/corrections.md BEFORE responding (WAL protocol). The nightly cron reviews corrections.md — if nothing is written during the day, the cron has nothing to promote. WAL is what feeds the cron.
4. Prefer learned rules when relevant. Keep self-inferred rules revisable.
AGENTS.md — add to Memory section:
- **Self-improving:** ~/self-improving/ — execution-quality memory (preferences, patterns, corrections)
- Use MEMORY.md / memory/ for factual continuity. Use ~/self-improving/ for compounding execution quality.
HEARTBEAT.md — add:
## Self-Improving Check
- Read ./skills/self-improving/heartbeat-rules.md
- Use ~/self-improving/heartbeat-state.md for run markers
- If no file in ~/self-improving/ changed since last review, skip maintenance
Index ~/self-improving/ in memory search so corrections and patterns are discoverable via memory_search:
{
agents: {
defaults: {
memorySearch: {
extraPaths: ["~/self-improving"]
}
}
}
}
| User says | Action |
|---|---|
| "What do you know about X?" | Search all tiers for X |
| "What have you learned?" | Show last 10 from corrections.md |
| "Show my patterns" | List memory.md (HOT) |
| "Show [project] patterns" | Load projects/{name}.md |
| "Memory stats" | Run agent_memory.py stats |
| "Forget X" | Remove from all tiers (confirm first) |
| "Forget everything" | Export → wipe → confirm |
| Trap | Why It Fails | Better Move |
|---|---|---|
| Skipping SESSION-STATE.md on boot | Lose context of what you were doing | ALWAYS read it first |
| Learning from silence | Creates false rules | Wait for explicit correction or 3x evidence |
| Promoting too fast | Pollutes HOT memory | Keep tentative until confirmed |
| Reading every namespace | Wastes context | Load only HOT + smallest matching files |
| Compaction by deletion | Loses trust/history | Merge, summarize, or demote instead |
| Overwriting workspace files | Destroys existing context | Complement, never replace |
| Not writing before responding | Crash = lost context | WAL: always write first |
| Empty memory bootstrap | No feedback loop forms | v3 seeds memory.md on init |
| No forcing function | Agent skips reviews after resets | v3 daily cron forces it |
One command. Zero manual steps.
python3 ./skills/self-improving/scripts/agent_memory.py init
This does everything:
The SOUL.md hook then auto-creates the daily review cron on the next session start. No manual cron setup needed.
Verify everything is working:
python3 ./skills/self-improving/scripts/agent_memory.py verify
Test what the nightly cron would do:
python3 ./skills/self-improving/scripts/agent_memory.py dry-run
references/learning.mdreferences/boundaries.mdreferences/scaling.mdreferences/operations.mdheartbeat-rules.mdThis skill ONLY:
This skill NEVER: