# I Built Self-Evolving Claude Code Memory w/ Karpathy's LLM Knowledge Bases <!-- ref: @content/youtube/cole-medin/i-built-self-evolving-claude-code-memory-w-karpathy-s-llm-knowledge-bases tags: [LLM knowledge bases, Claude Code hooks, long-term memory, Obsidian, Claude Agent SDK, compounding knowledge] version: 2 updated_at: 2026-11-24T06:05:02.709Z --> **[Watch on YouTube](https://www.youtube.com/watch?v=7huCP6RkcY4)** # I Built Self-Evolving Claude Code Memory w/ Karpathy's LLM Knowledge Bases *Synthesized from Cole Medin, 2026-04-06.* Cole Medin speaks alone, presenting his own build on top of a pattern Andrej Karpathy described for LLM-maintained knowledge bases. No host appears. ## Core Thesis Cole Medin argues that Andrej Karpathy's LLM knowledge-base pattern, which compiles raw external sources into a linked wiki, works just as well when the raw input is a coding agent's own session history. Using Claude Code hooks and the Claude Agent SDK, his setup turns each codebase's conversations into a memory that grows with the project, without a vector database. ## Key Insights - **Karpathy's pattern.** A raw folder of source markdown (articles, papers, transcripts) is compiled by an LLM into a wiki with concept pages and backlinks. An index file lets the agent navigate without RAG, and a linting pass checks for gaps, stale data, missing raw-to-wiki coverage and broken links. - **The compiler analogy.** Raw sources are source code, the LLM pass is the compiler, the wiki is the executable the agent queries, and linting is the test suite. - **Internal instead of external data.** Cole's variant takes Claude Code session summaries as the raw layer, so memory comes from the team's own decisions and lessons. - **Three hooks drive it.** A SessionStart hook loads the agents.md rules and index.md. PreCompact and SessionEnd hooks send the transcript to a separate Claude Agent SDK process that writes a summary into a daily log. - **Daily flush.** Once a day the logs are processed to extract concepts and connections into the wiki. The prompts live in the flush and compile scripts and can be edited. - **Subscription, not API key.** The Agent SDK process runs under the same Anthropic subscription that Claude Code uses, so no separate key is needed, according to the video. - **Speed on a warm memory.** A question that would otherwise need git log searches and sub-agents was answered from the knowledge base in about 10 seconds in his demo. - **Compounding loop.** Each answer can be filed back into the wiki, so the knowledge base grows with each session and each question. - **Obsidian as the viewer.** Obsidian opens the project folder as a vault to browse the daily logs, index and graph. ## Actionable Takeaways 1. Open the project folder as an Obsidian vault and keep an agents.md file and an index.md at the top of the knowledge base. 2. Add SessionStart, PreCompact and SessionEnd hooks in settings.json so each session loads the index and saves a summary before context is lost. 3. Treat the daily logs as raw input and run a daily flush that compiles concepts and connections into the wiki. 4. Edit the summarization and compile prompts in the scripts to fit what your project needs to remember. ## Notable Quotes > "It's simple but super effective." — Cole Medin > "There's no vector database here. It's nice and simple." — Cole Medin --- *Related: `@content/youtube/yifan-bth/let-the-agent-write-the-tests-and-the-fixes` · `@content/youtube/nate-herk/fable-5-karpathy-s-llm-wiki-is-basically-cheating` · `@content/youtube/tiago-forte/how-they-organize-everything-the-code-challenge` · `@content/youtube/tiago-forte/the-code-challenge-begins-3-strangers-30-days-one-method` · `@content/youtube/indy-dev-dan/one-prompt-every-agentic-codebase-should-have-for-engineering-teams`* --- *You're reading a protocol on [protocol.supply](https://protocol.supply) — hosted, searchable knowledge for AI agents. Think Agent Skills, as an API: bootstrap once (`curl -sL https://api.protocol.supply/bootstrap`), search (`/search?q=…`), fetch (`/@repo/slug`).* *Any skill can become a protocol, and any protocol installs as a local skill — tell your agent "install this as a skill" or see [`@protocol/protocol-to-skill`](https://api.protocol.supply/@protocol/protocol-to-skill).*