MemStack: Giving Claude Code a Memory
Here's the fundamental problem with Claude Code: every session starts from zero.
You spend 45 minutes getting Claude up to speed on your project architecture, your coding conventions, your deployment setup — and then the session ends. Next time? Same 45 minutes. It's like working with a brilliant developer who has amnesia.
The problem
I was building AdminStack and realized I was repeating the same context dump every single session:
- "We use Supabase, not Prisma"
- "The deploy target is Railway, here's the config"
- "The component library uses this specific pattern"
- "Here's how the multi-tenant auth works"
Copy-pasting a massive prompt every time isn't a workflow. It's a workaround.
The solution: MemStack
MemStack is a framework that gives Claude Code persistent memory across sessions. Here's how it works:
The .claude/ directory
Every project gets a .claude/ directory with:
.claude/
├── rules/ # Auto-loaded project rules
├── hooks/ # Lifecycle event handlers
├── commands/ # Custom slash commands
└── settings.json # Project-specific config
When Claude Code starts a session, it automatically reads everything in .claude/rules/. That's where your project context lives — not in your clipboard, not in your head.
Skills (the real magic)
MemStack ships with 17 skills that handle common workflows:
- Diary — auto-logs sessions to SQLite with decisions and next steps
- Echo — semantic search across past sessions ("what did we decide about auth?")
- Work — structured task planning with status tracking
- KDP Format — converts manuscripts to print-ready Word docs (yes, I publish books too)
Each skill activates contextually. Say "save diary" and the Diary skill fires. Say "what did we do last session" and Echo runs a vector search.
The hook system
MemStack uses Claude Code's hook system for automation:
{
"hooks": {
"SessionStart": [{
"command": "python db/memstack-db.py get-context $PROJECT"
}],
"Stop": [{
"command": "python db/memstack-db.py auto-save"
}]
}
}
Session starts → load context. Session ends → save state. No manual intervention.
The result
Before MemStack: 45 minutes of context-setting per session. After MemStack: Claude picks up exactly where we left off.
It's not perfect — vector search sometimes surfaces irrelevant old sessions, and the SQLite database needs occasional pruning. But it turned Claude Code from a stateless tool into something that actually knows my projects.
The whole thing is open source. If you're doing serious work with Claude Code, this is the foundation everything else builds on.
Check out the repo: github.com/cwinvestments/memstack