Creating a Second Brain with Claude Code
I've 2x’d my productivity as a VP of Product @mercury by creating a "Second Brain" using 5 years of work history, 15k docs with 3.5 million words, and every tool in my stack. It runs locally, is a core part of my every use of LLM, and gets better everyday.
Today, I want to share the stack, the workflow, and the prompt to build it:
Background
I am a VP of Product for @mercury, which is a long way of saying I'm in a lot of meetings, consuming a lot of content across different tools (linear, slack, notion, data analyses), and trying to make sure I actually get stuff done. Working at a company for 5 years and being an information addict, I am essentially a walking encyclopedia for Mercury post 2021-today -- but I've recently found that my scope + workload means I can't keep every plate spinning.
One day, I was scrolling X and came across a series of posts that caught my attention, starting with Tobias Lütke 's QMD. QMD is a local vector search, and then a few other posts started to show up that connected a few dots for me:
I decided that it was time to build
Prep work (~1-2 hours end to end)
To start, I needed a library of all the content I could know about... so I downloaded every document I've ever created for my job at Mercury + any relevant product strategy, analysis, retro, reflection on execution, etc. This netted out to over 15k documents and 3.5 million words. Maybe I've read them all, but I've forgotten most. These became a folder that I just called "raw data", and I ran QMD to index this on my computer.
To see if this worked, I used Claude Code to ask about random memories and surprising insights from this knowledge base - the amount of delight/surprise I experienced in seeing how much more capable vector search was than text-based search gave me the confidence to keep going. I asked one questions about books that it would think I like, and it was spooky how good of recommendations it gave me. I think this is my best advice in this journey: test every step of the way! Easy to get caught in hill climbing a local maxima
Train my brain and connect it to my tools (~2 hours)
With all the raw data, I needed to help it make sense of me + what my goals are + the tools I used, so pursued three paths:
Claude had access to all the information about me + the tools I used + had a massive library of all my work, but did it really know anything? Does anyone?
Wire it up (<1 hour)
At this point, I had so many words + documents that it was time to actually find use or abandon ship. But I didn't want to have to go search this every time and that's when "hooks" caught my attention.
Hooks from Claude Code let you insert content into your prompt without needing to ask (or when a session starts, after a tool use, or when a session stops). Using the UserPromptSubmit hook, I enabled my Claude Code to use qmd to find names + topics + specific documents related to my prompt.
This is a nerd-out moment, but when searching for files in Finder, it is mostly a name + raw text search.... but QMD can help bring context into searches. My system is tuned to figure out a query, then returns results using one of two techniques:
Very quickly after injecting context into prompts, I saw the quality of my results improving. My ability to bring lazy jargon and limited context, then have Claude enrich it with my "Second Brain" content showed me the power of the right context + tools going into every query, and I started to have weird things happen.... but more on that in a minute, because I had one more major step to unlock
Recommended by LinkedIn
Let it learn
GasTown and OpenClaw agents seemed to get better because they are consistently updating their memory (a written .md) file, so I started to wonder if I could learn this way too. I found that there are essentially three time frames in to self-reflect, increment new knowledge, and :
What this looks like in practice
It is a strange experience to describe how you use a brain, or a second one for that matter, but I legitimately believe I've 2x'ed my productivity as a whole and I want to share some practical examples.
Here's what an actual conversation looks like:
The proactive explorer mode
Because this system is so capable and knowledgable (+I'm so biased on my POV after 5 years in a job), I've started asking it regularly to think about the company priorities, all my knowledge and experience, and has access to all the tools I have, the Second Brain system is capable of doing autonomous research for how I can solve my problems.
At this point, it is no longer a cohesive narrative because I'm actively in this: I've started layering on other new functionality like Cron/Scheduled jobs, Agent Teams/Swarm, @karpathy's AutoResearch capabilities, Lenny Rachitsky 's interview archives... These flow into my daily briefs, sectioned-off parts of my memory, and become skills that are re-usable.
A note on data security, sensitivity, etc
There's a few things that are hard to fit nearly into this post, but I've thought a ton about how to make sure I'm not leaking private information to the world.
There's more to this, but critical step! Please make sure to follow all laws and regulations you have with your job
The Second Brain system (as drawn by itself)
A prompt you can use
I want you to help me build a "Second Brain" — a persistent knowledge system that runs in parallel to my work using Claude Code. We'll do this in 5 phases. Walk me through each one interactively. Don't skip ahead — confirm each phase is working before moving on.
## Phase 1: Interview Me & Create my Profile
Interview me to create a file at ~/Documents/second-brain/me.md that captures:
- Who I am (role, company, responsibilities)
- What I'm optimizing for (goals, priorities, what success looks like)
- My working style (tools I use daily, how I communicate, what frustrates me)
- My growth edges (feedback I've gotten, patterns I want to break)
- What I care about outside work (interests, values — helps with recommendations)
Ask me 5-7 questions conversationally. Don't make me fill out a template. Write the file when you have enough.
## Phase 2: Build the Knowledge Base
Help me collect and index my work history:
1. Ask me where my documents live (Google Docs, Notion exports, local files, etc.)
2. Help me export/download them into ~/Documents/second-brain/raw/
3. Install QMD (https://github.com/tobi/qmd) if not present: `bun install -g qmd`
4. Create a QMD collection from the raw folder: `qmd collection add Documents/second-brain/raw`
5. Index it: `qmd update`
6. **Test it together** — ask me for a few things I remember working on, then search the KB to see if it finds them. Try both `qmd search` (keyword) and `qmd vsearch` (semantic). If results are bad, we troubleshoot before moving on.
## Phase 3: Distill & Summarize
Using me.md + the knowledge base, create ~/Documents/second-brain/summaries/ with:
- strategic-context.md — what my company/team is trying to do and why
- role-context.md — my specific responsibilities and how I fit in
- historical-context.md — key decisions, pivots, lessons from my work history
- team-context.md — who I work with, dynamics, stakeholders
- personal-growth.md — patterns in my feedback, coaching themes
For each file, search the KB extensively (10+ queries mixing keyword and semantic search), cite specific source documents, and flag where you're inferring vs. quoting.
## Phase 4: Wire Up Automatic Context Injection
Create a Claude Code hook that enriches every prompt with relevant KB context.
Create ~/.claude/hooks/context-enrichment.sh that:
1. Extracts key terms and names from my prompt
2. Runs parallel searches (semantic + keyword) against the QMD collection
3. Returns the top results as context injected into the prompt
4. Completes in <2 seconds (kill searches that take longer)
Register it in ~/.claude/settings.local.json as a UserPromptSubmit hook.
The hook should output a <context> block with search results so Claude sees it but it doesn't clutter my conversation.
Test it: I'll type a lazy prompt about something in my KB and we'll see if the hook injects useful context.
## Phase 5: Create the Learning Loop
Set up three learning mechanisms:
### Per-session: /learn skill
Create ~/.claude/skills/learn/SKILL.md that:
- Reviews the conversation for mistakes, surprises, and validated approaches
- Updates ~/.claude/CLAUDE.md with new tool gotchas, workflow preferences, corrections
- Saves important context to memory files in ~/.claude/projects/-Users-{me}/memory/
- Bias toward brevity — only save what's genuinely new and useful for future sessions
Create a script at ~/.claude/scripts/morning-brief.sh that:
- Checks my calendar (if Google CLI is available)
- Searches the KB for context related to today's meetings
- Summarizes any updates from connected tools
- Outputs a brief I can read in 2 minutes
Help me set it up as a launchd job that runs at my preferred morning time.
### Per-month: Retro prompt
Create ~/.claude/skills/retro/SKILL.md that walks me through:
- What were we trying to accomplish this month?
- How did it actually go?
- What patterns are emerging (good and bad)?
- What should change next month?
- Update summaries/ with anything that's shifted.
---
## Rules for this whole process:
- Ask before installing anything
- Test each phase before moving to the next
- If something fails, don't retry — propose 2 alternatives
- Keep all files in ~/Documents/second-brain/ (KB) or ~/.claude/ (config)
- No over-engineering — functions over classes, scripts over frameworks
- Everything should be runnable, debuggable, and modifiable by me later
Start with Phase 1. Interview me.
Revenue | Estrategia | Analytics
1wHi, I'm trying a similar but oversimplified approach and find out I'm running out of tokens all the time. My setup is Code + Routines + GDrive docs as persistent memory + connectors to drive, gmail, calendar, slack, salesforce ... any thoughts on what could I be getting wrong?
Cool thanks for sharing Ryan
Love this. Appreciate you sharing.
Very cool. Can’t wait to experiment with this.