memory management

Prompts

A practical memory management system for OpenClaw: importance scoring, time-decay cleanup, write triggers, hybrid retrieval, and daily maintenance workflow.

Install

openclaw skills install memory-management-lite

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:

  • De-duplicate / merge similar memories when possible
  • Only persist when it will be useful for future retrieval or reuse

Time Decay & Cleanup (30+ days)

Short-term memory relevance decays with time:

  • Same day: 1.0
  • 1-7 days: 0.8
  • 8-30 days: 0.5
  • 30+ days: 0 (clean/archive during daily maintenance)

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:

  • "remember this" / "save this": evaluate importance and write to the right place
  • "don't forget" / "permanently save": write to MEMORY.md
  • "this is an important point": write to MEMORY.md
  • "write to memory": write by type:
    • preferences -> memory/preferences.md
    • decisions -> memory/decisions.md
    • projects -> memory/projects.md
    • contacts -> memory/contacts.md
    • patterns / best practices -> memory/patterns.md
    • feedback -> memory/feedback.md

Auto 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:

  • Ensure memory/YYYY-MM-DD.md exists
  • Review yesterday and extract long-term-worthy content into MEMORY.md / topic files
  • Clean logs older than 30 days
  • Optionally generate a short report

Cron 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:

  • Do not write sensitive information (accounts/keys/private content) into shared or long-term memory.

Preconditions:

  • memorySearch is enabled
  • Workspace has the expected layout (MEMORY.md + memory/ logs)
  • Daily maintenance is scheduled (cron or equivalent)

Related Skills

  • memory-setup: configure persistent memorySearch
  • self-improvement: turn errors/corrections into learnable experiences
  • cron-mastery: cron vs heartbeat time scheduling best practices

Feedback

  • If useful: clawhub star memory-management
  • Stay updated: clawhub sync

name: 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:

  • Evaluate an "importance score" before writing, and decide where to store the memory
  • Use time-decay for short-term memories, and clean them during daily maintenance
  • Provide manual trigger phrases (e.g. "remember this") to persist immediately
  • Provide hybrid retrieval (vector semantics + keywords)
  • Run a daily maintenance workflow (create daily file, review yesterday, update MEMORY, clean old logs, generate a report)

When to Use

Use this skill when you need:

  • The agent to reliably "remember key preferences/decisions/important facts" across multiple sessions
  • To prevent meaningless chat from filling up memory files
  • Retrieval quality to decay over time (newer items are more relevant; old items are cleaned automatically)
  • Daily memory maintenance to run automatically (instead of embedding all logic into every conversation)

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 Memory

## About
- 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.md

## Communication
- Preference:

## Tools & Workflows
- Common tools:
- Typical workflows:

memory/decisions.md:

# decisions.md

## Key Decisions
- Decision point:
- Background:
- Why this approach:
- Possible future adjustments:

memory/patterns.md:

# patterns.md

## Best 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:

  • 5 points: write to MEMORY.md
    • core principles, key decisions, user's core preferences
  • 4 points: write to MEMORY.md
    • important rules and lessons repeated multiple times
  • 3 points: write to memory/YYYY-MM-DD.md
    • general tasks and normal conversation content worth retrieving, but not long-term
  • 2 points: write to memory/YYYY-MM-DD.md
    • temporary info / optional records
  • 1 point: do not record
    • small talk / meaningless content

Suggested write strategy:

  • De-duplicate / merge the same memory when possible to avoid endless appends
  • Only persist when it is worth future retrieval / reuse

Time Decay & Cleanup (30+ days)

Short-term memory retrieval weight decays over time:

  • Same day: active (weight 1.0)
  • 1-7 days: recent (weight 0.8)
  • 8-30 days: mid-term (weight 0.5)
  • 30+ days: expired (weight 0; clean / archive during daily maintenance)

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):

  • "remember this" / "save this": evaluate importance and write to the corresponding place
  • "don't forget" / "permanently save": write directly to MEMORY.md
  • "this is an important point": write directly to MEMORY.md
  • "write to memory": write by content type:
    • preferences -> memory/preferences.md
    • decisions -> memory/decisions.md
    • projects -> memory/projects.md
    • contacts -> memory/contacts.md
    • patterns / best practices -> memory/patterns.md
    • feedback -> memory/feedback.md

Auto Recall (retrieve then answer)

When a user question belongs to these categories, first perform memory retrieval, then answer:

  • Asking about previous work/decisions/dates/people/preferences/tasks
  • Needs to reference or extend previous information

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:

  • Provider: voyage (or your actual vector provider)
  • sources: ["memory", "sessions"] (adjust as needed)
  • indexMode: "hot" (real-time updates; adjust if needed)
  • minScore: start from 0.3 (lower = more results)
  • maxResults: start from 20

Manual 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:

  • Create today's log: memory/YYYY-MM-DD.md
  • Review yesterday's log: extract content worth long-termizing into preferences.md / decisions.md / patterns.md / MEMORY.md
  • Clean old logs older than 30 days (optional but recommended)
  • Generate a report (optional: send to Lark/IM or output to console only)

Maintenance 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:

  • Replace YOUR_DEFAULT_MODEL with your default model
  • If you don't need to send to Lark, just output the report to the default channel / return content only

