memory-system
Skill0 starsChanged 7 months agoMITView on GitHub
Развёртывание и обслуживание 3-слойной системы памяти для любого агента OpenClaw — чтобы контекст переживал сессии. Активируется на: настрой память, memory setup, проверь память, memory check, почисти память, memory cleanup, память.
We split this skill into the rules it gives an agent
7 rules. 0 are common, 6 are distinctive, and 1 is very specific to this project.
0
Common
Most of the 6 edited versions we read keep these.
6
Distinctive
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 137
Check memory/YYYY-MM-DD.md for last 3 days
- Distinctive: line 143
When was it last updated?
- Distinctive: line 144
If >7 days → ⚠️ "MEMORY.md is stale"
- Distinctive: line 155
Update MEMORY.md — add new, remove duplicates
- Distinctive: line 156
Update "Recent decisions" section
- Distinctive: line 161
Don't delete without confirmation
- Distinctive: line 257
When session nears compaction, the agent saves context in this format:
“Common” is measured: kept by at least 6 in 10 of the 6 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Memory System — 3-Layer Agent Memory
A complete memory system for OpenClaw agents. Without memory, every session starts from zero. With it, the agent remembers decisions, mistakes, preferences, and project context.
Core principle: LLMs forget everything between sessions. Memory lives in files that auto-load into every session.
References
| Запрос | Файл |
| Шаблоны файлов памяти, структура MEMORY.md | Прочитай references/memory-structure.md |
| Правила памяти, жизненный цикл записей | Прочитай references/memory-rules.md |
Architecture: 3 Layers
┌──────────────────────────────────────────────┐
│ Layer 1: MEMORY.md (instant memory) │ ← Auto-loaded EVERY session
│ Always visible via Project Context │
├──────────────────────────────────────────────┤
│ Layer 2: memory/*.md (daily journals) │ ← Found via memory_search
│ Daily entries + topic files │
│ Semantic search across all files │
├──────────────────────────────────────────────┤
│ Layer 3: QMD (long-term memory) │ ← Automatic semantic search
│ Indexes ALL markdown files in workspace │
│ Finds relevant context by meaning │
└──────────────────────────────────────────────┘Layer 1: MEMORY.md
The ONLY file guaranteed to be seen every session. Auto-loaded into Project Context. Agent sees it without doing anything.
What goes here: Owner info, permanent rules, active projects, recent decisions, mistakes to avoid.
Key rule: Most important info in the first 10 lines. LLMs pay more attention to the top.
Layer 2: memory/*.md
Daily journals (memory/YYYY-MM-DD.md). Agent writes work results, decisions, context here. Accessed via memory_search — semantic search across all files.
Why separate: MEMORY.md has limited space. Everything that doesn't fit goes into journals. When the agent needs old context, it searches by meaning.
Layer 3: QMD
Automatically indexes all markdown files in workspace. When the agent calls memory_search("topic"), QMD finds relevant fragments by meaning.
- Provider: OpenAI
text-embedding-3-small - Indexes automatically
- Works passively — agent just searches
Mode 1: Memory Setup
Triggers: настрой память, memory setup
Steps:
- Create workspace structure:
workspace/
├── MEMORY.md — long-term memory (auto-loaded)
├── SOUL.md — identity & rules (owner-editable only)
├── HEARTBEAT.md — maintenance rules
├── memory/ — daily journals
│ └── YYYY-MM-DD.md
└── learning/
├── corrections.md — mistakes in RULE format
└── anti-patterns.md — what doesn't work- Create MEMORY.md from template in
references/memory-structure.md - Add memory_search to SOUL.md (append, don't rewrite):
## Memory Recall
Before answering questions about prior work, decisions, or preferences: run `memory_search` first. Check memory/*.md for relevant context.- Enable Memory Flush in openclaw.json (if not already):
{
"agents": {
"defaults": {
"compaction": {
"memoryFlush": {
"enabled": true,
"softThresholdTokens": 4000
}
}
}
}
}Memory Flush automatically prompts the agent to save important context when the session approaches compaction. Set softThresholdTokens to trigger early enough (4000 recommended).
- Enable QMD in openclaw.json:
{
"memorySearch": {
"enabled": true,
"provider": "openai",
"model": "text-embedding-3-small"
}
}- Create today's journal
memory/YYYY-MM-DD.mdwith basic template. - Confirm: show what was created, what already existed, what was added.
Mode 2: Memory Check
Triggers: проверь память, memory check
Steps:
1. Check daily journals
- Check
memory/YYYY-MM-DD.mdfor last 3 days - Exist? Not empty?
- ✅ Present and filled → OK
- ⚠️ Missing or empty → warn
2. Check MEMORY.md
- When was it last updated?
- If >7 days → ⚠️ "MEMORY.md is stale"
- Are key sections filled?
3. Check learning/
- Does
corrections.mdhave entries? - Does
anti-patterns.mdhave entries? - Empty files = agent isn't learning
4. Consolidate
- Scan
memory/*.mdfor last 7 days - Collect key decisions, insights, facts
- Update MEMORY.md — add new, remove duplicates
- Update "Recent decisions" section
5. Cleanup
- Find files in
memory/older than 30 days - Suggest archiving to
memory/archive/ - Don't delete without confirmation
6. Report
🧠 Memory Health
━━━━━━━━━━━━━━━━
📁 Daily journals: X files
📅 Last entry: YYYY-MM-DD
📋 MEMORY.md: current / stale (X days)
📚 Corrections: X entries
🧹 To archive: X files (>30 days)
🔍 memory_search: enabled / not configured
💾 Memory Flush: enabled / not configured
Health Score: X/10Score:
- 10 — everything perfect, logs fresh, MEMORY current
- 7-9 — minor gaps (missed day, empty learning)
- 4-6 — problems (MEMORY stale, no logs 3+ days)
- 1-3 — critical (memory not working)
Mode 3: Memory Cleanup
Triggers: почисти память, memory cleanup
Ревизия и очистка памяти от мусора. Удаляет устаревшее, дубликаты, мёртвые записи.
Steps:
1. Ревизия MEMORY.md
Прочитать MEMORY.md целиком. Для каждой записи спросить:
- Актуально? Если решение заменено новым → удалить старое
- Дубликат? Если факт повторяется → оставить одну копию
- "НЕ использовать"? Если запись содержит "НЕ использовать", "устарело", "отменено" → удалить целиком
- Конкретно? Если запись расплывчатая и бесполезна → удалить
2. Ревизия learning/
corrections.md— удалить правки старше 30 дней, которые уже усвоены (повторяющиеся ошибки = не усвоены, оставить)approved-patterns.md— удалить паттерны которые стали очевидными и не нужны как напоминаниеrejected-patterns.md— удалить записи которые больше не релевантны (например, для удалённого формата контента)- Правки повторяющиеся 3+ раз → перенести как правило в SOUL.md (секция Learned Patterns), удалить из learning/
3. Ревизия memory/*.md
- Файлы старше 30 дней → предложить архивирование в
memory/archive/ - Пустые файлы → удалить
- Файлы с единственной записью "нет активности" → удалить
4. Лимиты SOUL.md
- Секция "Learned Patterns" — максимум 15-20 правил
- Если добавляется новое правило, а лимит превышен → вытеснить наименее важное
5. Отчёт
🧹 Memory Cleanup
━━━━━━━━━━━━━━━━━
📋 MEMORY.md: удалено X записей, осталось Y
📚 learning/: удалено X записей, перенесено Y правил в SOUL.md
📁 memory/: удалено X пустых, предложено архивировать Y файлов
📏 SOUL.md Learned Patterns: X/20 правил
Принцип: нет записи = нет токенов = нет путаницы.Критерий: после очистки MEMORY.md должен помещаться в ~2000 токенов. Если больше — продолжить чистку.
What Works and What Doesn't
✅ Works: Auto-loaded files (MEMORY.md)
Agent sees them every session without effort. 100% hit rate.
✅ Works: Semantic search (memory_search + QMD)
Agent finds old context by meaning. Passive, low-effort.
✅ Works: Memory Flush (compaction prompt)
Automatically saves context before session compaction. Safety net.
❌ Doesn't work: Databases (SQLite, etc.)
LLM won't query a database on its own. It needs to: decide something is missing → write SQL → execute → interpret. 4 steps it will never take unprompted. Tested at scale — 5 out of 10 agents had zero DB queries in a week.
❌ Doesn't work: Task queues in files
Files that require agents to actively check them get ignored. Use cron jobs or Notion instead.
❌ Doesn't work: Regex extraction
Parsing session logs with regex produces garbage. LLM-based extraction (reading logs with a model) works 10x better.
Memory Flush Format
When session nears compaction, the agent saves context in this format:
## Decisions
- [DECISION] what was decided → outcome
## Active Tasks
- [TASK] name | status: done/in-progress/blocked | next: concrete step
## Corrections
- [CORRECTION] what went wrong | [CORRECT] how to do it right | [RULE] [category] rule
## Context for Next Session
- key fact the future self MUST knowCategories for RULE: style | format | content | platform | tone | process
Corrections Format (learning/corrections.md)
CORRECTION: what happened
REASON: why it's wrong
CORRECT: how to do it right
RULE: [category] one-line rule for the futureThis format makes mistakes searchable and actionable. The agent reads corrections.md before repeating work.
MEMORY.md vs SOUL.md
| SOUL.md | MEMORY.md | |
| What | Identity, role, behavior rules | Facts, decisions, context |
| Who edits | Only the owner | Agent + extraction pipeline |
| Changes | Rarely | Constantly |
| Analogy | DNA | Working memory |
Rule: SOUL.md is read-only for agents. MEMORY.md is read-write.
Other versions9 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 9
- bojieli/ai-agent-book-projects★ 53ksame name
- bojieli/ai-agent-book★ 53ksame name
- vudovn/ag-kit★ 8.2ksame name
- vudovn/antigravity-kit★ 8.2ksame name
- kangarooking/system-prompt-skills★ 178same name
- joelhooks/joelclaw★ 64same name
- soumatheusgomes/agentville★ 9same name
- Mlu-ctrl-alt-design/claude-skills★ 1same name
- Victoriakaey/build-reliable-agents★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
Used alongsideProjects with it also use batch-operations, intelligent-routing and 10 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
goca-seSkillbatch-operations
Apply a change safely across many files — refactors touching more than 5 files, library or API migrations, project-wide renames of symbols/imports/paths, or adding boilerplate to many files. Use when "do it all at once" risks context overflow or silent failures.
Also in 3 projects that use this
SKB3002Skillintelligent-routing
Automatic agent selection and intelligent task routing. Analyzes user requests and automatically selects the best specialist agent(s) without requiring explicit user mentions.
Also in 3 projects that use this
xenitV1Skillbash-linux
Bash/Linux terminal patterns. Critical commands, piping, error handling, scripting. Use when working on macOS or Linux systems.
Also in 3 projects that use this
xenitV1Skillred-team-tactics
Red team tactics principles based on MITRE ATT&CK. Attack phases, detection evasion, reporting.
Also in 3 projects that use this
rohunvoraSkillcontext-compression
Design and evaluate context compression strategies for long-running agent sessions. Use when agents exhaust memory, need to summarize conversation history, or when optimizing tokens-per-task rather than tokens-per-request.
Also in 5 projects that use this
myths-labsSkillcoordinator-mode
Multi-agent coordination SOP derived from Anthropic's internal coordinator architecture. Use when orchestrating parallel workers, dispatching subagents, planning multi-step implementations, or when tasks require research→synthesis→implementation→verification workflow. Triggers: 'coordinate', 'dispatch workers', 'parallel agents', 'multi-agent', 'fan out', 'orchestrate'.
Also in 3 projects that use this
- +6 more from xenitV1
In this repository35 other files it gives its agents.
- agent-architectSkill
- agent-memorySkill
- audience-lensSkill
- carouselSkill
- constructor-opsSkill
- content-repurposerSkill
- copywritingSkill
- customer-researchSkill
- editingSkill
- headlinesSkill
- heygenSkill
- learning-processorSkill
- nano-banana-pro-promptsSkill
- nano-bananaSkill
- openclaw-opsSkill
- personal-unpackingSkill
- prompt-engineerSkill
- reelsSkill
- selling-meaningsSkill
- seo-blog-writerSkill
- shared-learningsSkill
- skill-creatorSkill
- skill-securitySkill
- soul-masterySkill
- storytellingSkill
- swipefileSkill
- telegram-adminSkill
- telegramSkill
- text-postsSkill
- threadsSkill
- timelapse-creatorSkill
- tone-of-voiceSkill
- veo-videoSkill
- video-editorSkill
- youtubeSkill
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

