docs/best-practices/memory-bank.mdx
Memory Bank is a documentation methodology that transforms Cline from a stateless assistant into a persistent development partner. Through structured markdown files, Cline can "remember" your project details across sessions.
.clinerules/memory-bank.mdMemory Bank files are regular markdown files in your project that both you and Cline can access. They're organized hierarchically to build a complete picture of your project:
memory-bank/
├── projectbrief.md # Foundation document
├── productContext.md # Why this project exists
├── activeContext.md # Current work focus
├── systemPatterns.md # Architecture & patterns
├── techContext.md # Tech stack & setup
└── progress.md # Status & milestones
| File | Purpose |
|---|---|
projectbrief.md | Foundation document with core requirements and goals |
productContext.md | Why the project exists, problems it solves, UX goals |
activeContext.md | Current focus, recent changes, next steps (updates most frequently) |
systemPatterns.md | Architecture, design patterns, component relationships |
techContext.md | Tech stack, setup, constraints, dependencies |
progress.md | What works, what's left, known issues |
These work alongside Cline's built-in slash commands. In particular, /newtask and /smol help you manage context windows without losing progress.
Every AI model has a context window that limits how much information it can process at once. As you work, this window fills with conversation history, file contents, and tool results. Memory Bank helps you preserve important knowledge when you need to free up space.
When your context window fills up:
This preserves important context in your Memory Bank files before the window clears, letting you continue seamlessly in a fresh conversation.
activeContext.md changes most frequently; update it after each sessionprogress.md tracks milestones; review it when resuming workCopy this into a Cline Rules file (for example, .clinerules/memory-bank.md) or your global custom instructions:
# Cline's Memory Bank
I am Cline, an expert software engineer with a unique characteristic: my memory resets completely between sessions. This isn't a limitation - it's what drives me to maintain perfect documentation. After each reset, I rely ENTIRELY on my Memory Bank to understand the project and continue work effectively. I MUST read ALL memory bank files at the start of EVERY task - this is not optional.
## Memory Bank Structure
The Memory Bank consists of core files and optional context files, all in Markdown format. Files build upon each other in a clear hierarchy:
### Core Files (Required)
1. `projectbrief.md`
- Foundation document that shapes all other files
- Created at project start if it doesn't exist
- Defines core requirements and goals
- Source of truth for project scope
2. `productContext.md`
- Why this project exists
- Problems it solves
- How it should work
- User experience goals
3. `activeContext.md`
- Current work focus
- Recent changes
- Next steps
- Active decisions and considerations
- Important patterns and preferences
- Learnings and project insights
4. `systemPatterns.md`
- System architecture
- Key technical decisions
- Design patterns in use
- Component relationships
- Critical implementation paths
5. `techContext.md`
- Technologies used
- Development setup
- Technical constraints
- Dependencies
- Tool usage patterns
6. `progress.md`
- What works
- What's left to build
- Current status
- Known issues
- Evolution of project decisions
### Additional Context
Create additional files/folders within memory-bank/ when they help organize:
- Complex feature documentation
- Integration specifications
- API documentation
- Testing strategies
- Deployment procedures
## Documentation Updates
Memory Bank updates occur when:
1. Discovering new project patterns
2. After implementing significant changes
3. When user requests with **update memory bank** (MUST review ALL files)
4. When context needs clarification
REMEMBER: After every memory reset, I begin completely fresh. The Memory Bank is my only link to previous work. It must be maintained with precision and clarity, as my effectiveness depends entirely on its accuracy.
Custom instructions or Cline Rules?
Either works. Custom instructions apply globally across all projects. A Cline Rules file is project-specific and stored in your repo, which makes it easy to share with collaborators. You can also use conditional rules to activate Memory Bank instructions only when working with memory-bank/ files.
How often should I update? After significant milestones or direction changes. For active development, every few sessions. You can also let Auto Compact handle routine context management and reserve manual "update memory bank" for important checkpoints.
Does this work with other AI tools? Yes. Memory Bank is a documentation methodology that works with any AI that can read docs. Commands may differ but the approach works across tools.
Different from README files? Memory Bank provides structured, comprehensive documentation designed for AI context management, going beyond what a single README covers. It includes files for active context and progress tracking that change frequently, unlike a typical README.