claude-memory-compiler: the first serious Karpathy-wiki implementation for Claude Code
A plain-English guide to claude-memory-compiler by Cole Medin — the Karpathy LLM-wiki pattern wired directly into Claude Code via hooks and an MCP server. Your agent compiles institutional knowledge while you sleep.
Short version: claude-memory-compiler is the first serious Karpathy-wiki implementation built specifically for Claude Code. Hooks capture what you do; the Agent SDK extracts decisions and patterns; a compiler LLM organizes everything into a cross-referenced Markdown wiki. Your agent gets smarter about your codebase while you sleep. By Cole Medin (coleam00), MIT licensed. 20-minute install.
What is claude-memory-compiler?
The Karpathy LLM-wiki pattern says: have the agent compile its own structured wiki as it works. claude-memory-compiler is the first serious implementation of that pattern wired directly into Claude Code.
How it works: Claude Code hooks fire on session start/end. The Agent SDK reads the session data and extracts the important bits — architectural decisions, recurring patterns, tricky edge cases. A compiler LLM organizes those into cross-referenced Markdown pages. You commit those pages to your repo. Next session, Claude reads them first.
It's not a memory abstraction — it's a living wiki that writes itself alongside your code.
Who this is for
- 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, opinionated implementation.
- Anyone tired of writing CLAUDE.md by hand and watching it go stale.
Skip this if
You're non-technical or don't use Claude Code. This is Claude Code-specific by design — it leans into CC's hooks and Agent SDK. For general org memory, look at gbrain or obsidian-wiki.
What problem it solves
Every Claude Code user has the same breakdown cycle: you invest an hour teaching Claude your codebase. It gets smart. The session ends. Next session, it has no idea. You write CLAUDE.md — helps for a week — then it goes stale because you stop updating it.
claude-memory-compiler automates the maintenance. Every session contributes to the wiki. Stale-ness is handled by the compile step re-reading and updating pages as patterns evolve. You stop maintaining docs by hand; the docs maintain themselves from the reality of your work.
How to install it (plain English)
- Clone the repo. Pick a directory outside your main project.
git clone https://github.com/coleam00/claude-memory-compiler.git, thennpm install. - Configure. Copy
.env.exampleto.env. SetANTHROPIC_API_KEYandWIKI_OUTPUT_DIR(recommend your main project repo so it's version-controlled). - Register the hooks. The repo ships with Claude Code hooks that fire on session start/end. Follow the README's "Install hooks" section — usually one command.
- Register the MCP.
claude mcp add memory-compiler node /path/to/claude-memory-compiler/mcp-server.jsso the agent can read the wiki it's building. - Work normally. Compile periodically.
npm run compileturns session data into structured pages. Schedule it (cron) or run manually.
Full walkthrough: /memory/tools/claude-memory-compiler.
What you can do with it (for a non-technical founder)
If your eng team is running this:
- New hires get a living codebase wiki on day one — onboarding shrinks from weeks to days.
- Architecture decisions survive turnover — the compiler captures "we picked tRPC over REST because of X" even if that engineer leaves.
- Claude stops re-asking obvious questions — it reads the wiki before asking.
- The wiki is git-versioned — you can see what your codebase learned each quarter.
- Zero extra maintenance — the compile step replaces the death of CLAUDE.md.
What CLO adds on top
claude-memory-compiler builds a living codebase wiki for your agent. Cognition CLO tracks which concepts your engineering team is actually retaining from that wiki. Different scope, complementary: the compiler ensures the agent knows; CLO ensures your humans know. Ship both if code quality and team coherence both matter.
FAQ
How much does the compile step cost in tokens?
Configurable. Route the compile to Claude Haiku for pennies per day, or to Sonnet for richer extraction. Cole's repo has model-swap examples.
Does it work for multi-repo setups?
Yes. Run one compiler per repo, or one compiler with a repo-routing config. The repo README documents both patterns.
What does the output wiki look like?
Cross-referenced Markdown pages. Typical structure: /architecture/*.md, /decisions/*.md, /patterns/*.md, /glossary/*.md. Opens cleanly in Obsidian, VS Code, or any Markdown reader.
Can I hand-edit the generated pages?
Yes. The compiler respects your edits on the next run. This is exactly the workflow git was built for.
Is there a way to see what the compiler decided to extract?
Yes — the compile step logs its decisions. You can audit what got pulled from each session.
How does it compare to gbrain?
gbrain is the company-brain shape (people/projects/decisions). claude-memory-compiler is the engineering shape (architecture/patterns/decisions). Use both if you want a full company brain with a dedicated codebase section.
How does it compare to obsidian-wiki?
obsidian-wiki is Python + Obsidian-targeted, ingests from transcripts/Slack. claude-memory-compiler is Node + Claude Code-targeted, ingests from CC sessions. Different source material, same pattern.
Ready to install? Full walkthrough at /memory/tools/claude-memory-compiler. Deep dive on the pattern: /blog/what-is-the-karpathy-llm-wiki-pattern. Credit to @coleam00 — star the repo if it becomes your team's permanent memory layer.
Share this post: