Audit an OpenClaw agent's memory for staleness, redundancy, dark records, and contradictions. Use when a user asks to check memory health, clean up old memor...
---
name: willow-memory-health
description: Audit an OpenClaw agent's memory for staleness, redundancy, dark records, and contradictions. Use when a user asks to check memory health, clean up old memories, find duplicate entries, or diagnose why a memory isn't surfacing in search. Reports HOT/WARM/STALE/DEAD buckets with actionable recommendations.
metadata:
{ "openclaw": { "emoji": "🧠", "os": ["darwin", "linux"], "requires": { "bins": ["python3"] } } }
---
# Willow Memory Health
Audit an OpenClaw agent's memory files for four failure modes that silently degrade memory quality over time:
| Signal | What it means |
| ----------------- | -------------------------------------------------------------------------------- |
| **STALE / DEAD** | File hasn't been updated in 30+ / 90+ days — may no longer reflect current state |
| **REDUNDANT** | Two or more files cover the same subject (Jaccard similarity ≥ 0.55 on titles) |
| **DARK** | File exists in memory but doesn't surface when searched — invisible to the agent |
| **CONTRADICTION** | Same file contains opposing status words (e.g. "deployed" and "not deployed") |
## Trigger
Use this skill when the user:
- Asks to audit, clean up, or review memory
- Reports that the agent "forgot" something that should be in memory
- Wants to know which memories are stale or duplicated
- Asks why a memory isn't being retrieved
## Step 1 — Find the memory directory
Ask for confirmation or infer from context. The memory directory is typically one of:
- `<workspace>/memory/` — workspace-scoped memory files
- `~/.openclaw/agents/<agentId>/memory/` — agent-level memory
If neither is clear, ask: _"Where are your memory files stored? (e.g. a `memory/` folder in your workspace, or a path you specify)"_
## Step 2 — Run the diagnostic script
Run the bundled script against the memory directory:
```bash
python3 {baseDir}/scripts/memory_health.py --dir <memory-dir> --limit 50
```
Optional flags:
- `--limit N` — score only the N most recently modified files (default: 50)
- `--qmd` — enable DARK detection via `qmd query` (requires qmd CLI installed)
- `--json` — machine-readable output
If qmd is available and the user wants DARK detection:
```bash
python3 {baseDir}/scripts/memory_health.py --dir <memory-dir> --limit 50 --qmd
```
## Step 3 — Interpret the report
The script prints a per-file table and a summary:
```
WILLOW MEMORY HEALTH — memory/ (50 files)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
FILE BUCKET FLAGS
MEMORY.md HOT OK
2026-04-16.md HOT OK
2026-03-01.md WARM REDUNDANT
2026-03-01b.md WARM REDUNDANT
2025-12-10.md DEAD STALE | DARK
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
SUMMARY
Files scored : 50
HOT (<7d) : 12
WARM (7–30d) : 23
STALE (30–90d) : 11
DEAD (>90d) : 4
REDUNDANT pairs: 3
DARK : 2 (qmd search returned no match)
CONTRADICTION : 1
```
**HOT/WARM** — healthy, no action needed.
**STALE** — review and either update or archive. Suggest: _"These files haven't been updated in 30–90 days. Want me to review them and mark outdated sections?"_
**DEAD** — strong candidate for archiving. Ask the user: _"These files are 90+ days old. Should I move them to an `archive/` subfolder?"_
**REDUNDANT** — two files covering the same subject. Suggest merging the newer into the older or vice versa. Show both filenames and ask which to keep.
**DARK** — file exists but qmd search can't find it. This usually means the QMD index is out of date. Suggest running `qmd update` or re-indexing: `openclaw memory sync`.
**CONTRADICTION** — file contains opposing status phrases. Show the specific pairs flagged (e.g. "deployed" vs "not deployed") and ask the user to clarify current state.
## Step 4 — Offer cleanup options
After reporting, offer numbered actions the user can pick:
1. Archive all DEAD files (move to `memory/archive/`)
2. Show REDUNDANT pairs for manual review
3. Update QMD index to fix DARK records (`qmd update`)
4. Show CONTRADICTION files for editing
5. Skip — report only, no changes
Always confirm before moving or modifying files.
## Step 5 — Execute with confirmation
For each cleanup action:
- Show exactly which files will be moved or modified
- Confirm before proceeding
- Report what was done
After cleanup, offer to re-run the diagnostic to confirm the health score improved.
## Memory writes
If the user has opted into memory writes, append a dated summary to `memory/YYYY-MM-DD.md`:
```
## Memory health audit — {timestamp}
- Files scored: N
- DEAD archived: N files → memory/archive/
- REDUNDANT merged: N pairs
- DARK fixed: N (qmd update run)
- CONTRADICTION resolved: N files
```
Append-only. Do not overwrite existing entries.
## Notes
- `MEMORY.md` and undated files in `memory/` are treated as evergreen — they are scored for REDUNDANT and CONTRADICTION but never flagged STALE/DEAD.
- Files outside the `memory/YYYY-MM-DD.md` naming convention use `mtime` for age calculation.
- DARK detection requires qmd CLI. If unavailable, the DARK column is skipped and noted in the report.
- This skill does not modify the QMD index directly — it reports and suggests; the user confirms all changes.
don't have the plugin yet? install it then click "run inline in claude" again.
added explicit inputs table with qmd as optional external connection, expanded decision points with 10 conditional branches covering missing paths and error states, formalized procedure as 6 numbered steps with clear input/output, added edge cases for empty directories and qmd timeouts, clarified outcome signals as user-observable events, and structured output contract by data format and success criteria.
audit an openclaw agent's memory files to surface four silent failure modes that degrade memory quality over time: staleness (files not updated in 30+ or 90+ days), redundancy (multiple files covering the same subject), dark records (files that exist but don't surface in search), and contradictions (opposing status words in the same file). use this skill when a user asks to audit, clean up, or review their memory, reports the agent forgot something that should be there, wants to know which memories are stale or duplicated, or asks why a memory isn't being retrieved.
| input | format | notes |
|---|---|---|
| memory directory path | string or inferred from context | typically <workspace>/memory/ or ~/.openclaw/agents/<agentId>/memory/. if unclear, ask the user for the path. |
| python3 executable | system binary | required. check python3 --version before running diagnostics. |
| qmd CLI (optional) | system binary | only needed for DARK detection. if not present, DARK detection is skipped and noted in the report. |
memory_health.py script |
python script | bundled in {baseDir}/scripts/. must be present to run diagnostics. |
| limit parameter (optional) | integer | number of most recently modified files to score. default: 50. use --limit N to override. |
external connections:
qmd query. no env vars or auth required.step 1: locate and confirm the memory directory
ask the user where their memory files are stored. confirm one of these locations:
<workspace>/memory/ (workspace-scoped memory)~/.openclaw/agents/<agentId>/memory/ (agent-level memory)output: confirmed directory path as a string.
step 2: run the diagnostic script
execute the memory health script against the confirmed directory:
python3 {baseDir}/scripts/memory_health.py --dir <memory-dir> --limit 50
if qmd is installed and the user wants dark detection, run:
python3 {baseDir}/scripts/memory_health.py --dir <memory-dir> --limit 50 --qmd
optional flags:
--limit N: score only the N most recently modified files (default: 50).--qmd: enable dark detection via qmd query. skipped silently if qmd is unavailable.--json: output machine-readable json instead of human-readable table.output: scored report with per-file table showing FILE, BUCKET (HOT/WARM/STALE/DEAD), and FLAGS (OK, REDUNDANT, DARK, CONTRADICTION, or combinations).
step 3: parse and interpret the report
read the script output as a table with columns: FILE, BUCKET, FLAGS. the summary section shows counts:
output: interpreted summary as prose, with specific file names and recommendations per failure mode.
step 4: offer cleanup actions
present the user with numbered actions:
memory/archive/)qmd update)ask which action(s) the user wants to take. require explicit confirmation before any file operation.
output: list of selected actions as a numbered menu.
step 5: execute cleanup with confirmation
for each selected action:
after cleanup, offer to re-run the diagnostic (step 2) to confirm the health score improved.
output: summary of files moved, merged, or updated, plus the new health counts if re-run.
step 6 (optional): write memory audit log
if the user has opted into memory writes, append a dated summary to memory/YYYY-MM-DD.md:
## Memory health audit , {ISO 8601 timestamp}
- Files scored: N
- DEAD archived: N files → memory/archive/
- REDUNDANT merged: N pairs
- DARK fixed: N (qmd update run)
- CONTRADICTION resolved: N files
always append, never overwrite. output: confirmation that the audit entry was written.
if the memory directory path is unclear:
ask the user: "where are your memory files stored? (e.g. a memory/ folder in your workspace, or a path you specify)".
if qmd CLI is not installed: skip dark detection silently. note in the report: "DARK detection skipped (qmd CLI not found)". do not fail the entire diagnostic.
if the diagnostic script returns an error (e.g. directory not found, permission denied): stop and report the error message to the user. ask them to verify the path exists and is readable. do not proceed to step 3.
if the report shows STALE files (30, 90 days): suggest: "these files haven't been updated in 30, 90 days. want me to review them and mark outdated sections?" ask if the user wants to archive them or keep them as-is.
if the report shows DEAD files (>90 days):
ask: "these files are 90+ days old. should i move them to an archive/ subfolder?" require explicit yes/no before archiving.
if the report shows REDUNDANT pairs: show both filenames and ask: "these two files cover the same subject. which one do you want to keep?" offer to merge the newer into the older or vice versa.
if the report shows DARK records:
suggest: "these files exist but don't surface in search. this usually means the qmd index is out of date. want me to run qmd update?" if yes, run qmd update and re-run the diagnostic.
if the report shows CONTRADICTION: show the specific opposing phrases (e.g. "deployed" vs "not deployed") and ask the user to clarify the current state. do not auto-resolve.
if no actions are selected in step 4: end the skill. report that the audit is complete and no changes were made.
if a file operation fails (e.g. move, chmod): report the error, stop that operation, and ask the user to manually fix the issue before retrying.
success is defined by:
--json flag used).memory/YYYY-MM-DD.md with the audit summary.all output must be readable by the user and machine-parseable (if json flag is used).
the user knows the skill worked when:
notes
MEMORY.md and undated files in memory/ are treated as evergreen. they are scored for redundant and contradiction but never flagged stale or dead.memory/YYYY-MM-DD.md naming convention use mtime for age calculation.credits
original author: rudi193-cmd (clawhub)