# Claude Memory Compiler — Evolving Knowledge Base > Auto-capture Claude Code sessions into a structured knowledge base. Hooks extract decisions and lessons, compiler organizes into cross-referenced articles. No vector DB needed. 365+ stars. ## Install Save the content below to `.claude/skills/` or append to your `CLAUDE.md`: ## Quick Use 1. Clone and install: ```bash git clone https://github.com/coleam00/claude-memory-compiler.git cd claude-memory-compiler uv sync ``` 2. Copy the hooks config to your project: ```bash cp .claude/settings.json your-project/.claude/settings.json ``` 3. Use Claude Code as normal — sessions are captured automatically. Compile daily: ```bash uv run python scripts/compile.py ``` --- ## Intro Claude Memory Compiler is an evolving personal knowledge base for Claude Code with 365+ GitHub stars. It automatically captures your Claude Code sessions via hooks, extracts key decisions and lessons using the Claude Agent SDK, and compiles them into structured, cross-referenced knowledge articles. No vector database needed — uses a structured `index.md` approach that works better at personal scale. Inspired by Karpathy's LLM Knowledge Base architecture. Best for power users of Claude Code who want persistent memory across sessions. See also: [Claude Code Skills on TokRepo](https://tokrepo.com/en/collections/skills). --- ## 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: 1. **Session End** → hooks trigger `flush.py` 2. **Extraction** → Claude Agent SDK identifies decisions, patterns, and lessons 3. **Daily Logs** → insights saved to timestamped daily files 4. **Compilation** → `compile.py` organizes into cross-referenced articles 5. **Injection** → SessionStart hook loads `index.md` into 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.md` works better at personal scale - **Health checks** — `lint.py` runs 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 ```bash # 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.py ``` ### How 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 patterns ``` ### FAQ **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. --- ## Source & Thanks > Created by [Cole Medin](https://github.com/coleam00). Licensed under open source. > > [claude-memory-compiler](https://github.com/coleam00/claude-memory-compiler) — ⭐ 365+ Thanks to Cole Medin for building a practical memory system for Claude Code power users. --- ## 快速使用 1. 克隆并安装: ```bash git clone https://github.com/coleam00/claude-memory-compiler.git cd claude-memory-compiler uv sync ``` 2. 复制 hooks 配置到你的项目: ```bash cp .claude/settings.json your-project/.claude/settings.json ``` 3. 正常使用 Claude Code,会话自动捕获。每日编译: ```bash uv run python scripts/compile.py ``` --- ## 简介 Claude Memory Compiler 是一个 Claude Code 的个人知识库工具,GitHub 365+ star。自动通过 hooks 捕获 Claude Code 会话,用 Claude Agent SDK 提取关键决策和经验教训,编译成结构化、交叉引用的知识文章。不需要向量数据库,使用结构化 index.md 方式。灵感来源于 Karpathy 的 LLM 知识库架构。适合 Claude Code 重度用户。 --- ## Claude Memory Compiler — 从 AI 会话构建记忆 ### 工作流程 1. **会话结束** → hooks 触发 flush.py 2. **知识提取** → Claude Agent SDK 识别决策、模式、教训 3. **每日日志** → 保存到带时间戳的文件 4. **编译** → compile.py 组织成交叉引用文章 5. **注入** → SessionStart hook 加载 index.md 到下次会话 ### 核心特性 - **自动捕获** — hooks 在会话结束时触发 - **无需向量数据库** — 结构化 index.md 在个人规模更好用 - **健康检查** — lint.py 运行 7 项检查 - **查询接口** — 命令行搜索知识库 ### FAQ **Q: Claude Memory Compiler 是什么?** A: 自动捕获 Claude Code 会话并编译成结构化、可搜索知识库的开源工具。 **Q: 需要向量数据库吗?** A: 不需要,使用结构化 index.md 方式,在个人规模比 RAG 更好用。 --- ## 来源与感谢 > Created by [Cole Medin](https://github.com/coleam00). Licensed under open source. > > [claude-memory-compiler](https://github.com/coleam00/claude-memory-compiler) — ⭐ 365+ --- Source: https://tokrepo.com/en/workflows/4388e2e8-33ce-11f1-9bc6-00163e2b0d79 Author: Skill Factory