memory management
by @xuchang9337-dev
A practical memory management system for OpenClaw: importance scoring, time-decay cleanup, write triggers, hybrid retrieval, and daily maintenance workflow.
clawhub install memory-management-lite📖 About This Skill
name: Memory Management / Management System slug: memory-management version: 1.0.0 homepage: https://clawhub.com/skills/memory-management description: "A practical memory management system for OpenClaw: importance scoring, time-decay cleanup, write triggers, hybrid retrieval, and daily maintenance workflow." changelog: "Converted from workspace/memory/MANAGEMENT.md (importance scoring + decay + recall + daily maintenance)." metadata: {"clawdbot":{"emoji":"🧠","requires":{"bins":[]},"os":["linux","darwin","win32"]}}
Memory Management Skill
This skill provides a unified workflow to write, retrieve, and maintain long-term / topic-based / short-term memories across OpenClaw sessions.
When to Use
Use it when you want the agent to consistently remember key preferences/decisions/facts across sessions, while preventing memory bloat via time-decay and daily cleanup.
Target Workspace Layout (suggested)
Assume your workspace root is ~/.openclaw/workspace/:
workspace/
├── MEMORY.md
├── AGENTS.md # optional
├── TOOLS.md # optional
├── HEARTBEAT.md # optional
└── memory/
├── preferences.md
├── decisions.md
├── projects.md
├── contacts.md
├── patterns.md
├── feedback.md
└── YYYY-MM-DD.md
Importance Scoring (1-5) before writing
When you are about to write a memory:
5: write to MEMORY.md (core principles, key decisions, core preferences)4: write to MEMORY.md (important rules/lessons repeated multiple times)3: write to memory/YYYY-MM-DD.md (general tasks/conversation worth retrieving)2: write to memory/YYYY-MM-DD.md (temporary/optional records)1: do not record (small talk/meaningless content)Strategy:
Time Decay & Cleanup (30+ days)
Short-term memory relevance decays with time:
Cleanup workflow:
1. Scan memory/*.md daily logs
2. For files older than 30 days: migrate worth-keeping content into MEMORY.md or topic files; delete/archive the rest
Manual Triggers (immediate write)
When the user says:
MEMORY.mdMEMORY.mdmemory/preferences.md
- decisions -> memory/decisions.md
- projects -> memory/projects.md
- contacts -> memory/contacts.md
- patterns / best practices -> memory/patterns.md
- feedback -> memory/feedback.mdAuto Recall (retrieve then answer)
Before answering questions about previous work/decisions/dates/people/preferences/tasks:
1. Run memory_search with the user query
2. If your system supports it, refine quotes with memory_get
3. If retrieval is insufficient, do not fabricate; tell the user you checked memory but found no strong evidence
Retrieval (hybrid: vector + keywords)
Use hybrid retrieval to balance semantic match and keyword precision (vector semantics + FTS terms).
Example:
openclaw memory search "query"
Daily Maintenance Workflow
Suggested time: 08:30 (adjust for your timezone).
Goals:
memory/YYYY-MM-DD.md existsMEMORY.md / topic filesCron Job Template (maintenance)
{
"schedule": { "kind": "cron", "expr": "30 8 * * *", "tz": "Asia/Shanghai" },
"payload": {
"kind": "agentTurn",
"message": "Run the daily memory maintenance workflow: create today's log, review yesterday, migrate worth-keeping content to MEMORY/topic files, then clean logs older than 30 days and output a concise structured report.",
"model": "YOUR_DEFAULT_MODEL",
"timeoutSeconds": 600
}
}
Safety & Preconditions
Safety:
Preconditions:
memorySearch is enabledMEMORY.md + memory/ logs)Related Skills
memory-setup: configure persistent memorySearchself-improvement: turn errors/corrections into learnable experiencescron-mastery: cron vs heartbeat time scheduling best practicesFeedback
clawhub star memory-managementclawhub syncname: Memory Management / Management System slug: memory-management version: 1.0.0 homepage: https://clawhub.com/skills/memory-management description: "A complete, practical memory management system: file layout, importance scoring, time-decay cleanup, write-trigger rules, hybrid retrieval, and daily maintenance workflow for OpenClaw." changelog: "Initial release converted from workspace/memory/MANAGEMENT.md (importance scoring + decay + recall + daily maintenance)." metadata: {"clawdbot":{"emoji":"🧠","requires":{"bins":[]},"os":["linux","darwin","win32"]}}
Memory Management Skill
This is a practical "memory management system" skill for OpenClaw. It provides a unified set of rules to write, retrieve, and maintain long-term / topic-based / short-term memories across sessions.
It turns the following capabilities into a clear workflow:
When to Use
Use this skill when you need:
Target Workspace Layout
Assume your workspace root directory is ~/.openclaw/workspace/. Use the following structure:
workspace/
├── MEMORY.md # long-term memory (core knowledge base; keep maintenance focused)
├── AGENTS.md # agent behavior / calling constraints snippet (optional)
├── TOOLS.md # tools / skill index (optional)
├── HEARTBEAT.md # heartbeat task (optional)
└── memory/
├── preferences.md # user preferences
├── decisions.md # important decisions
├── projects.md # project information
├── contacts.md # contacts
├── patterns.md # best practices / patterns
├── feedback.md # feedback records
└── YYYY-MM-DD.md # daily logs (short-term memory)
Memory File Templates (recommended templates)
You can start with minimal templates. Later maintenance tasks only need to update small blocks or append a few bullet points.
MEMORY.md (example structure):
# MEMORY.md — Long-Term MemoryAbout
User core preferences:
Important identity / background: Active Projects
Project name: status / key milestones / current risks Decisions & Lessons
Key decisions (why chosen):
Lessons learned (avoid repeating mistakes): Preferences
Communication style:
Tool preferences:
Avoided behaviors:
memory/preferences.md:
# preferences.mdCommunication
Preference: Tools & Workflows
Common tools:
Typical workflows:
memory/decisions.md:
# decisions.mdKey Decisions
Decision point:
Background:
Why this approach:
Possible future adjustments:
memory/patterns.md:
# patterns.mdBest Practices
Pattern name:
When to use:
Step-by-step:
Failure examples (optional):
Importance Scoring (1-5) before writing
Rule: when you are about to "write to memory", first score the content (1-5), then decide where to store it.
Suggested mapping:
MEMORY.mdMEMORY.mdmemory/YYYY-MM-DD.mdmemory/YYYY-MM-DD.mdSuggested write strategy:
Time Decay & Cleanup (30+ days)
Short-term memory retrieval weight decays over time:
Daily maintenance cleanup workflow (recommended):
1. Scan all YYYY-MM-DD.md files under memory/
2. For files older than 30 days:
- If there is "worth keeping" content, extract it into MEMORY.md (or topic files)
- Otherwise delete / archive
Manual Triggers (immediate write)
When the user says the following phrases, immediately start "write evaluation" and persist (after scoring importance):
MEMORY.mdMEMORY.mdmemory/preferences.md
- decisions -> memory/decisions.md
- projects -> memory/projects.md
- contacts -> memory/contacts.md
- patterns / best practices -> memory/patterns.md
- feedback -> memory/feedback.mdAuto Recall (retrieve then answer)
When a user question belongs to these categories, first perform memory retrieval, then answer:
Suggested retrieval chain:
1. Use memory_search to search relevant memories by query
2. If your system supports it, use memory_get to pull more precise excerpts for quoting
3. If confidence is still not enough: be transparent and say you checked memories but couldn't find sufficient relevant evidence
Retrieval (hybrid retrieval: vector semantics + keywords)
Suggested strategy: hybrid retrieval (vector semantics + FTS keywords).
You can configure similar parameters in OpenClaw's memorySearch configuration:
voyage (or your actual vector provider)["memory", "sessions"] (adjust as needed)"hot" (real-time updates; adjust if needed)0.3 (lower = more results)20Manual retrieval example (if your system supports it):
openclaw memory search "query"
Daily Maintenance Workflow (daily review / maintenance)
Suggested daily execution time: 08:30 (adjust for your timezone).
Maintenance goals:
memory/YYYY-MM-DD.mdpreferences.md / decisions.md / patterns.md / MEMORY.mdMaintenance flow (6-7 steps):
1. Optional system/gateway status checks
2. Optional model status checks
3. Optional API configuration checks
4. Configuration backups:
- Backup: openclaw.json -> openclaw.json.backup-YYYYMMDD
- Backup retention: keep at most the last 3 backups
- Sync/update independent backups for API keys (if you have files like .api-keys-backup.env)
5. Create today's log file if it doesn't exist
6. Review yesterday: extract key preferences/decisions/lessons and update MEMORY or topic files
7. Clean old logs (30+ days) and migrate "worth keeping" content before deleting
Backup shell command examples (you can copy into your cron payload):
cp ~/.openclaw/openclaw.json ~/.openclaw/openclaw.json.backup-$(date +%Y%m%d)
ls -t ~/.openclaw/openclaw.json.backup-* | tail -n +4 | xargs -r rm
cp ~/.openclaw/openclaw.json ~/.openclaw/.api-keys-backup.env
Cron Job Template (run maintenance)
In OpenClaw's cron jobs, a recommended pattern is: "isolated session + scheduled trigger + only maintenance tasks".
Example payload (showing the core fields you need to pay attention to: schedule and payload.message; the rest depends on your environment):
{
"schedule": { "kind": "cron", "expr": "30 8 * * *", "tz": "Asia/Shanghai" },
"payload": {
"kind": "agentTurn",
"message": "Run the daily memory maintenance workflow (7 steps): 1) Create memory/YYYY-MM-DD.md (if missing) 2) Review yesterday's memory and extract content worth long-termizing into MEMORY.md or topic files 3) Delete logs older than 30 days (migrate important content before deleting) 4) Optionally back up openclaw.json (keep last 3) 5) Generate a concise structured report with findings and recommendations.\\nRequirement: output must be structured and concise, focusing on maintenance results.",
"model": "YOUR_DEFAULT_MODEL",
"timeoutSeconds": 600
}
}
Notes:
YOUR_DEFAULT_MODEL with your default modelAGENTS.md Snippet (copy/paste)
Add the following snippet to your AGENTS.md (or whichever document constrains agent behavior):
### 🧠 Memory Management Rules (Memory Management Skill)1) Auto recall:
Before answering questions about previous work/decisions/dates/people/preferences/tasks, run memory_search first.
If retrieval is still uncertain, explain in the response that you checked memory but couldn't find enough evidence.
2) Manual write triggers:
When the user says: "remember this" / "save this" / "don't forget" / "permanently save" / "this is an important point" / "write to memory"
First evaluate the importance score (1-5), then write:
5-4 points: write to MEMORY.md
3-2 points: write to memory/YYYY-MM-DD.md
1 point: do not record 3) Time decay and cleanup:
Daily maintenance will clean logs older than 30 days; before deleting, migrate worth-keeping content to MEMORY.md or topic files.
4) Retrieval strategy:
Prefer hybrid retrieval (vector semantics + FTS keywords).
Safety & Preconditions
Safety advice:
MEMORY.md when you explicitly need it and it is controllable (long-term storage is more sensitive).Run prerequisites (recommended):
memorySearch enabled (otherwise "retrieval/recall" will not work)MEMORY.md + memory/ log directoryRelated Skills
memory-setup: configure persistent memorySearch (vector retrieval foundation)self-improvement: turn errors/corrections into learnable experiencescron-mastery: cron vs heartbeat time scheduling best practicesclawdhub: install/update/publish skillsFeedback
clawhub star memory-managementclawhub syncname: Memory Management / Management System slug: memory-management version: 1.0.0 homepage: https://clawhub.com/skills/memory-management description: "A complete, practical memory management system: file layout, importance scoring, time-decay cleanup, write-trigger rules, hybrid retrieval, and daily maintenance workflow for OpenClaw." changelog: "Initial release converted from workspace/memory/MANAGEMENT.md (importance scoring + decay + recall + daily maintenance)." metadata: {"clawdbot":{"emoji":"🧠","requires":{"bins":[]},"os":["linux","darwin","win32"]}}
Memory Management Skill
This is a practical "memory management system" skill for OpenClaw. It provides a unified set of rules to write, retrieve, and maintain long-term / topic-based / short-term memories across sessions.
It turns the following capabilities into a clear workflow:
When to Use
Use this skill when you need:
Target Workspace Layout
Assume your workspace root directory is ~/.openclaw/workspace/. Use the following structure:
workspace/
├── MEMORY.md # long-term memory (core knowledge base; keep maintenance focused)
├── AGENTS.md # agent behavior / calling constraints snippet (optional)
├── TOOLS.md # tools / skill index (optional)
├── HEARTBEAT.md # heartbeat task (optional)
└── memory/
├── preferences.md # user preferences
├── decisions.md # important decisions
├── projects.md # project information
├── contacts.md # contacts
├── patterns.md # best practices / patterns
├── feedback.md # feedback records
└── YYYY-MM-DD.md # daily logs (short-term memory)
Memory File Templates (recommended templates)
You can start with minimal templates. Later maintenance tasks only need to update small blocks or append a few bullet points.
MEMORY.md (example structure):
# MEMORY.md — Long-Term MemoryAbout
User core preferences:
Important identity / background: Active Projects
Project name: status / key milestones / current risks Decisions & Lessons
Key decisions (why chosen):
Lessons learned (avoid repeating mistakes): Preferences
Communication style:
Tool preferences:
Avoided behaviors:
memory/preferences.md:
# preferences.mdCommunication
Preference: Tools & Workflows
Common tools:
Typical workflows:
memory/decisions.md:
# decisions.mdKey Decisions
Decision point:
Background:
Why this approach:
Possible future adjustments:
memory/patterns.md:
# patterns.mdBest Practices
Pattern name:
When to use:
Step-by-step:
Failure examples (optional):
Importance Scoring (1-5) before writing
Rule: when you are about to "write to memory", first score the content (1-5), then decide where to store it.
Suggested mapping:
MEMORY.mdMEMORY.mdmemory/YYYY-MM-DD.mdmemory/YYYY-MM-DD.mdSuggested write strategy:
Time Decay & Cleanup (30+ days)
Short-term memory retrieval weight decays over time:
Daily maintenance cleanup workflow (recommended):
1. Scan all YYYY-MM-DD.md files under memory/
2. For files older than 30 days:
- If there is "worth keeping" content, extract it into MEMORY.md (or topic files)
- Otherwise delete / archive
Manual Triggers (immediate write)
When the user says the following phrases, immediately start "write evaluation" and persist (after scoring importance):
MEMORY.mdMEMORY.mdmemory/preferences.md
- decisions -> memory/decisions.md
- projects -> memory/projects.md
- contacts -> memory/contacts.md
- patterns / best practices -> memory/patterns.md
- feedback -> memory/feedback.mdAuto Recall (retrieve then answer)
When a user question belongs to these categories, first perform memory retrieval, then answer:
Suggested retrieval chain:
1. Use memory_search to search relevant memories by query
2. If your system supports it, use memory_get to pull more precise excerpts for quoting
3. If confidence is still not enough: be transparent and say you checked memories but couldn't find sufficient relevant evidence
Retrieval (hybrid retrieval: vector semantics + keywords)
Suggested strategy: hybrid retrieval (vector semantics + FTS keywords).
You can configure similar parameters in OpenClaw's memorySearch configuration:
voyage (or your actual vector provider)["memory", "sessions"] (adjust as needed)"hot" (real-time updates; adjust if needed)0.3 (lower = more results)20Manual retrieval example (if your system supports it):
openclaw memory search "query"
Daily Maintenance Workflow (daily review / maintenance)
Suggested daily execution time: 08:30 (adjust for your timezone).
Maintenance goals:
memory/YYYY-MM-DD.mdpreferences.md / decisions.md / patterns.md / MEMORY.mdMaintenance flow (6-7 steps):
1. Optional system/gateway status checks
2. Optional model status checks
3. Optional API configuration checks
4. Configuration backups:
- Backup: openclaw.json -> openclaw.json.backup-YYYYMMDD
- Backup retention: keep at most the last 3 backups
- Sync/update independent backups for API keys (if you have files like .api-keys-backup.env)
5. Create today's log file if it doesn't exist
6. Review yesterday: extract key preferences/decisions/lessons and update MEMORY or topic files
7. Clean old logs (30+ days) and migrate "worth keeping" content before deleting
Backup shell command examples (you can copy into your cron payload):
cp ~/.openclaw/openclaw.json ~/.openclaw/openclaw.json.backup-$(date +%Y%m%d)
ls -t ~/.openclaw/openclaw.json.backup-* | tail -n +4 | xargs -r rm
cp ~/.openclaw/openclaw.json ~/.openclaw/.api-keys-backup.env
Cron Job Template (run maintenance)
In OpenClaw's cron jobs, a recommended pattern is: "isolated session + scheduled trigger + only maintenance tasks".
Example payload (showing the core fields you need to pay attention to: schedule and payload.message; the rest depends on your environment):
{
"schedule": { "kind": "cron", "expr": "30 8 * * *", "tz": "Asia/Shanghai" },
"payload": {
"kind": "agentTurn",
"message": "Run the daily memory maintenance workflow (7 steps): 1) Create memory/YYYY-MM-DD.md (if missing) 2) Review yesterday's memory and extract content worth long-termizing into MEMORY.md or topic files 3) Delete logs older than 30 days (migrate important content before deleting) 4) Optionally back up openclaw.json (keep last 3) 5) Generate a concise structured report with findings and recommendations.\\nRequirement: output must be structured and concise, focusing on maintenance results.",
"model": "YOUR_DEFAULT_MODEL",
"timeoutSeconds": 600
}
}
Notes:
YOUR_DEFAULT_MODEL with your default modelAGENTS.md Snippet (copy/paste)
Add the following snippet to your AGENTS.md (or whichever document constrains agent behavior):
### 🧠 Memory Management Rules (Memory Management Skill)1) Auto recall:
Before answering questions about previous work/decisions/dates/people/preferences/tasks, run memory_search first.
If retrieval is still uncertain, explain in the response that you checked memory but couldn't find enough evidence.
2) Manual write triggers:
When the user says: "remember this" / "save this" / "don't forget" / "permanently save" / "this is an important point" / "write to memory"
First evaluate the importance score (1-5), then write:
5-4 points: write to MEMORY.md
3-2 points: write to memory/YYYY-MM-DD.md
1 point: do not record 3) Time decay and cleanup:
Daily maintenance will clean logs older than 30 days; before deleting, migrate worth-keeping content to MEMORY.md or topic files.
4) Retrieval strategy:
Prefer hybrid retrieval (vector semantics + FTS keywords).
Safety & Preconditions
Safety advice:
MEMORY.md when you explicitly need it and it is controllable (long-term storage is more sensitive).Run prerequisites (recommended):
memorySearch enabled (otherwise "retrieval/recall" will not work)MEMORY.md + memory/ log directoryRelated Skills
memory-setup: configure persistent memorySearch (vector retrieval foundation)self-improvement: turn errors/corrections into learnable experiencescron-mastery: cron vs heartbeat time scheduling best practicesclawdhub: install/update/publish skillsFeedback
clawhub star memory-managementclawhub sync