Prevent amnesia from context compaction. Persist what matters, forget what doesn't.
text
workspace/
└── memory/
├── INDEX.md # 索引 — 唯一必须全量加载的文件
├── decisions.md # 架构决策 + 理由(为什么选 X 不选 Y)
├── lessons.md # 教训与经验(bug 根因、workaround、踩坑记录)
├── project-context.md # 项目上下文(技术栈、目录结构、部署信息)
├── people.md # 人物信息(偏好、角色、沟通习惯)
├── tools-config.md # 工具与环境(命令备忘、环境配置、代理设置)
├── YYYY-MM-DD.md # 每日日记(自动创建)
└── archive/ # 归档(低价值淘汰 + 超期条目)
FileBudgetRationaleINDEX.md80Index only — fast to scandecisions.md200Architecture decisions with rationalelessons.md300Bug patterns, workarounds — high volumeproject-context.md150Stack, schema, config, deploy infopeople.md100User preferences, rolestools-config.md100Commands, env, proxy notesEach daily journal100Raw events, temporary
Every entry in categorized files uses this format:
markdown
## [YYYY-MM-DD] Title
- Tags: tag1, tag2, tag3
- Fitness: last_referenced=YYYY-MM-DD, hit_count=N, decision_value=HIGH|MEDIUM|LOW
- Body: one-line summary of the record
Scan the current session. Write to today's journal ( memory/YYYY-MM-DD.md):
Iron rule (铁律): Write decisions the moment they're made, not at session end. Context can vanish at any time.
Promote from daily journals to categorized memory files:
Promotion criteria:
Routing map:
Journal item typeTarget fileArchitecture/design choicedecisions.mdBug root cause, workaroundlessons.mdTech stack, deploy infoproject-context.mdUser preference, team rolepeople.mdCommand, env configtools-config.md
Memory hygiene via Survival Merge Protocol (优胜劣汰):
memory/archive/[PROVEN]Detailed protocol:
references/survival-merge.md
memory/INDEX.md — the only file you must load fully on every wakememory/YYYY-MM-DD.mdmemory/YYYY-MM-DD.mdBased on INDEX.md search hints, load when the task touches a domain:
decisions.md + project-context.mdlessons.mdpeople.mdtools-config.mdLoad-and-release: read the file, use it, do NOT carry it into subsequent turns.
memory_search (qmd or equivalent) for archive/ filesDetailed protocol:
references/mount-strategy.md
INDEX.md is the single source of truth for what memory exists. Rebuild it after every Deep Sleep or REM cycle.
markdown
# Memory Index
> Last rebuilt: YYYY-MM-DD | Total files: N | Budget: 500 lines per category
## Hot Files (load on session start)
| File | Lines | Last Updated | Recent Entries |
|------|-------|-------------|----------------|
| decisions.md | 45 | 2026-04-06 | Redis缓存策略, API版本v2 |
| project-context.md | 80 | 2026-04-07 | QMS技术栈, 数据库schema |
## On-Demand Files (load when relevant)
| File | Lines | Last Updated | Search Hint |
|------|-------|-------------|-------------|
| lessons.md | 120 | 2026-04-05 | bug根因, workaround, 踩坑 |
| people.md | 30 | 2026-03-28 | 人物偏好, 角色 |
| tools-config.md | 25 | 2026-04-03 | 命令备忘, 环境配置 |
## Daily Journals
| Date | Exists | Key Events |
|------|--------|------------|
| 2026-04-07 | ✅ | cron修复, Dreaming skill创建 |
| 2026-04-06 | ✅ | PraisonAI研究, GitHub同步 |
text
1. Read memory/INDEX.md
2. Read today + yesterday journals
3. Resume work
→ Dump to today's journal immediately: task state, in-flight decisions, open files, errors, next step.
WhenActionWrite toDecision madeWrite immediatelymemory/YYYY-MM-DD.mdSession endingDump current statememory/YYYY-MM-DD.mdNew sessionRead INDEX + 2 journalsL1 mountEvery 3 daysPromote + route + rebuild INDEXDeep SleepWeeklyFitness eval + archive + supersedeREMTask touches domainLoad relevant fileL2 mount
references/memory-lifecycle.md — 三阶段操作手册 + 文件分类规范references/anti-amnesia-checklist.md — 防失忆检查清单 + INDEX 维护references/mount-strategy.md — 挂载策略详细操作手册references/survival-merge.md — 优胜劣汰融合完整协议