claude-memory-compiler
This is the first serious implementation of Karpathy's LLM-wiki pattern specifically for Claude Code. As you work in Claude Code, hooks capture what happened; the Agent SDK extracts the key decisions and patterns; a compiler LLM organizes everything into cross-referenced Markdown articles. Your agent gets smarter about your codebase while you sleep.
- Technical founders and staff engineers deep in Claude Code daily
- Teams that want their coding agent to compile institutional knowledge automatically
- Builders who want to see the Karpathy pattern in a shipping implementation
What you'll do
claude-memory-compiler is installed as a Claude Code hook + MCP server. It watches your sessions, extracts decisions, and writes a living wiki. Budget 20 minutes the first time.
Before you start
- Claude Code installed and working on a project
- git, Node.js 20+
- An Anthropic API key (for the compilation step)
Step-by-step install
- 011. Clone the repo
Pick a directory outside your main project to host the compiler. Clone there.
git clone https://github.com/coleam00/claude-memory-compiler.git cd claude-memory-compiler npm install
- 022. Configure
Copy .env.example to .env. Set ANTHROPIC_API_KEY and WIKI_OUTPUT_DIR (where your compiled Markdown should live — we recommend your main project repo so it's version-controlled).
- 033. Register the hooks
The repo ships with Claude Code hooks that fire on session start/end. Follow the README's 'Install hooks' section — it's usually a single command that writes the hook config into your ~/.claude directory.
Tip: Hooks run locally. Nothing leaves your machine unless you explicitly call the compile step, which uses the Anthropic API. - 044. Register the MCP
Add the compiler's MCP server to your Claude Code config so the agent can read the wiki it's building.
claude mcp add memory-compiler node /absolute/path/to/claude-memory-compiler/mcp-server.js
- 055. Work normally — let it compile
Open Claude Code as usual. The hooks silently capture sessions. Periodically (or on a schedule) run the compile step, which converts raw session data into structured wiki pages.
npm run compile
Your first 10 minutes
- 01Run a normal Claude Code session on your project. Make a non-trivial change.
- 02Run `npm run compile`. Check your WIKI_OUTPUT_DIR — new pages should appear.
- 03Open one of the generated pages. Confirm it captured the architectural decision you just made.
- 04Commit the wiki to your project repo. Every future hire reads it on clone.
- 05Layer Cognition CLO on top — the compiler builds the brain; CLO tracks what your team is retaining from it.
Troubleshooting
Hooks don't fire.
Check ~/.claude/settings.json has the hooks registered. A common fix is re-running the install script with your shell sourced fresh.
Compile step uses a lot of tokens.
Cole's repo has configuration for which model the compile step uses. Route to Claude Haiku for cheaper (and surprisingly good) compilation.
claude-memory-compiler holds the knowledge. Cognition CLO models retention per employee per concept using a Weibull forgetting curve — so you see decay before it becomes a missed SOP or a failed audit.