What Are Memory Files?
Fresh out of the box, your OpenClaw agent knows nothing about you. Every conversation starts cold — it doesn't know your name, how you like to communicate, what projects you're working on, or what it's absolutely not allowed to do. It's a capable assistant with no context, and a capable assistant with no context gives generic answers.
Memory files fix this. They're plain Markdown files that live in
~/.openclaw/ on your server, and OpenClaw automatically loads them
into every conversation. Whatever you write in them becomes part of the agent's
operating context — its personality, your profile, its rules, its environment.
This is how you go from "helpful chatbot" to "personal AI that actually knows me."
The Files and When They Load
OpenClaw has six memory files. They don't all load the same way — understanding when each one gets injected is key to building a lean, effective workspace:
SOUL.md — Persona, tone, values, and hard limits.
TOOLS.md — Environment configuration and tool guidance.
These three files are the core. They're injected into every single message.
MEMORY.md — Private iron-law rules that must always be true.
These are never loaded in group channels (e.g. a Discord server) — only in direct messages and main sessions. This is a security feature.
docs/ folder and load it on-demand with skills instead.
Where the Files Live
All memory files go in your OpenClaw workspace directory:
# List your current memory files
ls -la ~/.openclaw/
# A well-configured workspace looks like this:
~/.openclaw/
├── AGENTS.md ← operating instructions (every turn)
├── SOUL.md ← persona + values (every turn)
├── TOOLS.md ← environment config (every turn)
├── USER.md ← your profile (DMs only)
├── MEMORY.md ← private rules (DMs only)
├── IDENTITY.md ← agent name (gateway startup)
├── openclaw.json ← gateway config (not a memory file)
└── docs/ ← deep reference content (on-demand)
openclaw.json and possibly a few placeholder files. The memory files
you'll write in this tutorial don't exist yet — you're starting from a blank slate,
which is actually ideal. A purpose-built workspace beats the default every time.
The Minimum Viable Workspace
You don't need to configure every file at once. The official recommendation — and what the community has landed on — is that three files are the meaningful minimum:
Add USER.md and MEMORY.md once the basics are working. Build incrementally — you'll learn what you actually need from watching how the agent responds.
SOUL.md & AGENTS.md
These two files do the heavy lifting. SOUL.md defines who your agent is — its personality, tone, values, and the things it will never do. AGENTS.md defines how your agent works — its operating procedures, how it handles tasks, and how it maintains its own memory over time. Together they turn a blank-slate model into something that consistently feels like yours.
SOUL.md — Identity, Tone & Limits
Think of SOUL.md as the answer to "who are you?" It shapes every response your agent gives. A well-written SOUL.md means your agent matches your communication style, knows its purpose, and has clear hard limits it will never cross.
Create it:
nano ~/.openclaw/SOUL.md
A practical starting point:
# Identity
You are [Name], a personal AI assistant for [Your Name].
Your purpose is to help with [primary use case: research / writing / dev / automation].
# Tone
- Direct and concise. No filler.
- Ask one clarifying question at a time if something is ambiguous.
- Use bullet points for lists; prose for explanations.
- Match the energy of the conversation — casual when I'm casual, focused when I'm working.
# Hard Limits — Never Violate These
- Never run destructive commands (rm -rf, DROP TABLE, etc.) without explicit confirmation
- Never share credentials, tokens, API keys, or private data
- Never make financial commitments or purchases without explicit permission
- Never send messages or emails on my behalf without showing me the draft first
- If unsure whether an action is reversible, stop and ask
# Values
- Honesty over helpfulness — say "I don't know" rather than guessing
- Privacy matters — handle personal data with discretion
- Errors should be acknowledged, not papered over
AGENTS.md — Operating Instructions
Where SOUL.md is about identity, AGENTS.md is about operation. This file tells your agent how to handle tasks — its workflow, how to self-organize, when to use which tools, and how to maintain its own memory files. Think of it as the internal procedure manual.
nano ~/.openclaw/AGENTS.md
# Task Approach
- For any task with 3+ steps, outline the plan before starting
- For ambiguous requests, restate your interpretation before acting
- Complete tasks fully — don't stop halfway and ask if you should continue
- Report errors clearly with what you tried, what failed, and what the fix would be
# Memory Maintenance
- When you learn something new and persistent about me or my setup, update USER.md
- When a rule should always apply regardless of context, add it to MEMORY.md
- Keep file entries short and dated (YYYY-MM) for future pruning
- Prune entries older than 6 months unless they're still actively relevant
# Tool Usage
- Read before writing — always check what exists before creating or overwriting
- Confirm before any destructive action (delete, overwrite, bulk operations)
- Prefer targeted edits over full file rewrites
- If a tool fails, explain what happened before trying an alternative
# Communication
- When a task is done, say so briefly — don't over-explain completed work
- Surface important decisions or trade-offs; don't hide them in long outputs
- If something takes more than 30 seconds, give a status update
Reload and Test
Memory files are loaded at the start of each new session. Restart the gateway to pick up your changes, then start a fresh conversation to see them take effect:
openclaw gateway restart
Then send a message that would reveal whether the persona is active — something like "Who are you and what do you do?" A good SOUL.md will give you a crisp, on-brand answer. A poorly written one will give you a generic "I'm an AI assistant" response. Iterate until it feels right.
USER.md & IDENTITY.md
SOUL.md and AGENTS.md define how the agent behaves. USER.md and IDENTITY.md define the context — who you are, and who the agent is. This is where you stop repeating yourself every conversation. Once your agent knows your background, your projects, your preferences, and your timezone, it stops asking. It just knows.
USER.md — Your Profile
USER.md is the agent's persistent record of who you are. Unlike SOUL.md (which is about the agent), this file is entirely about you — your work, your preferences, your context. It's loaded only in direct messages and main sessions, never in public or group channels, making it safe for reasonably personal information.
nano ~/.openclaw/USER.md
# About Me
Name: [Your Name]
Location / Timezone: [City, Country — UTC-5]
Field: [e.g. Software development, marketing, finance, etc.]
Experience level: [Beginner / Intermediate / Expert] in [relevant areas]
# Active Projects
- [Project A]: [One sentence description and current status]
- [Project B]: [One sentence description and current status]
# Tech Stack
- Primary OS: [Ubuntu 24.04 / macOS / Windows 11]
- Languages I use: [Python, JavaScript, etc.]
- Tools I use daily: [VS Code, GitHub, Notion, etc.]
# Preferences
- Communication: Direct. Skip preambles like "Great question!"
- Formatting: Code in code blocks. Prose for explanations. Bullets for lists.
- Timezone: Responses should reference my local time when relevant
- Feedback style: Tell me if something I'm doing is a bad idea, don't just do it
# Things to Remember
# (The agent should add new entries here as it learns things about you)
# Format: [YYYY-MM] — [What it learned]
IDENTITY.md — The Agent's Name & Nature
IDENTITY.md is the agent's formal self-definition — its name, a short description of its nature, and any characteristics that make it distinct. This is separate from SOUL.md: SOUL.md defines behavior and limits, while IDENTITY.md is more like a business card.
IDENTITY.md is loaded once at gateway startup, not on every turn, so it's appropriate for slightly longer content that doesn't need to be injected constantly.
nano ~/.openclaw/IDENTITY.md
# Agent Identity
Name: [Your agent's name — e.g. "Axiom", "Atlas", "Rex"]
Type: Personal AI assistant
Owner: [Your name]
Deployed: [Month Year]
Platform: [EC2 / Mini PC] running OpenClaw
# Purpose
[One to three sentences describing what this agent is for. Be specific.
Example: "A personal productivity assistant focused on research, writing,
and automating repetitive tasks for a freelance developer."]
# Characteristics
- [Trait 1: e.g. "Methodical — breaks large tasks into steps"]
- [Trait 2: e.g. "Honest — admits uncertainty rather than guessing"]
- [Trait 3: e.g. "Efficient — respects time and minimizes back-and-forth"]
TOOLS.md & MEMORY.md
TOOLS.md gives your agent a map of its environment — what tools are available, how the server is configured, what commands are risky, and any quirks it needs to know about. MEMORY.md is different: it's the file for iron-law rules that must always be true, kept private from group channels. Together they handle the operational reality of running an agent on real infrastructure.
TOOLS.md — Environment Configuration
TOOLS.md is loaded on every turn for both the main agent and any sub-agents it spawns. Think of it as the operations manual for the machine your agent is running on. Without it, the agent has to guess about paths, available commands, SSH hosts, and what's safe to run.
gs to git status, the agent should know.
sudo. What should always be double-checked before running.
Server-specific danger zones.
nano ~/.openclaw/TOOLS.md
# Environment
OS: Ubuntu 24.04 LTS
User: [your username]
Shell: bash
Node: v24.x
npm global prefix: /usr/local
# Key Paths
OpenClaw config: ~/.openclaw/openclaw.json
OpenClaw logs: ~/.openclaw/logs/
Projects: ~/projects/
Workspace: ~/.openclaw/
# Available Tools
- Standard Unix tools (grep, find, awk, sed, curl, wget)
- git, node, npm, python3
- openclaw CLI (openclaw status, openclaw logs, openclaw gateway restart, etc.)
# SSH Access
# [Add entries as needed:]
# dev-server: ssh dev@192.168.1.x (dev machine)
# Risky Commands — Always Confirm First
- Any rm -rf or rm with wildcards
- Any sudo commands that modify system files
- Any git push --force
- Any database migrations or DROP operations
- Any openclaw config changes (restart required)
# Notes
- This server is AWS EC2 t3.small — memory is limited, avoid large in-memory operations
- UFW is active — check before opening new ports
- Systemd service: openclaw.service (use openclaw gateway restart, not systemctl directly)
MEMORY.md — Private Iron-Law Rules
MEMORY.md is for rules that must always be true — things that are more absolute than SOUL.md's guidelines and more personal than AGENTS.md's procedures. Crucially, MEMORY.md is never injected into group conversations (like a Discord server channel). It's only loaded in direct messages and main sessions. This makes it the right place for private operational context.
nano ~/.openclaw/MEMORY.md
# Memory — Main Session Only
# IMPORTANT: These rules apply only in direct messages and main sessions.
# Never reference this file's contents in group channels.
# Iron Laws
- [2026-03] Never run commands in the ~/projects/[sensitive-project] directory without explicit permission
- [2026-03] Always verify the target environment before running any deployment commands
- [2026-03] Disk space on this server is limited — avoid writing large temp files
# Lessons Learned
# (Add entries when you discover something that must never happen again)
# Format: [YYYY-MM] — [What happened and what to do instead]
# Private Context
# (Operational context that shouldn't appear in shared channels)
- [Add entries as needed]
Token Efficiency & BOOTSTRAP.md
Memory files are powerful but not free — every character in AGENTS.md, SOUL.md, and TOOLS.md gets sent to the LLM on every single message. Write these files well and you get a sharp, consistent agent. Let them bloat and you're paying to inject irrelevant context on every interaction. This section covers how to keep your workspace lean and introduces BOOTSTRAP.md — the one-time setup interview that creates your initial files for you.
Keeping Files Lean
The community best practice, confirmed by official docs: keep each of the three every-turn files (AGENTS.md, SOUL.md, TOOLS.md) under 10,000–15,000 characters. OpenClaw trims oversized files automatically with a truncation marker — which means if your files are too big, content at the end gets silently cut off. The rules you wrote last are the ones most likely to disappear.
wc -c ~/.openclaw/SOUL.md ~/.openclaw/AGENTS.md ~/.openclaw/TOOLS.md
— Run this to see current character counts. If any file is over 15,000
characters, it's time to trim.
~/.openclaw/docs/ directory for deep reference content.
Skill-specific guides, project documentation, verbose reference material — all
of this belongs in docs/ and gets loaded on-demand by skills rather than
injected every turn.
[YYYY-MM] format. Undated entries are impossible to prune
confidently later — you don't know if they're still relevant.
# Character counts for the three every-turn files
wc -c ~/.openclaw/SOUL.md ~/.openclaw/AGENTS.md ~/.openclaw/TOOLS.md
# Target: under 15,000 characters each
# 15,000 characters ≈ 3,750 tokens ≈ reasonable context overhead
BOOTSTRAP.md — The First-Run Interview
Don't want to write your memory files from scratch? BOOTSTRAP.md is a built-in OpenClaw feature designed for exactly this. It's a first-run interview script: when present, your agent will start a conversational setup session with you, ask about your name, preferences, values, and goals, then write your initial SOUL.md, USER.md, and IDENTITY.md files for you based on the conversation.
Once the interview is complete and the files are written, BOOTSTRAP.md deletes itself. It's a one-time ritual, not a permanent file.
To use BOOTSTRAP.md, create a placeholder file and the agent will kick off the interview on next connect:
# Download the official BOOTSTRAP.md template
curl -fsSL https://docs.openclaw.ai/reference/templates/BOOTSTRAP \
-o ~/.openclaw/BOOTSTRAP.md
# Restart the gateway — interview starts on next DM
openclaw gateway restart