Exbrain

Exbrain

Exbrain — Your AI's External Brain. Claude Code × Obsidian × SOUL/MEMORY/DREAMS

Exbrain Banner

Exbrain 2.0 — A Self-Growing External AI Brain

An AI knowledge system that remembers, compiles, verifies, and evolves on its own.
Claude Code × Obsidian × a 4-layer architecture

🇯🇵 日本語 · Inspired by Karpathy's LLM Wiki

What is Exbrain?

There's exactly one reason the most powerful AI model still gives you mediocre output: it knows nothing about you.

Exbrain builds an "external brain" that Claude Code reads from and writes to, on top of Obsidian (which is really just a folder of Markdown files). Your days, clients, decisions, and lessons accumulate and get compiled automatically, so that every session starts already knowing where you are right now.

  • Your memory lives on your own disk, as plain text. No vendor lock-in.
  • It keeps working with your laptop closed (via cloud-side scheduled tasks), and you can read it on your iPhone (via iCloud sync).
  • Whatever model you swap in next, the brain survives.

What Changed in v2

The single biggest lesson from three months of running v1 (SOUL/MEMORY/DREAMS + clips):

"Raw logs pile up on their own, but compiled knowledge rots on its own."

Daily notes and clips (the raw layer) grew fatter every day through automation, while client pages and indexes (the wiki layer) went stale within weeks. v2 fixes this with a nightly compiler.

v1v2
StructureSOUL/MEMORY/DREAMS + a set of folders4-layer model (raw → wiki → digest → identity)
Front doorNone (just CLAUDE.md)INDEX.md (map + freshness dashboard)
Raw → knowledge compilationManual (stalls quickly)Nightly compile runs every night (cheap model)
Quality controlweekly-sync.sh (never actually ran)Weekly lint (registered with launchd, no LLM)
ResearchVanishes into chatresearch/ (verified, sourced, with an expiry date)
CitationsOptionalA source link is required for every claim (the receipts principle)

The 4-Layer Architecture

┌─ identity ────────────────────────────────────────────┐
│  SOUL.md / VOICE.md / RED-LINES.md                    │
│  Values, voice, lines you won't cross — humans only    │
└───────────────────────────────────────────────────────┘
┌─ digest ──────────────────────────────────────────────┐
│  MEMORY.md (recent context) / DREAMS.md (pattern insight)│
│  Written only by the cloud cognition pipeline (AM/PM + weekly)│
└───────────────────────────────────────────────────────┘
                        ▲ synthesize
┌─ wiki (compiled knowledge)────────────────────────────┐
│  entities/ clients/ insights/ research/ decisions/    │
│  One page per entity / lesson. Source link on every claim│
│  ★ The nightly compile updates this every night        │
└───────────────────────────────────────────────────────┘
                        ▲ compile
┌─ raw (raw logs, inviolable)───────────────────────────┐
│  daily/ (daily logs) clips/ (bookmarks) raw/ (dumps)  │
│  Append-only. No rewrites = ground truth              │
└───────────────────────────────────────────────────────┘

Why raw is inviolable: when the same agent keeps reading and rewriting the same notes, details dissolve and errors compound. Freeze the raw logs and you can rebuild the wiki layer as many times as you like.

Separation of ownership is the key: the cloud writes raw + digest, the local nightly compile writes the wiki, and humans write identity. Because each layer has exactly one author, sync conflicts can't arise by construction.

The Automatic Loops — How the Brain Stays Alive

A brain you only feed when you remember to is dead within three weeks. So everything goes on a schedule:

LoopWhenWhatCost
Session primerStart of every sessionInject today's schedule, recent events, and open loops into contextZero (just reading)
Session recordEnd of every sessionGuarantee the daily-note scaffold + git syncZero
The morning/evening eye07:00 / 18:30Calendar/Slack/Gmail → generate and update the daily noteCloud
ClipsEvery 4 hoursX bookmarks → summarize and save to clips/Cheap
Nightly compile23:30Read raw, compile entities/decisions/open-loops/INDEXCheap model (haiku)
Weekly lintSunday 09:00Detect broken links, duplicates, staleness, expired researchZero (shell only)
Weekly DreamingSunday 21:30Synthesize patterns across the vault → DREAMS.mdPremium model (once a week)

