Layered Memory Architecture
by @uselesslibraries
Build cheap, truthful long-term memory for agents with a layered architecture instead of a memory blob. Design, explain, audit, or improve a system that sepa...
clawhub install layered-memory-architectureπ About This Skill
name: layered-memory-architecture description: Build cheap, truthful long-term memory for agents with a layered architecture instead of a memory blob. Design, explain, audit, or improve a system that separates hot canon, durable topic doctrine, project-scoped working memory, episodic logs, and generated live summaries. Use when creating token-efficient agent memory, reducing memory bloat and context cost, comparing layered memory against generic persistent-memory systems, defining memory boundaries, improving retrieval trust, or migrating from blob memory to a layered model.
Memory Architecture
Design memory as a system, not a bucket.
Core stance
Optimize for: 1. truthful retrieval 2. low token cost 3. clear boundaries 4. maintainable long-horizon continuity 5. project isolation where neededDo not default to "store more and search later." First decide what kind of memory something is.
The five-layer model
Use these layers consistently:1. Hot canon - Small, frequently loaded, cross-session truths. - Identity, preferences, standing doctrine, current priorities, compact cross-project lessons. - Keep it aggressively bounded.
2. Durable topic doctrine - Stable architecture notes, decisions, playbooks, operating rules, and domain context. - More detailed than hot canon, but still curated.
3. Project-scoped working memory - Raw or evolving material tied to one initiative. - Research notes, migration plans, transcripts, experiment outputs, snapshots. - Promote only distilled lessons upward.
4. Episodic logs - What happened today or in a specific work session. - Events, observations, intermediate findings, next steps. - Default landing zone for fresh information.
5. Generated live summaries - Rebuildable operator read models for current state. - Queue views, alerts, health snapshots, status summaries, compact log digests. - Treat as derived state, not durable canon.
Memory classification rule
Before writing memory, classify the item:If uncertain, bias downward:
Promotion / demotion flow
Use this ladder:Truthfulness rules
Never let memory blur these categories:Do not promote temporary red/yellow/green conditions, queue counts, disk snapshots, or stale alerts into canon unless they reveal a durable rule.
Retrieval policy
Retrieve in this order: 1. hot canon 2. compact index/selector 3. relevant topic docs 4. project memory only if the task is project-specific 5. generated summaries before raw logs for live-state questions 6. raw logs only when summary is insufficient or needs verification 7. episodic logs only when recent event history mattersThe goal is not maximum recall. The goal is the right recall.
Comparison frame
When comparing layered memory against generic persistent-memory tools, use this lens:Generic persistent-memory systems usually optimize for:
Layered memory systems optimize for:
Use this summary line:
If needed, read references/scorecard.md for a compact comparison rubric.
Anti-patterns
Flag these quickly:Output patterns
For comparisons or teaching material, prefer one of these structures:Use bundled references only when needed
references/scorecard.md when preparing a digestible comparison, talk track, or publishable rubric.references/migration-pattern.md when helping someone convert an existing persistent-memory setup into a layered one.references/layout-template.md when the user wants a concrete starter structure for implementing layered memory in a workspace.references/audit-checklist.md when the user wants a repeatable audit of an existing memory setup instead of a high-level philosophy discussion.references/classifier-pattern.md when the user wants a lightweight routing rule for deciding where fresh information belongs.references/promotion-trigger-pattern.md when the user wants a safe promotion model for moving notes upward over time.references/summary-generator-pattern.md when the user wants live-state summaries that remain derived and rebuildable rather than polluting canon.Reliability rules
Keep the explanation compact unless the user explicitly wants a deep comparison.