AGENTS.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:

  • Do not write sensitive information (accounts, keys, private content) into publicly shared memory.
  • Only store information in MEMORY.md when you explicitly need it and it is controllable (long-term storage is more sensitive).

Run prerequisites (recommended):

  • Your OpenClaw has memorySearch enabled (otherwise "retrieval/recall" will not work)
  • Your workspace is created with the expected layout: MEMORY.md + memory/ log directory
  • Daily maintenance is configured or planned (cron or equivalent mechanism)

Related Skills

  • memory-setup: configure persistent memorySearch (vector retrieval foundation)
  • self-improvement: turn errors/corrections into learnable experiences
  • cron-mastery: cron vs heartbeat time scheduling best practices
  • clawdhub: install/update/publish skills

Feedback

  • If useful: clawhub star memory-management
  • Stay updated: clawhub sync

name: 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:

  • Evaluate an "importance score" before writing, and decide where to store the memory
  • Use time-decay for short-term memories, and clean them during daily maintenance
  • Provide manual trigger phrases (e.g. "remember this") to persist immediately
  • Provide hybrid retrieval (vector semantics + keywords)
  • Run a daily maintenance workflow (create daily file, review yesterday, update MEMORY, clean old logs, generate a report)

When to Use

Use this skill when you need:

  • The agent to reliably "remember key preferences/decisions/important facts" across multiple sessions
  • To prevent meaningless chat from filling up memory files
  • Retrieval quality to decay over time (newer items are more relevant; old items are cleaned automatically)
  • Daily memory maintenance to run automatically (instead of embedding all logic into every conversation)

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 Memory

## About
- 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.md

## Communication
- Preference:

## Tools & Workflows
- Common tools:
- Typical workflows:

memory/decisions.md:

# decisions.md

## Key Decisions
- Decision point:
- Background:
- Why this approach:
- Possible future adjustments:

memory/patterns.md:

# patterns.md

## Best 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:

  • 5 points: write to MEMORY.md
    • core principles, key decisions, user's core preferences
  • 4 points: write to MEMORY.md
    • important rules and lessons repeated multiple times
  • 3 points: write to memory/YYYY-MM-DD.md
    • general tasks and normal conversation content worth retrieving, but not long-term
  • 2 points: write to memory/YYYY-MM-DD.md
    • temporary info / optional records
  • 1 point: do not record
    • small talk / meaningless content

Suggested write strategy:

  • De-duplicate / merge the same memory when possible to avoid endless appends
  • Only persist when it is worth future retrieval / reuse

Time Decay & Cleanup (30+ days)

Short-term memory retrieval weight decays over time:

  • Same day: active (weight 1.0)
  • 1-7 days: recent (weight 0.8)
  • 8-30 days: mid-term (weight 0.5)
  • 30+ days: expired (weight 0; clean / archive during daily maintenance)

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):

  • "remember this" / "save this": evaluate importance and write to the corresponding place
  • "don't forget" / "permanently save": write directly to MEMORY.md
  • "this is an important point": write directly to MEMORY.md
  • "write to memory": write by content type:
    • preferences -> memory/preferences.md
    • decisions -> memory/decisions.md
    • projects -> memory/projects.md
    • contacts -> memory/contacts.md
    • patterns / best practices -> memory/patterns.md
    • feedback -> memory/feedback.md

Auto Recall (retrieve then answer)

When a user question belongs to these categories, first perform memory retrieval, then answer:

  • Asking about previous work/decisions/dates/people/preferences/tasks
  • Needs to reference or extend previous information

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:

  • Provider: voyage (or your actual vector provider)
  • sources: ["memory", "sessions"] (adjust as needed)
  • indexMode: "hot" (real-time updates; adjust if needed)
  • minScore: start from 0.3 (lower = more results)
  • maxResults: start from 20

Manual 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:

  • Create today's log: memory/YYYY-MM-DD.md
  • Review yesterday's log: extract content worth long-termizing into preferences.md / decisions.md / patterns.md / MEMORY.md
  • Clean old logs older than 30 days (optional but recommended)
  • Generate a report (optional: send to Lark/IM or output to console only)

Maintenance 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:

  • Replace YOUR_DEFAULT_MODEL with your default model
  • If you don't need to send to Lark, just output the report to the default channel / return content only

AGENTS.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:

  • Do not write sensitive information (accounts, keys, private content) into publicly shared memory.
  • Only store information in MEMORY.md when you explicitly need it and it is controllable (long-term storage is more sensitive).

Run prerequisites (recommended):

  • Your OpenClaw has memorySearch enabled (otherwise "retrieval/recall" will not work)
  • Your workspace is created with the expected layout: MEMORY.md + memory/ log directory
  • Daily maintenance is configured or planned (cron or equivalent mechanism)

Related Skills

  • memory-setup: configure persistent memorySearch (vector retrieval foundation)
  • self-improvement: turn errors/corrections into learnable experiences
  • cron-mastery: cron vs heartbeat time scheduling best practices
  • clawdhub: install/update/publish skills

Feedback

  • If useful: clawhub star memory-management
  • Stay updated: clawhub sync