How to Get the Most Out of OpenClaw: A Practical Best Practices Guide
OpenClaw (formerly Clawdbot and Moltbot) has exploded onto the scene as one of the fastest-growing open-source AI projects in history — surpassing 190,000 GitHub stars in a matter of weeks. Created by Peter Steinberger, it's an autonomous AI assistant that runs locally on your own hardware and connects to your messaging platforms like WhatsApp, Telegram, Slack, Discord, and Signal.
But getting OpenClaw installed is only about 20% of the work. The other 80% is making it actually useful, keeping it secure, and managing its memory so it stays sharp over time. This guide collects battle-tested recommendations from the official documentation, community experts, and real-world production setups.
Understanding OpenClaw's Memory System
OpenClaw's memory is file-based and Markdown-driven. The core philosophy is simple: files are the source of truth — the agent only retains what gets written to disk. Every new session starts fresh, and the agent rebuilds its context by reading workspace files.
The memory system has two layers:
- MEMORY.md — Long-term, curated facts: preferences, decisions, relationships, and durable context that should persist indefinitely.
- memory/YYYY-MM-DD.md — Daily logs: running notes about what happened that day, decisions made, and conversation context.
This split is intentional. Daily notes catch everything useful in the moment (including messy context), while MEMORY.md should stay smaller and more carefully maintained — the stuff you want to remain true over time.
Why MEMORY.md Must Not Get Too Large
This is where many users run into trouble. Every session, OpenClaw loads your workspace files — including MEMORY.md — into the LLM's context window as part of the system prompt. The default
bootstrapMaxChars is 20,000 characters, and the recommended setting is 10,000–15,000 characters. If your total workspace files exceed this limit, OpenClaw truncates them using a 70/20/10 split (70% from the start, 20% from the end, 10% truncation marker), which means instructions silently get lost.
Here are the recommended size limits for your workspace files:
| File | Target Size | Purpose |
|------|-------------|---------|
| AGENTS.md | < 2 KB | Operational instructions only |
| SOUL.md | < 3 KB | Persona, role, behavior rules |
| USER.md | < 1.5 KB | User profile and preferences |
| MEMORY.md | < 5 KB | Curated long-term facts |
| IDENTITY.md | < 1 KB | Name, emoji, vibe |
| HEARTBEAT.md | < 4 KB | Periodic task checklist |
| TOOLS.md | < 1 KB | Environment-specific notes |
| Total | < 15 KB | Must fit within bootstrapMaxChars |
You should measure your total size regularly:
bash
wc -c ~/.openclaw/workspace/*.md
You can also explicitly set the limit:
bash
openclaw config set agents.defaults.bootstrapMaxChars 15000
Keep MEMORY.md Curated, Not a Diary
If you let MEMORY.md turn into a running diary, it gets noisy and less useful. Keep it curated — only durable facts, preferences, and important decisions. Day-to-day context belongs in the daily log files (
memory/YYYY-MM-DD.md).
A practical rule: no duplication across files. SOUL.md defines behavior, MEMORY.md stores facts. Don't repeat information in both. Every line must earn its place — if removing a line doesn't change the agent's behavior, remove it.
Setting Up Your Workspace Files Right
SOUL.md — Your Agent's Constitution
SOUL.md defines who your agent is and, crucially, what it is not allowed to do. It operates at the reasoning level — a well-written SOUL.md causes the agent to refuse bad requests before trying to execute them.
Key principles:
- Be explicit. Models respond better to clear rules than vague guidance. "NEVER log, cache, or transmit API keys or passwords" is far stronger than "be careful with sensitive data."
- Use absolute language. "NEVER" is stronger than "avoid if possible."
- Organize by category: security boundaries, financial boundaries, operational limits, and user-facing behavior.
- Version it. Treat SOUL.md like code with a changelog. When you change it, note what changed and why.
AGENTS.md — Operational Safety
AGENTS.md defines what your agent can do, what requires confirmation, and what it should never attempt. Security researchers found hundreds of exposed OpenClaw dashboards in late January 2026, many with zero authentication — the common thread was missing or poorly configured AGENTS.md.
The default AGENTS.md template includes critical instructions:
- Read SOUL.md, USER.md, MEMORY.md, and today + yesterday's daily log before responding.
- Don't dump directories or secrets into chat.
- Don't run destructive commands unless explicitly asked.
- Don't share private data, contact info, or internal notes.
- Be careful in group chats — you're not the user's voice.
USER.md — Context About You
USER.md stores everything the agent needs to know about you: your name, role, preferences, working hours, communication style. When you want a behavior change, the most reliable approach is to tell the agent explicitly: "Add to USER.md that I want short answers and copy-pasteable commands."
Managing Sessions and Context
Session Resets Are Your Friend
OpenClaw's context window (typically 200,000 tokens) fills up during use. Performance degrades as it fills — the agent starts missing patterns, forgetting earlier instructions, and making more mistakes.
Best practices:
- Reset after each independent task. Finished writing an article? Reset. Finished debugging? Reset. Previous task context is usually useless for the next task.
- Don't rely on auto-compaction as a strategy. Compaction is lossy — details get dropped and the agent's understanding of your intent degrades. It's a safety net, not a workflow.
- Use the "pre-compressed memory refresh" technique for multi-day projects: tell the agent to write key decisions and todos to MEMORY.md, reset the session, then start a new session that reads MEMORY.md and continues.
bash
Three reset methods:
openclaw "reset session" # Command line
rm -rf ~/.openclaw/agents.main/sessions/*.jsonl # Direct deletion
Or type /compact in chat # Built-in command
Automatic Session Reset
Configure automatic daily resets to prevent unbounded context growth:
bash
openclaw config set session.reset.mode daily
openclaw config set session.reset.atHour 4 # 4 AM gateway local time
Enable Hidden Memory Features
OpenClaw has excellent memory infrastructure, but several powerful features are off or minimal by default. Most users never discover them:
Pre-Compaction Memory Flush
When a session is close to auto-compaction, this triggers a silent agentic turn that reminds the model to write durable notes to disk before context is lost. This prevents the "woke up with amnesia" problem.
json
{
"agents": {
"defaults": {
"compaction": {
"reserveTokensFloor": 20000,
"memoryFlush": {
"enabled": true,
"softThresholdTokens": 4000
}
}
}
}
}
Hybrid Search (BM25 + Vector)
Combines semantic similarity with keyword matching (70/30 blend, 4× candidate pool). This dramatically improves recall for exact terms, names, error strings, and code symbols. Enable it for better memory retrieval.
Embedding Cache
Caches chunk embeddings in SQLite so reindexing does not re-embed unchanged text. Saves API calls and makes search faster on startup. Verify it's working:
bash
sqlite3 ~/.openclaw/memory/main.sqlite "SELECT COUNT(*) FROM embedding_cache;"
Recency Decay
If your agent has months of daily notes, old stale information can outrank recent context in search results. Recency decay solves this by penalizing older entries, so today's notes rank higher than something from five months ago.
Diversity Reranking
Daily notes often repeat similar information across days. Diversity reranking drops near-duplicate results, so the agent gets distinct pieces of information instead of three variations of the same fact.
Optimize for Cost and Speed
API costs are the main recurring expense with OpenClaw. Light use runs $10–30/month, typical use $30–70/month, and heavy automation can reach $100–150/month or more. Here are proven ways to cut costs:
Disable Unused Skills and Tools
Each enabled skill adds thousands of tokens to the system prompt. Only keep the tools you actually use:
json
{
"enabledSkills": ["file-operations", "git", "bash"],
"disabledSkills": ["browser-automation", "gmail", "calendar"]
}
Disabling niche tools can save 10–15% of token usage.
Don't Feed Entire Files
Only inject task-relevant snippets into context. If you're modifying a function, provide just that function — not the entire file. This alone can reduce context consumption by 70–80%.
Maintain an ARCHITECTURE.md
Put a high-level system design document in your project root. When the agent needs a global perspective, it can read this instead of scanning the entire codebase. Add a brief README.md in each module directory explaining what the module does.
Use a Cheaper Model for Heartbeat
The heartbeat daemon runs periodic check-ins. Consider using a faster, cheaper model for these routine tasks by setting
heartbeat.model in your config.
Security: Don't Skip This
OpenClaw connects to real messaging surfaces and has access to your local system. Treat inbound DMs as untrusted input. Cisco's AI security research team tested a third-party OpenClaw skill and found it performed data exfiltration and prompt injection without user awareness.
Essential security measures:
- Enable DM pairing mode (
dmPolicy: "pairing"). Unknown senders receive a pairing code and the bot won't process their message until approved. - Use allowlists. Explicitly list who can message your agent.
- Run
openclaw doctorto surface risky or misconfigured DM policies. - Never expose the dashboard to the public internet without authentication.
- Store API keys in environment variables, not in plain text workspace files.
- Set file permissions:
chmod 700 ~/openclaw/config/andchmod 600 ~/openclaw/config/*.json. - Pin to a recent version (2026.1.29 or later) and keep up with security patches.
- Define explicit boundaries in SOUL.md for what the agent can and cannot do — especially around shell commands, file access, and outbound communication.
Your First Week: A Progression
If you've just set up OpenClaw and are staring at the chat wondering "now what?", here's a practical progression:
- Days 1–2: Just talk. Ask it to explain things, summarize articles, check the weather. Build comfort and trust.
- Days 3–4: Start personalizing. Edit SOUL.md and USER.md. Tell it your preferences. Correct it when it gets things wrong — every correction compounds.
- Days 5–7: Add automation. Set up a heartbeat for morning briefings. Configure cron jobs. Install a skill or two from ClawHub.
- Ongoing: Curate memory. Periodically review MEMORY.md and prune stale or incorrect entries. Memory is not self-cleaning — you need to maintain it.
The compound effect is real. After weeks of corrections and accumulated context, your agent genuinely knows how you work. The people building that context now will have a massive head start when this kind of setup becomes mainstream.
---
Sources
- OpenClaw Official Docs — Memory: docs.openclaw.ai/concepts/memory
- OpenClaw GitHub Repository: github.com/openclaw/openclaw
- OpenClaw Default AGENTS.md Reference: docs.openclaw.ai/reference/AGENTS.default
- awesome-openclaw Best Practices (CodeAlive-AI): github.com/CodeAlive-AI/awesome-openclaw/blob/main/OPENCLAW_BEST_PRACTICES.md
- OpenClaw Memory Deep Dive (Study Notes): snowan.gitbook.io/study-notes/ai-blogs/openclaw-memory-system-deep-dive
- OpenClaw Memory Explained (LumaDock): lumadock.com/tutorials/openclaw-memory-explained
- OpenClaw Performance Optimization (BetterLink Blog): eastondev.com/blog/en/posts/ai/20260205-openclaw-performance
- SOUL.md Best Practices (OpenClaw Experts): openclawexperts.io/blog/soul-md-best-practices
- AGENTS.md Security Configuration (Alireza Rezvani / Medium): alirezarezvani.medium.com
- How to Make Your OpenClaw Agent Useful (Aman Khan): amankhan1.substack.com
- Memory Optimization Onboarding Discussion: github.com/openclaw/openclaw/discussions/6038
- What Is OpenClaw? (Milvus Blog): milvus.io/blog/openclaw-formerly-clawdbot-moltbot-explained
- What Is OpenClaw? (DigitalOcean): digitalocean.com/resources/articles/what-is-openclaw
- OpenClaw Wikipedia: en.wikipedia.org/wiki/OpenClaw