💰 Cost by design: the premium model shows up only for the weekly synthesis. Compilation is routine work, so it goes to a cheap model. "Routine work, routine tier."

Nightly compile (brain-compile.sh) — the heart of v2

23:30 launchd fires
  │
  ├─ 1. Detect uncompiled days (catches up to 3 days behind)
  ├─ 2. Launch claude -p headless (haiku; Read/Write/Edit/Glob/Grep only)
  │     "Read daily/{date}.md and the new clips,
  │      then update the pages for the clients, people, and tools
  │      that appeared. Attach a source [[daily/{date}]] to every
  │      addition. Do not touch raw or digest."
  ├─ 3. Safety valve: auto-restore any changes to the raw/digest/identity layers
  ├─ 4. git commit "compile: {date}"
  └─ 5. push

Never let the LLM touch git (the script owns it), restrict what it can write by layer, and keep changes minimal — runaway prevention is guaranteed by the mechanism, not by trust.

Weekly lint (brain-lint.sh) — rot detection

An unmaintained wiki always rots. Sunday morning, a deterministic check with no LLM finds it:

  • Broken wikilinks (wiki layer only)
  • iCloud conflict copies (filename 2.md) and byte-identical duplicates
  • Staleness (entities that appear in recent dailies but haven't been updated in 30+ days)
  • Expired research (past its expires: date)
  • Missing dailies and near-empty notes (detects when automation has stopped)

Results go to system/lint-report.md. Anything critical fires an OS notification.

INDEX.md — the Front Door and Paying for Context

The context window is "an expensive room where you're billed for everything you bring in." So:

  • Keep CLAUDE.md under 200 lines and have it merely point at the vault (it's the always-billed zone, loaded every session)
  • To look something up, go INDEX.md → follow the links. Never do a full-folder scan.
  • For big questions, have a subagent read and hand back only the conclusion (decisions go in the expensive room; the library stays outside)

INDEX.md carries a map of every section plus a freshness dashboard (updated nightly by compile). You can see at a glance which layer was updated when, which makes rot visible.

research/ — Don't Mix Rumor with Verified

Turn research that would vanish into chat into an asset. The research skill's flow:

question → decompose into 3–5 sub-questions
        → parallel agents investigate different facets (web / official / practitioners' voices)
        → turn every finding into a receipt (claim + source URL + date)
        → ★ a skeptic agent attacks every claim
           ├─ single source → demote to "single-source"
           ├─ contradiction → present both sides or reject
           └─ source can't be traced → reject
        → only the survivors are saved to research/YYYY-MM-DD_topic.md
           (with expires: in the frontmatter; lint detects expiry)

Verification is kept separate because a checker on fresh context is stronger than a model reviewing its own work.

Vault Structure

~/vault/
├── INDEX.md        ← Front door (map + freshness) ★ always start here
├── CLAUDE.md       ← The schema of record (under 200 lines; stays a pointer)
├── SOUL.md / VOICE.md / RED-LINES.md   ← identity layer
├── MEMORY.md / DREAMS.md               ← digest layer
├── open-loops.md   ← Open loops (updated by compile)
│
├── daily/          ← raw: daily logs (auto-generated AM/PM)
├── clips/          ← raw: X & article clips (x/ articles/)
├── raw/            ← raw: catch-all for manual dumps (transcripts, etc.)
│
├── entities/       ← wiki: people people/ tools tools/ orgs orgs/
├── clients/        ← wiki: one page per client
├── insights/       ← wiki: lessons & patterns (one lesson per file)
├── research/       ← wiki: verified research (with expires)
├── decisions/      ← wiki: decision log (monthly)
│
├── memory/ system/ skills/ ← Claude Code internal mirror (SYNCED)
├── templates/      ← entity / concept / research / daily-note / decision
└── scripts/        ← hooks · compile · lint · sync

Setup

Prerequisites

  • Claude Code (Pro or Max) / Obsidian (free) / a GitHub account
  • (Optional) Slack, Google Calendar, and Gmail Connectors; an always-on agent

Step 1: Create the vault + expand the templates

git clone https://github.com/chaenmasahiro0425/exbrain.git /tmp/exbrain
mkdir -p ~/vault && cp -r /tmp/exbrain/vault-template/* /tmp/exbrain/vault-template/.gitignore ~/vault/

# iCloud sync (if you want iPhone support)
mv ~/vault ~/Library/Mobile\ Documents/iCloud~md~obsidian/Documents/exbrain
ln -s ~/Library/Mobile\ Documents/iCloud~md~obsidian/Documents/exbrain ~/vault

Step 2: Write the identity layer (this part alone is a human job)

  • SOUL.md — who you are, and how you want the AI to behave
  • VOICE.md — your voice per channel
  • RED-LINES.md — the lines you won't cross no matter what you're told

Step 3: Configure hooks

~/.claude/settings.json:

{
  "hooks": {
    "SessionStart": [{ "hooks": [
      { "type": "command", "command": "bash ~/vault/scripts/on-session-start.sh" }
    ]}],
    "Stop": [{ "hooks": [
      { "type": "command", "command": "bash ~/vault/scripts/on-session-end.sh", "async": true }
    ]}],
    "PostToolUse": [{ "matcher": "Write|Edit", "hooks": [
      { "type": "command", "command": "bash ~/vault/scripts/on-file-change.sh", "async": true }
    ]}]
  }
}

Step 4: Backfill — get everything you have into the brain

Dump your past chat logs, meeting notes, and memos into raw/, then tell Claude Code:

Following the rules in ~/vault/CLAUDE.md, read every file in raw/
and compile entities/, clients/, and insights/. Attach a source link to every claim.

If there are dozens of files, knock it out in one shot with parallel subagents (or a Workflow).

Step 5: Start the loops

# Register with launchd (after replacing the placeholder with your own username)
cp /tmp/exbrain/launchd/com.YOURNAME.brain-*.plist ~/Library/LaunchAgents/
launchctl bootstrap gui/$(id -u) ~/Library/LaunchAgents/com.YOURNAME.brain-compile.plist
launchctl bootstrap gui/$(id -u) ~/Library/LaunchAgents/com.YOURNAME.brain-lint.plist
launchctl bootstrap gui/$(id -u) ~/Library/LaunchAgents/com.YOURNAME.brain-pull.plist

Register the morning/evening daily-note generation and the weekly Dreaming as Cloud Scheduled Tasks (claude.ai/code/scheduled), and the brain keeps running even with your PC closed.

Step 6: Back up to GitHub

cd ~/vault
git init && git add -A && git commit -m "Initial brain"
gh repo create my-vault --private --source=. --push

⚠️ A Sync Warning — This Is Where Vaults Die

Pick exactly one sync system. If iCloud syncs while an agent is mid-write, it mass-produces conflict copies of the form filename 2.md (a true story: 395 of them in v1's real-world use).

  • Make git the "save-point layer": nothing is final until you commit
  • If you use iCloud, the weekly lint detects the conflict copies (handled in v2)
  • The byte-identical duplicates it finds are safe to delete

Scripts Included

ScriptPurpose
brain-compile.sh★ The nightly compiler: raw → wiki compilation (23:30)
brain-lint.sh★ Weekly lint: rot detection (Sunday 09:00)
on-session-start.shSessionStart hook: pull → healthcheck → primer injection
session-primer.shInject the "state of the brain" into context at the start of a session
on-session-end.shStop hook: guarantee the daily scaffold + sync
on-file-change.shPostToolUse hook: record changes to the audit log
vault-sync.shTwo-way git sync (rebase; cloud wins on daily conflicts)
vault-healthcheck.shPer-session health check + dashboard
sync-x-bookmarks.shFetch X bookmarks (for the always-on agent)
sync-agent-to-vault.shEnrich daily notes with data from external agents
ios-clip-shortcut.mdOne-tap clipping from the iPhone share menu

All scripts are macOS-compatible (no GNU extensions). The LLM-execution parts run in headless mode with tightly scoped permissions.

Design Philosophy — References

  • Karpathy's LLM Wiki — the origin of "treat your knowledge base like a codebase"
  • Claude Code Hooks / Cloud Scheduled Tasks
  • The raw/wiki split, source receipts, skeptic verification, and expiry dates are an implementation of the second-brain patterns that the practitioner community converged on in 2026

License

MIT — LICENSE

Related

How to Install

  1. Download the ZIP or clone the repository
  2. Open the folder as a vault in Obsidian (File → Open Vault)
  3. Obsidian will prompt you to install required plugins

Stats

Stars

66

Forks

11

License

MIT

Last updated 9d ago

Categories