brain
The brain is a private markdown wiki stored as an Obsidian vault. Claude writes and maintains the wiki pages (sources, projects, concepts, people, lessons, index), and the user opens the vault folder in Obsidian to browse and read the generated notes directly.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@brainsearch the brain for lessons about database migrations"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
brain-kit
A second brain for Claude Code that maintains itself.
You get a private markdown wiki (it opens in Obsidian) that Claude writes and keeps current, plus:
an MCP server, so every Claude Code session in every repo can search the brain and write to it
a scheduled sync, which turns your captured notes into linked wiki pages and keeps a page for each of your repos
a lessons ledger: mistakes your agents made become rules. You approve each one, and it then shows up either in your
CLAUDE.mdfiles or right before the tool call it guardshooks that load the current repo's page when a session starts, and save a worklog when a long session compacts
The brain starts empty. It fills up as you work.
Install
npm (needs Node 18+):
npx create-second-braincurl:
curl -fsSL https://raw.githubusercontent.com/lawrencehui/brain-kit/main/get.sh | shClaude Code plugin (the MCP server and hooks come from the plugin; /brain-kit:init then creates the vault and the sync schedule):
claude plugin marketplace add lawrencehui/brain-kit
claude plugin install brain-kit@brain-kit
# then, in Claude Code: /brain-kit:initfrom a clone:
git clone https://github.com/lawrencehui/brain-kit && ./brain-kit/install.shAll of them run the same installer. With no flags, it creates the brain at ~/brain and watches the repos under ~/Dev. To change that, pass flags. Flags work with every method; for curl, put them after sh -s --:
npx create-second-brain --vault ~/notes/brain --dev ~/code
curl -fsSL .../get.sh | sh -s -- --vault ~/notes/brain --dev ~/codeOnce it finishes, start a new Claude Code session so the MCP tools load.
Requirements
git, node/npm, python3, zsh, rg (ripgrep) and the claude CLI, on macOS or Linux. The installer checks for these and tells you which are missing.
Flags
Flag | Default | Meaning |
|
| Where the brain lives. Must be empty or not exist yet. |
|
| Folder whose git repos the brain tracks. |
|
| Name of the MCP server and of the scheduled job. |
| same as | Name of the capture command put on your PATH. |
|
| Model the sync uses. |
| none | Comma-separated list of steps not to run (see below). |
Related MCP server: Memlio
What the installer sets up
Step | What it does | Skip with |
vault | Copies the empty wiki template into | — |
mcp server | Installs the server's dependencies and runs its self-test | — |
cli | Adds a |
|
mcp | Registers the MCP server with |
|
schedule | Runs the sync four times a day (00:02, 06:02, 12:02, 18:02): launchd on macOS, crontab on Linux |
|
hook | Adds three Claude Code hooks to |
|
devclaude | Adds a short block to |
|
Every step can be re-run safely. Running the installer again on an existing brain updates the engine files and leaves your content alone. This is also how you upgrade.
Using it
In Claude Code, agents get four tools:
Tool | Use |
| Run at the start of a session. Returns the project's page, its latest worklogs and its lessons in one call. |
| Full-text search across the brain. |
| Read a page. Add a heading argument to read just that section. |
| Save a finding, decision, mistake or worklog. |
From a terminal:
brain "Postgres connection pool tops out at 20, not 100"
brain -p my-app -t feedback "don't run migrations without a backup"
git log -5 | brain -p my-app -t worklog
brain sync --force # run the sync nowEvery capture, from the CLI, MCP or a hook, goes through one script (meta/capture.py). It replaces anything that looks like a credential (API keys, tokens, JWTs, private keys, password=..., passwords in URLs) with [REDACTED:<kind>] before writing, and skips a capture identical to one saved in the last 10 minutes.
Reviewing lessons:
brain lessons list # proposed lessons waiting for you
brain lessons show L073
brain lessons approve L073 L074 # make them live
brain lessons retire L012 --superseded-by L080
brain lessons list --active # what's live nowNew lessons from the sync are proposed and are never injected until you approve them. This is enforced in code, not left to the model: the sync snapshots the ledger before Claude runs, and afterwards brain lessons gate forces every newly added lesson to proposed and gives it a unique ID, whatever the model wrote. Once a day, the session-start hook mentions any that are waiting.
Inside the vault, Claude Code has three slash commands:
/ingest [path]: turn sources into wiki pages/query <question>: answer from the wiki, with citations/lint: find broken links, orphan pages and contradictions
In Obsidian, open the vault folder as a vault to browse it.
How it works
capture ─────────────┐
brain CLI │
brain_capture (MCP) ├──► raw/journal/*.md ──┐
PostCompact hook │ │
your repos (~/Dev) ──┴── git HEADs ──────────┤
▼
meta/sync.sh (4x a day; skips if nothing changed)
1 ingest new raw files → wiki/sources, entity pages
2 refresh pages for repos whose HEAD moved
3 update wiki/lessons.md from corrections and fix commits
4 lint
5 git commit (local)
│
meta/render-lessons.py ──┴──► lessons block in CLAUDE.md filesCheap when idle. Before calling Claude, the sync computes a fingerprint from the timestamps of your raw files and the current commit of every repo. If nothing has changed it exits straight away, at no cost. To run it on demand:
zsh ~/brain/meta/sync.sh --force.Vault layout:
raw/holds what came in and is never rewrittenwiki/holds what Claude wrote (sources/,projects/,concepts/,people/,index.md,lessons.md)meta/holds the engine, the logs andbrain.env(this machine's settings, not committed)
Search uses ripgrep over the markdown files. There is no vector database and nothing to re-index.
Lessons are blocks in
wiki/lessons.md(the schema is at the top of that file). A lesson is live when it isactive, not superseded, not graduated, and has been seen withinstale_days. Each live lesson reaches agents in one of two ways:Just in time. A lesson with a
match:field (for examplecmd:git\s+push.*--forceortool:^Edit$ && path:\.sql$) is injected by the PreToolUse hook right before a matching tool call, and only in repos it is scoped to. It isn't shown again in the same session for 40 tool calls.Always on. A lesson without a matcher goes into
CLAUDE.mdas one line. Lines are ranked by severity, then hits, then recency, and cut atinject_token_budget(2,000 tokens by default). Lessons over the budget stay searchable.
The
scopedecides where a lesson applies:Scope
Written into
universal<dev>/CLAUDE.md, which every repo inheritsproject:<slug><dev>/<slug>/CLAUDE.mdrepo:<path>that repo's
CLAUDE.mdstack:<name>repos you've mapped to that stack in
meta/lessons-routing.jsonBy default only
highlessons go intoCLAUDE.md, andhighandmedlessons can fire just in time. Lessons are only added toCLAUDE.mdfiles that already exist; the renderer never creates one.
Hooks
Hook | What it does | Cost |
| Finds this repo's | One page per new session |
| Injects the matching lessons before a tool call, at most 2 per call. Silent when nothing matches, and silent on any error. | About 40 ms per tool call; usually zero tokens |
| Saves a digest of the session as a worklog in | None until the next sync |
Configuration
File | Purpose |
| Brain name, |
|
|
| Optional |
| The rules Claude follows when maintaining the wiki. Edit it to change how pages are written. |
| Definitions of |
Security and privacy
To run unattended, the sync calls
claude -p --permission-mode bypassPermissions. It can read every repo under--devand acts on anything that lands inraw/, so only point it at code and notes you trust.The vault is a local git repo. Don't add a public remote: the brain fills up with private details of your work.
Captures are redacted before they're written, but the patterns only catch credential-shaped strings. Don't paste secrets in on purpose.
The PreToolUse hook only adds context. It never blocks or changes a tool call.
Several brains on one machine
Give each brain its own --name and --cli-name. Each gets its own MCP server, scheduled job, hooks and marked block in CLAUDE.md, so they don't overwrite each other. (The plugin always serves the brain named brain, or the one in $BRAIN_VAULT.)
npx create-second-brain --vault ~/work-brain --name work-brain --cli-name wbUninstall
claude mcp remove -s user brain
launchctl bootout gui/$(id -u)/com.brainkit.brain.sync # macOS
rm ~/Library/LaunchAgents/com.brainkit.brain.sync.plist # macOS
crontab -l | grep -v '# brainkit:brain$' | crontab - # Linux
rm ~/.local/bin/brainThen remove the three hook entries that point into <vault>/meta/ (PostCompact, PreToolUse, SessionStart) from ~/.claude/settings.json, or run claude plugin uninstall brain-kit@brain-kit if you installed the plugin. Delete the BRAIN-USAGE:brain and BRAIN-LESSONS:brain blocks from your CLAUDE.md files. The vault is ordinary markdown in git: keep it or delete it.
Credits
Ideas taken from other projects:
lessons-learned: lessons that fire right before the tool call they guard
claude-reflect and obsidian-second-brain: a human approves rules before they go live
agentmemory: a token budget on injection, redacting secrets, dropping duplicate captures, retiring stale memories
claude-memory-compiler: loading context automatically at session start
Andrej Karpathy's LLM-wiki pattern: the
raw/→wiki/layout
License
MIT
This server cannot be deployed
Maintenance
Related MCP Connectors
Persistent memory for Claude Code and Cursor. Stop re-explaining your project every session.
Personal context for every AI: search, read, and write back to your private Markdown library.
- SeturosOAuthcom.seturos
Shared work memory for Claude Code, Codex, Cursor and chat, scoped to each repository.
Persistent context for Claude. Your AI always knows your projects and next actions across sessions.
Related MCP Servers
- AlicenseNot gradedqualityCmaintenanceGives Claude Code long-term memory that persists across sessions via hybrid BM25 and vector semantic search, with multi-project isolation.9 npm8MIT
- AlicenseNot gradedqualityBmaintenanceEnables saving bookmarks, notes, and files from inside Claude Code or Codex and later finding them from any project or session just by describing what you remember. All storage, indexing, and natural-language search run locally via SQLite and a bundled embedding model, with no accounts, cloud, or API keys.6 npmMIT
- AlicenseNot gradedqualityAmaintenanceEnables Claude to read and search a local Markdown knowledge base and past session transcripts, and write distilled notes back into it over MCP.35 npm1MIT
- AlicenseAqualityBmaintenanceEnables a shared, searchable knowledge base of project notes and status, accessible from Claude Code, Teams, CLI, and GitHub, with gated writes.4MIT