Install
openclaw skills install @hanningwang/memory-lifecycleStructured memory management to resolve cliff-edge forgetting, false persistence, context blowup, contradictions, hallucinated recall, and stale accumulation. Use when the user states anything durable to carry across sessions — preferences, corrections, decisions, team/environment facts, or standing instructions ('from now on...', 'always X before Y', 'never...') even without saying 'remember'; for first-time setup, compaction flush, deep research or project work, recalling a past session missing from context, when MEMORY.md exceeds its size threshold, or on 'init memory' / 'promote memory' / 'compact memory' / 'workspace init'.
openclaw skills install @hanningwang/memory-lifecycleStructured memory management built on openclaw's memory infrastructure. Provides structure for the pre-compaction memory flush (what to encode and how), defines promote rules for moving entries from daily files to MEMORY.md, compact rules for pruning stale entries, and project workspaces for detail that doesn't fit in MEMORY.md. Retrieval uses the platform's memory_search tool (hybrid BM25 + vector), which automatically indexes all memory/**/*.md files.
Three layers with progressive loading:
| Layer | File | Injected? | Managed by |
|---|---|---|---|
| Daily | memory/YYYY-MM-DD.md | Today + yesterday at session start | Flush prompt (auto) |
| Longterm | MEMORY.md | Always (full content) | Promote + Compact |
| Permanent | SOUL.md + AGENTS.md | Always (full content) | User only |
Supporting files:
memory/projects/{name}/ — project workspaces (loaded on-demand via pointers in MEMORY.md)memory/.lifecycle.log — operation audit logmemory/.memory-backup.md — MEMORY.md backup before modificationMEMORY.md is always in context but has a size ceiling (30K chars). For detailed knowledge — deployment runbooks, research reports, project architecture, recurring workflows — use project workspaces:
MEMORY.md (always in context):
- Service A deployment | see memory/projects/service-a-deployment/
memory/projects/service-a-deployment/runbook.md (loaded when needed):
Full step-by-step procedure, env vars, rollback steps, gotchas
Agent sees the pointer in MEMORY.md, reads the workspace file only when the task requires it.
If memory/.lifecycle.log does not exist, run init. See init.md.
Triggered when the user explicitly or implicitly states something lasting:
Do not compose your response yet. First write the entry to MEMORY.md in the appropriate section (## User, ## Knowledge, ## Rules, etc.):
- {content} | EXPLICIT | from:YYYY-MM-DD
If the content is detailed (multi-step procedure, analysis, etc.), create a project workspace instead and add a pointer to MEMORY.md.
Then respond to the user and confirm. Persistence before acknowledgment.
The platform triggers a silent agentic turn when the session approaches the context window limit. The goal is to encode durable information from this session into today's daily file before compaction.
If the conversation was trivial (single-question lookup, no decisions, no new information), reply NO_REPLY.
Read memory/YYYY-MM-DD.md if it exists. Append a new session section (do not overwrite earlier sessions from today).
Write a session section with this structure:
## Session {HH:MM}
### Key Events
- {event}
### Knowledge Learned
- {fact}
### User Preferences
- {preference} | EXPLICIT or INFERRED
### Decisions Made
- {decision}
### Unfinished
- {item}
Only record non-trivial, specific information. Skip filler.
Promote qualifying entries to MEMORY.md:
from:YYYY-MM-DD.## In Progress as - [ ] {task} | from:YYYY-MM-DD (skip if already tracked).Before promoting, backup MEMORY.md to memory/.memory-backup.md. Log each promotion to memory/.lifecycle.log.
If MEMORY.md exceeds 30K chars after promotion, run compact. See promote-compact.md.
See flush-prompt.md for the openclaw.json memoryFlush configuration.
When the user asks about something from a previous session and the answer is not in MEMORY.md or current context:
Use the memory_search tool to search across daily files and MEMORY.md. The platform automatically indexes all memory/**/*.md files with hybrid BM25 + vector search.
If the search finds relevant entries in daily files, present findings to the user. If the information deserves long-term persistence, promote it to MEMORY.md with from:YYYY-MM-DD.
Scan daily files from the last 7 days. For each entry, check against MEMORY.md — skip duplicates, promote qualifying entries, resolve conflicts. See promote-compact.md for the full checklist.
When MEMORY.md grows beyond 30K chars or contains visibly stale/redundant entries, run compact: decay old entries, merge duplicates, supersede contradictions. See promote-compact.md for the full checklist.
When the user asks for research, analysis, wants to create/work on a project, or teaches a multi-step procedure worth persisting:
Create memory/projects/{name}/ (or append if exists). See workspace-init.md for structure.
Write findings, procedures, or analysis to workspace files.
Add a one-line pointer to MEMORY.md ## Projects:
- {name} | {one-line description} | memory/projects/{name}/
Present key findings in chat. The workspace holds the detail; MEMORY.md holds the index.
| Entry type | Action |
|---|---|
| EXPLICIT | Promote immediately with from:YYYY-MM-DD |
| INFERRED, 3+ daily files | Promote |
| INFERRED, 1-2 days | Leave in daily file |
| Credential | Reject — pointer only |
| Detailed procedure / analysis | Create project workspace + pointer instead |
| Entry type | Action |
|---|---|
Non-[perm], not relevant 60+ days | Delete |
In Progress [x] older than 7 days | Delete |
In Progress [ ] not updated 60 days | Delete |
| Same topic, multiple entries | Merge |
[perm] | Never touch |
Newer > Older. EXPLICIT > INFERRED. User correction > all. AGENTS.md > everything.
When a MEMORY.md entry is disputed: look up from:YYYY-MM-DD, use memory_search or read the daily file to find the original context. If wrong or stale, update MEMORY.md and log the correction.
Never store credentials, API keys, tokens, or connection strings. Replace with location pointers. Always backup MEMORY.md before modifying. Always log operations to memory/.lifecycle.log.
Entry format: - {content} | EXPLICIT or INFERRED | from:YYYY-MM-DD | [perm]
EXPLICIT — user stated directlyINFERRED — deduced from behaviorfrom:YYYY-MM-DD — date of daily file with original context[perm] — immune to compaction decay (only the user tags this)Project pointer format: - {name} | {description} | memory/projects/{name}/
In Progress format: - [ ] {task} | from:YYYY-MM-DD (open) → - [x] {task} | from:YYYY-MM-DD (done)
### Unfinished items captured during flush become [ ] entries here.[x] when the work completes. Compact then purges done items quickly (7 days) and reaps abandoned open items (60 days).Sections: ## User / ## Projects / ## Team / ## Knowledge / ## Rules / ## In Progress
User: "Remember that staging uses port 3001"
Write to MEMORY.md ## Knowledge:
- Staging uses port 3001 | EXPLICIT | from:2026-05-08
Respond: "Recorded — staging uses port 3001."
Session discussed Redis migration and decided to switch packages:
Append to memory/2026-05-08.md:
## Session 14:30
### Decisions Made
- Switch from ioredis to redis package for auth-service
### Unfinished
- Connection pooling not yet configured
Promote the decision to MEMORY.md:
- Switch from ioredis to redis for auth-service | EXPLICIT | from:2026-05-08
User: "Deploy service A"
Agent sees in MEMORY.md (already in context):
- Service A deployment | production deploy procedure | memory/projects/service-a-deployment/
Agent reads memory/projects/service-a-deployment/runbook.md, follows the steps.
User explains a complex deploy procedure over a long conversation.
Agent creates memory/projects/service-a-deployment/runbook.md with full steps, adds pointer to MEMORY.md:
- Service A deployment | production deploy procedure | memory/projects/service-a-deployment/