A unified memory system that prevents agents from forgetting what they did yesterday and ensures work survives session boundaries in written form.
Built from five proven patterns:
MEMORY.md small and usefultext
┌─────────────────────────────────────────────────────┐
│ MEMORY FORTRESS │
├─────────────────────────────────────────────────────┤
│ 🔴 SESSION RAM → temporary, lost on compaction │
│ 🟡 STATE/ → active task, blockers, decisions│
│ 🟢 DAILY LOG → memory/YYYY-MM-DD.md │
│ 🔵 MEMORY.md → curated durable knowledge │
│ ⚪ DOMAINS/ → topic-specific detail │
│ 📦 ARCHIVE/ → older logs │
│ 🧱 PROJECT FILES → task_plan.md + notes.md + output│
└─────────────────────────────────────────────────────┘
Core principle: session memory is temporary, files are truth.
Order matters.
text
1. state/HOLD.md — what is blocked? do not do these
2. state/ACTIVE.md — is there an active task?
3. state/DECISIONS.md — recent decisions, last 48h
4. state/CLOSED.md — durable closed decisions, not to be reopened casually
5. IDENTITY.md — who the agent is
6. SOUL.md — learned style and operating principles
7. USER.md — who the agent serves
8. memory/YYYY-MM-DD.md — today + yesterday
9. MEMORY.md — long-term knowledge, main session only
Post-boot status line:
text
🏰 Boot: ACTIVE=[task|none] | HOLD=[n] | DECISIONS=[n last 48h]
memory_searchWhen the user gives you a task:
state/ACTIVE.mdstate/ACTIVE.md format#markdown
## Active task
**User said:** "[exact quote]"
**Interpretation:** [what you believe it means]
**Status:**
- [ ] Step 1
- [ ] Step 2
**Updated:** YYYY-MM-DD HH:MM
state/HOLD.md format#markdown
[YYYY-MM-DD HH:MM | session] Item — reason for blocking
state/DECISIONS.md format#markdown
[YYYY-MM-DD HH:MM | session] Decision — context / rationale
state/CLOSED.md format#markdown
[YYYY-MM-DD | decider] Topic keyword — short final decision
Use CLOSED.md for issues that were definitively settled and should not keep resurfacing as open questions.
Session RAM can disappear. Save important things before that happens.
EventWhere to writeDecision madestate/DECISIONS.md + daily logPreference discoveredMEMORY.md or daily logTask receivedstate/ACTIVE.mdSomething blockedstate/HOLD.mdError + lessondaily log + .learnings/Important fact discovereddaily log, later promote if durableWork completedstate/ACTIVE.md + daily log
Rule: if it matters, write it immediately.
MEMORY.md?#Score each candidate on 4 axes from 0 to 3.
Axis0123DurabilityGone tomorrowWeeksMonthsYears+ReuseOne-timeOccasionalFrequentEvery sessionImpactTrivialHelpfulChanges outputChanges decisionsUniquenessObviousMildly usefulHard to re-deriveIrreplaceable
Put it in MEMORY.md if:
Everything else belongs in the daily log or a domain file.
MEMORY.md ≤10KB#text
memory/
├── domains/
│ ├── projects.md
│ ├── infrastructure.md
│ ├── people.md
│ ├── skills-tools.md
│ ├── lessons.md
│ └── policies.md
├── .learnings/
├── archive/
└── YYYY-MM-DD.md
MEMORY.md stores summaries, references, and the most important durable knowledgememory/domains/*.md stores detailed topic-specific materialmemory/archive/ stores old logsmemory/.learnings/ stores structured mistakes, corrections, and requestsPrefixTypeDECDecisionPREFPreferenceFACTDurable factPOLICYRuleLESSONLesson learnedERRKnown error
Use priority 1 to 10. Reserve 9 to 10 for truly critical items.
[STALE]Always use:
memory_searchmemory_getSearch order:
state/MEMORY.mdmemory/domains/*.mdmemory/YYYY-MM-DD.mdmemory/archive/Do not read entire memory trees "just in case."
RuleDetailsOwn workspaceEach agent writes in its own workspaceNo cross-readDo not read another agent's memory by defaultCommunicationUse direct agent messaging, not memory filesShared stateOnly explicitly shared foldersPrivate contextKeep private conversations private
Don'tDo instead"I'll remember this mentally"Write it to a file immediatelyPaste chat logs into MEMORY.mdUse daily log + summaryLet MEMORY.md bloatSplit into domain filesAnswer past-context questions from memory aloneSearch firstKeep many tasks in ACTIVE.mdOne active task, rest in project filesParaphrase the user's taskKeep the exact quoteStore secret valuesRecord only that they exist
.learnings/ — mistakes, corrections, and growth#Recommended files:
memory/.learnings/LEARNINGS.mdmemory/.learnings/ERRORS.mdmemory/.learnings/FEATURE_REQUESTS.mdLEARNINGS.md / correctionLEARNINGS.md / knowledge_gapLEARNINGS.md / best_practiceERRORS.mdFEATURE_REQUESTS.mdtext
TYPE-YYYYMMDD-XXX
Memory is not enough. The work itself must also exist in files.
If it's not written down, it doesn't exist.
WhatWhereIncoming taskstate/ACTIVE.md, exact user wordsDecisionstate/DECISIONS.md + daily logBlockerstate/HOLD.mdPermanently closed decisionstate/CLOSED.mdReorientation snapshotstate/ORIENT.mdResearch notesnotes.mdProject progresstask_plan.mdFinal outputa dedicated deliverable fileGeneral lesson.learnings/ or a domain file
Treat work as a project immediately if any of these are true:
For any non-trivial task, create:
text
projects/<project-slug>/
├── task_plan.md
├── notes.md
└── deliverable.md or another suitable output file
task_plan.md#markdown
# Task Plan: [name]
## Goal
[one-sentence end state]
## Phases
- [ ] Phase 1: setup
- [ ] Phase 2: discovery / research
- [ ] Phase 3: execution
- [ ] Phase 4: review / deliver
## Decisions Made
- [decision]: [why]
## Errors Encountered
- [error]: [resolution]
## Status
**Currently in Phase X** - [current focus]
notes.md#Use it for sources, raw findings, analysis, and anything too large for the live context window.
If you write a cron or automation prompt, include a dedicated section like this:
markdown
### Documentation (MANDATORY)
- Append a short run summary to: [exact file path]
- Format: YYYY-MM-DD | type | slug | summary
- This must be the last step before finishing
Because project files are memory too. task_plan.md, notes.md, and state/ORIENT.md together form the operational memory of ongoing work.
When an agent suddenly loses the thread, starts following the wrong branch of work, or needs to recover the real task from a long conversation, it should create a focused reorientation summary before doing more execution.
text
Read back the full thread content and summarize what we have done so far, where the task is documented, and what the next step is. Do not go further, only produce this detailed summary.
state/HOLD.md, state/ACTIVE.md, state/DECISIONS.md, state/CLOSED.mdtask_plan.md and notes.mdstate/ORIENT.mdstate/ORIENT.md format#markdown
## Reorientation snapshot
**Thread / Context:** [which thread or task this is]
**What we did so far:**
- ...
- ...
**Where it is documented:**
- `state/ACTIVE.md`
- `projects/<slug>/task_plan.md`
- `projects/<slug>/notes.md`
**Actual next step:**
- ...
**Do not do instead:**
- ...
- ...
**Closure criteria:**
- ...
- ...
**Last updated:** YYYY-MM-DD HH:MM
Because they create noise, duplicate the file-based source of truth, and consume context themselves. The correct model is: file-first summary, chat-only when useful.
If the recurring task is thread readback + summary + documented next-step recovery, use a dedicated context-rescue mini-skill.
FrequencyTaskEvery sessionrun boot sequenceEvery taskupdate ACTIVEImportant eventwrite immediatelyDailyreview daily log and clean stateWeeklysize-check MEMORY.md and update domainsBiweeklyarchive old logsMonthlydemote stale memories and resolve contradictionsOn errorwrite to .learnings/ERRORS.mdOn correctionwrite to .learnings/LEARNINGS.md
bash
mkdir -p state
touch state/ACTIVE.md state/HOLD.md state/DECISIONS.md state/CLOSED.md
bash
touch state/ORIENT.md
bash
mkdir -p memory/domains memory/archive memory/.learnings
bash
mkdir -p projects
Add the boot sequence, the write-before-lose rule, the documentation-first project pattern, and the failsafe ORIENT.md reorientation layer.
"Memory is what separates a tool from an ally."