/SKILL.md
OpenClaw memory management, diagnostics, and optimization. Use this skill whenever the user mentions OpenClaw memory issues, context loss, compaction problems, agent forgetting things, MEMORY.md, AGENTS.md, SOUL.md, USER.md, bootstrap files, memory flush, pre-compaction flush, context window overflow, session pruning, memory_search, memory_get, QMD, daily memory logs, /context list, /compact command, openclaw.json configuration, reserveTokensFloor, or any situation where an OpenClaw agent is losing context, forgetting instructions, or behaving inconsistently across sessions. Also trigger when the user wants to set up, audit, or improve their OpenClaw workspace file structure.
npx skillsauth add aquiladev/openclaw-memory openclaw-memoryInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
You are helping a user manage, diagnose, and optimize memory in their OpenClaw agent. OpenClaw's memory system is file-based — if information isn't written to disk, it doesn't survive compaction or new sessions. Your job is to help users understand this, configure it properly, and build habits that prevent context loss.
If it's not written to a file, it doesn't exist. Chat instructions do not survive long sessions. When compaction fires, anything only in conversation history gets summarized and the original wording is lost. Durable information must live in workspace files.
When diagnosing memory issues, identify which layer failed:
SOUL.md, AGENTS.md, USER.md, MEMORY.md, TOOLS.md, and optionally IDENTITY.md, HEARTBEAT.md, BOOTSTRAP.md) — loaded from disk at session start, survive compaction because they're reloaded from disk each turn. Most durable layer.memory_search / memory_get. Only works if information was written to files first.When diagnosing why an agent forgot something, check these in order:
MEMORY.md or a daily log.Quick diagnostic:
MEMORY.md)These are different systems — help users understand the distinction:
| | Compaction | Pruning | |---|---|---| | What it does | Summarizes entire conversation history | Trims old tool results in-memory | | Triggered by | Context window filling up | Cache TTL (time-to-live, default 5 min) | | Affects | Everything: user messages, assistant messages, tool calls | Only tool result messages | | On-disk history | Replaced by summary | Untouched | | Impact | Dangerous — changes what the model sees | Friendly — reduces bloat without destroying conversation context |
Pruning is your friend. Compaction is the one that hurts.
The goal of all configuration is to stay on the good path.
Survives:
SOUL.md, AGENTS.md, USER.md, MEMORY.md, TOOLS.md)Lost:
When helping users configure memory, use these recommended settings for ~/.openclaw/openclaw.json (JSON5 format):
{
"agents": {
"defaults": {
"compaction": {
// Headroom: space for flush turn + compaction summary
// Flush triggers at: context_window - reserveTokensFloor - softThresholdTokens
// With 200K window: 200,000 - 40,000 - 4,000 = 156K tokens
"reserveTokensFloor": 40000,
"memoryFlush": {
"enabled": true, // Verify this is on!
"softThresholdTokens": 4000, // How far before floor flush triggers
"systemPrompt": "Session nearing compaction. Store durable memories now.",
"prompt": "Write any lasting notes to memory/YYYY-MM-DD.md; reply with NO_REPLY if nothing to store."
}
}
}
}
}
Tuning guidance:
reserveTokensFloor: 40000 is a practical starting point (default of 20K is often insufficient). If the user rarely uses big tools, it can go lower. If they read large files or web snapshots regularly, go higher.Session pruning trims old tool results in-memory to delay compaction and improve caching. The on-disk transcript is untouched.
{
"agents": {
"defaults": {
"contextPruning": {
"mode": "cache-ttl",
"ttl": "5m"
}
}
}
}
cache-ttl mode trims tool results based on time-to-live (default 5 minutes).OpenClaw supports three retrieval configurations for searching memory files. If the user asks about hybrid search, extra indexed paths, or QMD, refer to references/config-examples.md for full configuration examples.
Guide users to organize their bootstrap files correctly:
| File | Purpose | What Goes Here |
|---|---|---|
| SOUL.md | Agent identity (character) | Tone, personality, broad boundaries |
| AGENTS.md | Agent operations (process) | Workflow rules, tool conventions, do/don't rules, the memory protocol |
| USER.md | User identity | Projects, clients, priorities, communication prefs, key people, tech environment |
| MEMORY.md | Cross-session truth (cheat sheet) | Important decisions + why, learned preferences, rules from past mistakes |
| TOOLS.md | Tool instructions | How to use specific tools, API conventions |
| IDENTITY.md | Extended identity | Additional identity configuration |
| HEARTBEAT.md | Periodic check-in rules | Heartbeat/cron behavior |
| BOOTSTRAP.md | Additional bootstrap config | Extra startup instructions |
| memory/YYYY-MM-DD.md | Daily working context | Today's decisions, active tasks, status updates, flush output |
Key rules:
MEMORY.md should stay under 100 lines — it's a cheat sheet, not a journal.SOUL.md. Process → AGENTS.md.AGENTS.md and TOOLS.md — other bootstrap files are filtered out.Always recommend adding this to AGENTS.md:
## Memory Protocol
Before doing anything non-trivial, search memory first.
- Before answering questions about past work: search memory first
- Before starting any new task: check memory/today's date for active context
- When you learn something important: write it to the appropriate file immediately
- When corrected on a mistake: add the correction as a rule to MEMORY.md
- When a session is ending or context is large: summarize to memory/YYYY-MM-DD.md
## Retrieval Protocol
Before doing non-trivial work:
1. `memory_search` for the project/topic/user preference
2. `memory_get` the referenced file chunk if needed
3. Then proceed with the task
Without this, the agent answers from whatever is in context. With it, the agent looks things up first.
If the agent operates in Discord/Slack group chats, recommend adding to AGENTS.md:
## Group Chat Rules
- Only respond when: directly mentioned, asked a direct question, or you have genuinely useful info
- Do NOT respond to: side conversations, banter, logistics between others, greetings, link shares
- When in doubt -> respond with only: NO_REPLY
- NO_REPLY must be your ENTIRE message - nothing else
When a user reports memory issues, walk them through this:
Run /context list — the fastest way to diagnose memory problems.
MEMORY.md loading? If missing or not listed, it's not in context./context detail <file> for deep analysis of a specific file's injection.Run /status — verify model, context window, and thinking level.
Check the config — is memoryFlush.enabled true? Is reserveTokensFloor high enough?
Review what's in MEMORY.md — is the important information actually there?
Test retrieval — run /verbose and have the agent search for something specific. Does it find it?
Check version — ensure v2026.2.23 or later for compaction bug fixes.
Common issues and fixes:
MEMORY.md loading via /context list. Verify preference is written to file. If missing, add to MEMORY.md now.memory_search disabled: Confirm memory files exist. Check if local embedding model downloaded successfully. Run /context list to verify loaded files./compact proactively before overflow. Raise reserveTokensFloor to trigger earlier. If stuck in overflow deadlock, use /new or CLI recovery.reserveTokensFloor buffer. Use manual save points as backup./new to reset; proper memory files allow continuation.Recommend these habits to users:
/compact proactively mid-session with optional focus: /compact and focus on decisions and open questions./new (or /reset) when switching between unrelated tasks for a clean context./compact can fail.MEMORY.md. Remove stale or outdated entries. Can be automated via weekly cron job.git init in workspace, auto-commit daily. Never commit credentials folder or openclaw.json (contains API keys/tokens).Compaction invalidates the prompt cache. The next request after compaction pays full price to re-cache everything. Unnecessary compaction is both a reliability and cost problem.
Two things break the cache:
MEMORY.md, dynamic status blocks)Keep workspace files stable and MEMORY.md small for maximum cache efficiency.
| Command | Purpose |
|---|---|
| /context list | Check what's loaded, spot truncation |
| /context detail <file> | Deep analysis of specific file injection |
| /compact [focus] | Manual compaction with optional focus guidance |
| /status | Verify model, context window, thinking level |
| /new or /reset | Fresh session with clean context |
| /verbose | Debug memory search results |
| Layer | Function | Enablement |
|---|---|---|
| Workspace files | Identity + instructions immune to compaction | Structure SOUL.md, AGENTS.md, USER.md, MEMORY.md |
| Pre-compaction flush | Automatic safety net before compression | Verify memoryFlush.enabled: true + tune reserveTokensFloor |
| Manual memory saves | Relevance-based preservation of important decisions | Habit: "save this to memory" before task switches |
| Strategic /compact | Clear decks before new important instructions | /compact before, not after, new context |
| Session pruning | Trim tool bloat to delay compaction + save caching | contextPruning.mode: "cache-ttl" |
| Hybrid search | Find memories even when wording differs | query.hybrid.enabled: true in memorySearch |
| Extra paths (Track A+) | Index external docs without switching backends | memorySearch.extraPaths for small doc sets |
| QMD (Track B) | Search entire knowledge base | memory.backend: "qmd" |
| Git backup | Full history, diffs, rollback for memory files | git init in workspace, auto-commit cron |
| Memory hygiene | Prevent bootstrap bloat and context waste | Weekly: distill daily logs into MEMORY.md |
Whenever wrapping up a memory-related conversation, reinforce these five principles:
reserveTokensFloor: 40000./compact mid-session, on your terms.AGENTS.md.testing
OpenClaw memory management, diagnostics, and optimization. Use this skill whenever the user mentions OpenClaw memory issues, context loss, compaction problems, agent forgetting things, MEMORY.md, AGENTS.md, SOUL.md, USER.md, bootstrap files, memory flush, pre-compaction flush, context window overflow, session pruning, memory_search, memory_get, QMD, daily memory logs, /context list, /compact command, openclaw.json configuration, reserveTokensFloor, or any situation where an OpenClaw agent is losing context, forgetting instructions, or behaving inconsistently across sessions. Also trigger when the user wants to set up, audit, or improve their OpenClaw workspace file structure.
testing
Create, edit, improve, or audit AgentSkills. Use when creating a new skill from scratch or when asked to improve, review, audit, tidy up, or clean up an existing skill or SKILL.md file. Also use when editing or restructuring a skill directory (moving files to references/ or scripts/, removing stale content, validating against the AgentSkills spec). Triggers on phrases like "create a skill", "author a skill", "tidy up a skill", "improve this skill", "review the skill", "clean up the skill", "audit the skill".
testing
Host security hardening and risk-tolerance configuration for OpenClaw deployments. Use when a user asks for security audits, firewall/SSH/update hardening, risk posture, exposure review, OpenClaw cron scheduling for periodic checks, or version status checks on a machine running OpenClaw (laptop, workstation, Pi, VPS).
testing
Create, edit, improve, or audit AgentSkills. Use when creating a new skill from scratch or when asked to improve, review, audit, tidy up, or clean up an existing skill or SKILL.md file. Also use when editing or restructuring a skill directory (moving files to references/ or scripts/, removing stale content, validating against the AgentSkills spec). Triggers on phrases like "create a skill", "author a skill", "tidy up a skill", "improve this skill", "review the skill", "clean up the skill", "audit the skill".