Claw Memory Management
Agent Buildingclaw-memory-managementClaw Memory Management is an Agent Skill for agent building published in the x-cmd/x-cmd repository on GitHub: a SKILL.md instruction file an AI agent can load to do this task.
Workspace memory management guide: memory layers, writing rules, entry format, and maintenance. Use when writing, updating, or maintaining memory files (memory/YYYY-MM-DD.md and MEMORY.md).
How to use this skill
Bring this guide into your coding agent with a prompt tailored to the tool you use.
- Open your project in Codex.
- Copy and paste the prompt below.
- Review files and risks before approving any action.
Inspect the Agent Skill at https://github.com/x-cmd/x-cmd/blob/HEAD/mod/claw/lib/data/workspace/manager/skills/memory-management/SKILL.md and all supporting files. Report provenance, permissions, scripts, dependencies, and security risks. Propose an exact installation into .agents/skills/claw-memory-management, but wait for my approval before writing files or running scripts.
Copying this prompt does not install or run the skill. Review third-party files before use.
Memory Management
Memory Layers
| Layer | File | Content | Purpose |
|---|---|---|---|
| Layer 2 | MEMORY.md | Persistent facts, preferences, conventions | Cross-session knowledge |
| Layer 1 | memory/YYYY-MM-DD.md | Concise daily index: tasks, decisions, changes, next steps | Quick context recovery |
Key difference: memory/ is what you need to know to continue working. Keep it concise — do not stuff it with exhaustive operational details.
Writing Rules
- Write memory after action — Each round produces one concise memory index entry.
- Keep memory concise —
memory/is for quick context recovery. If it becomes too long to scan at a glance, you are writing too much detail. - Use timestamps inside entries — Use
HH:MM:SSinside entries. The##heading already provides the date. - Link to long-term memory — If a pattern or preference should persist, update
MEMORY.mddirectly. - Silent writing — Write memory as part of tool calls. Do not mention logging in your text replies to the user.
- Log every reply — Every memory entry must include a
Sentfield summarizing what you output to the user. If you said nothing, write"No reply". - Check before replying — Before replying, scan today's
memory/entries for theSentfield. If you already answered this question, do not repeat it. - Check context on short/ambiguous replies — If the user's message is brief or seems to reference something not in their message (e.g., "ok", "好的", "why", "next time"), ALWAYS check the most recent
Sententry inmemory/YYYY-MM-DD.md. The user may be responding to a heartbeat notification. If so, acknowledge the notification context in your reply.
Memory Index Entry Format
Append entries to memory/YYYY-MM-DD.md. Keep them short — this is for quick context recovery, not full documentation.
## HH:MM:SS — [One-sentence task summary]
- **Request**: [What the user asked for]
- **Method**: [Brief description of the approach or pattern used]
- **Key decision**: [Important choices and rationale]
- **Changes**: [List of files touched]
- **Status**: [Complete / Partial / Blocked / Needs review]
- **Sent**: [Brief summary of what you sent to the user, e.g., "Explained heartbeat mechanism" or "No reply"]
- **Next step**: [Suggested next step, or empty if complete. If you sent a message to the user and expect a reply, write: "If user replies, they are likely responding to: <summary of what you sent>". This helps the next agent session understand the context when the user replies.]
Do not output these logs in your text replies. Write them directly to files.
Memory Maintenance
Periodically (every few days or when you notice accumulation), review and maintain your memory:
- Read recent
memory/YYYY-MM-DD.mdfiles - Identify significant events, lessons, insights worth saving long-term
- Update
MEMORY.mdwith distilled learnings (not raw logs) - Delete outdated information in
MEMORY.mdthat is no longer relevant
This is like a human reviewing a diary and updating their mental model. Daily files are raw notes; MEMORY.md is curated wisdom.
Key rule: If you want to remember something, write it to a file.