Memory Bank Pattern
A cross-session memory system for AI coding agents built from versioned markdown files in a_memory/ directory. Designed around the constraint that LLM memory resets between sessions — the file system is the only durable state.
Source: Josh Wand’s coding-agent-rules repo (memory.md).
Core Premise
“My memory resets completely between sessions. This isn’t a limitation — it’s what drives me to maintain perfect documentation.”The agent treats
_memory/ as its only link to prior work. At session start, memory is compiled and loaded. After each turn, current task state is updated. The files must be maintained with enough precision for a fresh agent to pick up work mid-task without additional context.
Directory Structure
Session Bootstrap via repomix
Memory is compiled into a single markdown blob at session start using repomix:basicTruths/ and currentState/ files. knowledgeBase/ is excluded from the compile — loaded on-demand when relevant to the current task.
The agent’s first response must be this repomix tool call. No exceptions.
Mode-Based Workflow
Sessions follow a structured mode progression:- Check if task is clear
- Ask clarifying questions
- Develop strategy
- Present to user
- Refine with user
- Document in memory
- Check memory + task state
- Update
currentTaskState.md - Execute or identify yak-shaving dependency
- Loop until all subtasks complete → VERIFY
Commands
.ts should also update currentEpic.md and theBacklog.md when applicable. The goal: enough detail for a new agent to continue without additional context.
Yak-Shaving Tracking
currentTaskState.md maintains a yak-shaving stack — the dependency chain of subtasks needed to complete the current task. Each level is logged with status and outcome. This prevents context loss when a task branches into prerequisite work.
Key Distinctions from AGENTS.md
The Memory Bank solves the core AGENTS.md limitation identified in Wand’s critique: static files can’t carry evolving project state across sessions.
When to Use
- Long-horizon multi-session projects where session reset is the primary threat
- Projects where business context is as important as technical context
- Any setup where you want a new agent to resume work without human re-briefing
Relation to Other Memory Approaches
Related Pages
- Rules vs. Hooks — where Memory Bank fits in the rules/hooks spectrum
- AGENTS.md (format) — the AGENTS.md format whose limitations motivate this pattern
- Agentic Memory Tool — Anthropic’s native memory API approach
- Mnemory — self-hosted vector memory alternative
- Context Compression Strategies — clear-over-compact; Memory Bank makes clearing safe
- Agent Context Instructions — the broader concept this implements