Managing Memory
Build a local knowledge base for progressive disclosure by the agent
Memory and context retrieval belong to the context machinery layer of the harness (see Harness Engineering). Progressive disclosure โ the agent reads more only when a task needs it โ is the same idea as Skillsโ on-demand loading: keep the baseline light, retrieve the depth lazily.
Do You Need Memory?
For most projects, Rules are sufficient.
| Aspect | Rules | Memory |
|---|---|---|
| Determinism | โ You know exactly which rules are applied | โ ๏ธ Agent reads on-demand, may miss some |
| Use Cases | Coding standards, tech stack conventions | Business knowledge, troubleshooting history |
Memory is suitable when:
- Extensive business domain knowledge needs AI understanding
- Need to track troubleshooting history
- Want AI to learn from past implementations
Memory uses progressive disclosure โ the agent reads based on needs. If certain rules must always apply, use Always Apply Rules.
Our Local Memory Practice
We chose local files over embedding solutions:
- No tool call limits - Cursor Agent can freely read local files
- Cost-effective with powerful models - with Opus-class models, more context in one request is economical
- Version controlled - memory evolves with your codebase
Directory Structure
- README.md
- index.md
- business-domain.md
- key-features.md
- troubleshooting.md
| File | Purpose |
|---|---|
README.md | Usage protocol - Agent learns how to use memory from here |
index.md | Main index linking to all topics |
business-domain.md | Business knowledge (core concepts, business rules) |
key-features.md | Core features and implementation notes |
troubleshooting.md | Common issues and solutions |
Core Design: File System as Interaction Protocol
Key insight: Rules only need to tell the agent โwhat the .memory directory isโ. The detailed usage protocol lives in .memory/README.md.
Benefits:
- โ
Rules donโt need dynamic maintenance - Memory usage conventions evolve independently inside
.memory - โ Self-documenting - Agent gets the latest instructions by reading README.md
- โ Decoupled - The memory system expands without touching rules
Rules Configuration (Minimal)
---
alwaysApply: true
---
# Memory System
This project uses `.memory/` directory as knowledge base.
Before starting complex tasks, read `.memory/README.md` to understand usage..memory/README.md (Full Protocol)
# Project Memory Knowledge Base
This directory is the project memory, storing knowledge the AI Agent needs.
## ๐ Usage Protocol
### When to Read Memory
- Before starting complex tasks
- When dealing with business logic
- When uncertain about implementation details
### When to Update Memory
- After completing important features
- After solving tricky problems
- When documentation doesn't match reality
### Navigation
- Start from `index.md` for navigation
- Use `[[filename]]` links to jump
- Keep memory concise, avoid redundancy
## ๐๏ธ Directory Structure
```
.memory/
โโโ README.md # This file: usage protocol
โโโ index.md # Main index
โโโ business-domain.md # Business knowledge
โโโ key-features.md # Core features
โโโ troubleshooting.md # Common issues
```.memory/index.md (Navigation Entry)
# Project Memory Index
## Business
- [[business-domain]] - Core concepts, business rules
## Features
- [[key-features]] - Key feature implementation notes
## Troubleshooting
- [[troubleshooting]] - Known issues and solutions.memory/business-domain.md (Business Knowledge Example)
# Business Knowledge
## Core Concepts
### User Roles
- **Admin** - Full permissions, can manage other users
- **Editor** - Can create and edit content
- **Visitor** - Read-only access
### Order Status Flow
pending โ paid โ shipped โ delivered
โ cancelled
## Business Rules
- Orders can be cancelled within 30 minutes after payment
- Auto-switch to pre-order when out of stock
- Members get 10% discountProgressive Disclosure
The agent reads memory incrementally based on task needs:
Best Practices
| Do | Donโt |
|---|---|
| โ Keep each file under 200 lines | โ Duplicate content already in Rules |
| โ Use clear headers and bullet points | โ Store sensitive information |
| โ Update memory after important work | โ Let files grow too large |
Next Steps
- How Rules Work - Understand Rules basics
- Rules Writing Best Practices - Write effective Rules
- Context Management - Broader context strategies