Slavka Memory Pattern: Unlimited scalable memory with a fixed context window
Problem
Claude Code has a fixed context window. The more you stuff into CLAUDE.md, the less room for actual work. But projects grow — more files, more patterns, more knowledge to remember.
The real question: how do you give Claude unlimited memory without expanding the context window?
Solution: Slavka Memory Pattern
Instead of stuffing everything into CLAUDE.md, use short pointers that reference detailed files on disk. Claude reads the details only when the conversation context triggers them.
Think of it like human memory: you don't remember everything, but you remember where to find it. A library, not a backpack.
Traditional: Memory ≈ Context window (fixed)
Slavka Pattern: Memory ≈ ∞ files on disk, Context ≈ pointers only
Structure
~/.claude/CLAUDE.md ← Always loaded (~200 lines, ~3k tokens)
│
├─ Short rules & behavior
├─ Pointers to guides ──────→ ~/Projects/_guides/IT_WORKFLOW.md
│ ~/Projects/_tests/TESTING_GUIDE.md
│ ~/Projects/_guides/DOCKER_GUIDE.md
│ (loaded only when needed, 0 tokens otherwise)
│
└─ Project CLAUDE.md ───────→ ~/Projects/my-app/CLAUDE.md
(loaded only when working in that project)
How it works
CLAUDE.md contains a short pointer block:
## Guides (read on demand)
User is learning IT workflows. If the conversation touches these topics,
read the corresponding file before answering:
- **Git, branches, PR, deploy, CI/CD** → `~/Projects/_guides/IT_WORKFLOW.md`
- **Testing: when, which type, how** → `~/Projects/_tests/TESTING_GUIDE.md`
Do NOT load these files at session start. Read only when context requires it.
This block costs ~50 tokens. The full guides are 200+ lines each but cost 0 tokens until needed.
When the conversation touches testing → Claude reads the testing guide. When it's about CSS → nothing is loaded. Knowledge is available but doesn't consume context until relevant.
Project CLAUDE.md: the big win
Instead of Claude running Explore agents every session (~150k tokens to understand your codebase), document the project structure once:
## Frontend structure
src/public/js/modules/
├── state.js # Central state store
├── api.js # HTTP wrapper with retry
├── keyboard/
│ ├── index.js # Main handler: j/k/arrows/Cmd+K
│ ├── navigation.js # Focus tracking, list switching
│ └── actions.js # getFocusedItemData(), Enter/d/e/s handlers
├── marketplace/
│ ├── core.js # loadMarketplace(), filters, sort
│ └── renders.js # renderMarketplace(), item templates
## CSS classes for focus
- `.focused` — current element (border highlight)
- `.selected` — checked items (blue border)
Now Claude knows your project structure without expensive exploration.
Results
| Metric | Before | After |
|--------|--------|-------|
| Context used for "memory" | ~150k tokens | ~7k tokens |
| Available knowledge | Limited to CLAUDE.md | Unlimited files on disk |
| Explore agents per session | 2-3 | 0 |
| Can scale to 50+ guides | No (context overflow) | Yes (0 cost until loaded) |
The mental model
CLAUDE.md = RAM (always loaded, keep it small)
_guides/ = SSD (fast access when needed, unlimited capacity)
Explore = Internet (slow, expensive, avoid when possible)
Tips
- CLAUDE.md < 200 lines. Rules + pointers only.
- Use "read only when needed" phrasing. Claude respects this instruction.
- Document project structure once. Replaces expensive Explore agents forever.
- Guides are free until loaded. Have as many as you want — 0 tokens until read.
- Update after big refactors. The investment pays off every session.
The point is not saving tokens. It's unlimited scalable memory with a fixed context window.
---
Update (February 2026): Full open-source release
This pattern has evolved into a complete memory framework. The full system is now available as a public repo:
What's been added since the original post:
- SMP Cards — cross-project dependency mapping (agent knows changing API X will break bot Y)
- MCP Memory Server — external persistent storage with hybrid search (full-text + semantic)
- Automatic hooks — session start/end context loading, raw action logging, security checks
- Session anchors — key-moment logging that survives context compression
- Templates — ready-to-use CLAUDE.md, hooks, and settings for quick setup
Works with Claude Code, Cursor, Copilot, and any MCP-compatible agent.
This issue has 5 comments on GitHub. Read the full discussion on GitHub ↗