OpenClaw Memory Management
Without MEMORY.md, your agent forgets everything between sessions. Every conversation starts from zero. MEMORY.md gives your agent persistent context: who your clients are, what your projects look like, what you prefer. Your agent gets better over time instead of starting over.
What MEMORY.md does
MEMORY.md is a file in your OpenClaw workspace that your agent reads at the start of every session. It contains persistent context: facts about you, your projects, your preferences, and anything your agent needs to remember across conversations.
Think of it as your agent's long-term memory. SOUL.md defines who your agent is. HEARTBEAT.md defines what it does on a schedule. MEMORY.md defines what it knows.
The three workspace files:
- • SOUL.md = personality and behavior rules (who the agent is)
- • HEARTBEAT.md = scheduled tasks (what the agent does automatically)
- • MEMORY.md = persistent context (what the agent knows)
Pattern 1: Static preferences
The simplest MEMORY.md stores things that rarely change: your timezone, preferred channels, project URLs. Write it once and update it when things change.
# MEMORY.md
## User preferences
- Preferred communication channel: Telegram
- Timezone: America/New_York
- Morning briefing time: 8:00am
- Do not send notifications between 10pm and 7am
## Project context
- Main repo: github.com/user/project
- Production URL: https://app.example.com
- Staging URL: https://staging.example.com
- Deploy branch: mainPattern 2: Learned context
This pattern stores things your agent learns over time. Client contacts it discovers in emails. Patterns it notices in your inbox. Preferences you mention in conversation.
# MEMORY.md
## Client list
- Acme Corp (sarah@acme.com) - priority: high
- Widget Inc (tom@widget.co) - priority: medium
- StartupXYZ (alex@startupxyz.com) - priority: high
## Email patterns I have learned
- Emails from @stripe.com about "payment failed" = urgent, notify immediately
- Emails from @github.com = low priority unless subject contains "security"
- Weekly digest from newsletter@techcrunch.com = skip, never flag
## Meeting preferences
- User prefers 30-minute meetings, not 60
- Never schedule before 10am
- Friday afternoons are blocked for deep workPattern 3: Project state
For development workflows, MEMORY.md can track project state: current sprint goals, recent decisions, known issues. This gives your agent context that would otherwise require re-explaining every session.
# MEMORY.md
## Current sprint
- Sprint 14: March 3-14
- Goal: ship user dashboard redesign
- Key PRs: #142 (dashboard layout), #145 (chart component), #147 (data fetching)
## Recent decisions
- 2026-03-05: Switched from Chart.js to Recharts (smaller bundle)
- 2026-03-02: Decided to use server components for dashboard pages
- 2026-02-28: API v2 endpoint format finalized
## Known issues
- Flaky test in auth.test.ts - intermittent timeout on CI
- Memory leak in WebSocket handler - tracked in #138
- Safari rendering bug on chart tooltips - low priorityPattern 4: Self-updating memory
The most powerful pattern: tell your agent to update MEMORY.md itself. Add instructions in SOUL.md that tell the agent when and how to write new memories.
# In SOUL.md, instruct your agent to maintain MEMORY.md:
When you learn something new about the user's preferences, projects, or workflows,
update MEMORY.md. Keep entries concise. Remove outdated information.
Rules for MEMORY.md updates:
- Add new client contacts when you see them in emails
- Update project status when PRs are merged or issues are closed
- Record any explicit preferences the user tells you
- Never store passwords, API keys, or sensitive credentials
- Keep the file under 200 lines. Summarize older entries.With self-updating memory, your agent gets smarter over time. It remembers your clients, learns your patterns, and builds up project context without you maintaining the file manually.
Best practices
Keep it under 200 lines
Your agent reads MEMORY.md every session. A massive file wastes tokens and slows things down. Summarize old entries. Remove anything no longer relevant.
Use clear sections
Organize by topic: clients, projects, preferences, learned patterns. Your agent can find what it needs faster with clear headings.
Never store secrets
No API keys, passwords, or tokens in MEMORY.md. Use environment variables or the OpenClaw secret store for sensitive data.
Date your entries
For things that change (sprint goals, recent decisions), add dates. This helps your agent know what is current and what might be stale.
Review periodically
Check MEMORY.md every few weeks. Remove outdated entries. Correct anything your agent got wrong. This is like pruning a garden.
Templates that benefit from MEMORY.md
Any template works better with context. These runbooks especially benefit from a well-maintained MEMORY.md:
Email Triage Bot
Store client list and priority rules in memory so triage improves over time.
~$0.30/day
Calendar Prep
Remember attendee context and meeting history for better briefs.
~$0.25/day
GitHub PR Reviewer
Store coding standards and past review patterns for consistent feedback.
~$0.35/day
Competitor Watch
Track competitor list, pricing history, and feature changes over time.
~$0.20/day
Get started with memory
Create a MEMORY.md in your workspace with your basic preferences. Then add self-updating instructions to your SOUL.md. Your agent starts building context from the first session.