Claude Memory Compiler — Build Memory from Your AI Sessions
The Problem
Claude Code sessions are ephemeral — valuable decisions, debugging insights, and architectural choices are lost when the session ends. You end up re-explaining the same context over and over.
The Solution
Claude Memory Compiler hooks into your Claude Code workflow and builds a growing knowledge base automatically:
- Session End → hooks trigger
flush.py - Extraction → Claude Agent SDK identifies decisions, patterns, and lessons
- Daily Logs → insights saved to timestamped daily files
- Compilation →
compile.pyorganizes into cross-referenced articles - Injection → SessionStart hook loads
index.mdinto next session
Key Features
- Automatic capture — hooks fire on session end + pre-compaction safety net
- Knowledge extraction — AI identifies decisions, patterns, and lessons learned
- No vector database — structured
index.mdworks better at personal scale - Health checks —
lint.pyruns 7 checks (broken links, orphans, contradictions, staleness) - Daily compilation — automatically triggers after 6 PM local time
- Query interface — search your knowledge base from the command line
Setup
# Install dependencies
uv sync
# Copy hooks config to your project
cp .claude/settings.json your-project/.claude/settings.json
# Compile knowledge base
uv run python scripts/compile.py
# Query your knowledge base
uv run python scripts/query.py "How did I handle the auth migration?"
# Run health checks
uv run python scripts/lint.pyHow Knowledge Is Organized
knowledge/
index.md # Master index, injected into each session
architecture/ # System design decisions
debugging/ # Bug patterns and solutions
conventions/ # Code style and project rules
integrations/ # Third-party service patternsFAQ
Q: What is Claude Memory Compiler? A: An open-source tool that automatically captures Claude Code sessions and compiles them into a structured, searchable knowledge base that persists across conversations.
Q: Does it require a vector database?
A: No. It uses a structured index.md approach inspired by Karpathy's LLM Knowledge Base architecture, which works better than RAG at personal scale.
Q: How does it integrate with Claude Code? A: Via Claude Code hooks — it captures sessions automatically on end, extracts insights, and injects the knowledge index at session start.