A persistent knowledge layer for Claude Code. Brain mode gives Claude memory across sessions — it loads your past context at startup, captures what you learn as you work, and surfaces relevant knowledge when you need it.
Run brain for the launcher dashboard — pick a project and it opens in a new window with a brain-mode session ready:
Pick one and it opens in a fresh window, cd'd into the project with memory already loading:
Memory loads before you type — projects, pitfalls, and patterns are already in context:
Hit an error you've seen before, and the fix comes back with it:
Destructive commands and secret leaks are blocked before they run:
When the session ends, useful knowledge is written to the vault for you — no command to run:
A two-row statusline keeps brain state, git, context, and session metrics in view:
These are illustrative mockups with placeholder data — your real sessions use your own projects and vault.
Without brain mode, every Claude Code session starts from zero. With it:
- Session start: Hooks automatically load your vault context — projects, pitfalls, patterns — into Claude's context window
- While you work: Error pattern recognition surfaces past solutions. Safety hooks block dangerous commands and secret leaks before they happen. Session guardian monitors context usage and research focus.
- When you pause: An idle detection hook gently offers to capture useful patterns
- Session end: A smart stop hook evaluates whether the session produced something worth capturing
- Statusline: Two-row branded display with brain state, git info, context bar, lines changed, and session duration
Everything runs through Claude Code's hook system. You just work normally.
- Node.js (for Claude Code)
- Git
- jq (JSON processing)
- Claude Code (
npm install -g @anthropic-ai/claude-code)
The toolkit is built on bash and POSIX tooling (sed, grep, awk, mktemp, /tmp, symlinks, chmod).
| Platform | Status | Notes |
|---|---|---|
| Linux | ✅ Supported | |
| macOS | ✅ Supported | |
| Windows (WSL) | ✅ Supported | Use WSL. Keep the repo and your vault on the Linux filesystem (~/), not /mnt/c/..., for speed. |
| Windows (native) | ❌ Not supported | PowerShell/cmd lack bash; Git Bash / MSYS / Cygwin only partially work (missing GNU tools, unreliable symlinks). |
Windows users: install WSL and run the toolkit from inside it.
setup.shruns a platform preflight — on a native Windows shell it warns, links to the WSL docs, and prompts before continuing rather than failing halfway through.
git clone https://github.com/bizzar0helldemon/claude-brain-toolkit.git
cd claude-brain-toolkit
bash onboarding-kit/setup.shThe setup script:
- Deploys the
brain-modeagent to~/.claude/agents/ - Installs all global skills (23 skills)
- Deploys all hook scripts to
~/.claude/hooks/(10 hooks + 2 libraries) - Registers hooks in
~/.claude/settings.json(idempotent — safe to re-run) - Deploys slash commands and the statusline script
- Verifies everything is in place
claude --agent brain-modeOn first run, BRAIN_PATH won't be set yet. Claude will detect this and offer to run /brain-setup, which walks you through:
- Choosing a vault directory
- Creating the directory structure
- Setting
BRAIN_PATHin your shell profile andsettings.json
After setup, restart Claude Code and brain mode is active.
Brain mode uses hooks across 6 event types:
| Hook | Event | What It Does |
|---|---|---|
session-start.sh |
SessionStart | Loads vault context into Claude's context window. Caches for fast /clear reloads. |
pre-compact.sh |
PreCompact | Triggers capture before context window compaction. |
post-tool-use.sh |
PostToolUse | Detects real git commits and appends a silent record to brain-mode/commit-log.jsonl. |
session-guardian.sh |
PostToolUse | Monitors context % (warns at 70%/85%) and detects runaway research loops (5+ reads without writes). |
post-tool-use-failure.sh |
PostToolUseFailure | Matches errors against stored patterns and surfaces past solutions with adaptive tier responses. |
risk-classifier.sh |
PreToolUse | Blocks dangerous bash commands (git reset --hard, rm -rf /, chmod 777, etc.). |
pre-commit-secrets.sh |
PreToolUse | Scans staged diffs for API keys, tokens, and private keys before allowing commits. |
loop-detector.sh |
PreToolUse | Catches agents repeating identical tool calls 5+ times and breaks the loop. |
notification-idle.sh |
Notification (idle) | Offers to capture when the session has content and the user pauses. One offer per session. |
stop.sh |
Stop | Writes a mechanical session receipt to brain-mode/session-log.jsonl, ingests new GSD .planning/ artifacts into inbox/captures/, and issues one silent distillation prompt when the session had capturable content. |
Capture is mechanical, not advisory: stop.sh and post-tool-use.sh write to the vault themselves rather than asking you to run /brain-capture. The Stop hook is deployed and registered by default.
Capture alone just accumulates. The gardener closes the loop so notes earn or lose their place in the session-start budget based on whether they actually get used:
-
Surface —
session-start.shlogs every injected note tobrain-mode/surface-log.jsonl. -
Observe —
post-tool-use.shlogs ausedevent tobrain-mode/retrieval-log.jsonlwhenever a vault note is Read. -
Adjust —
tools/brain-gardener.py(lazy weekly trigger fromsession-start.sh, at most once per 7 days) folds those events into each note's frontmatter counters and applies status transitions:warm --(used ≥2×)--> hot hot --(surfaced ≥8× with 0 uses, or 30d cold)--> warm warm --(90d idle, never used)--> archive # skipped at session start, still searchable archive --(180d further idle)--> tombstone # body kept on disk forever any archived/tombstoned --(any use)--> resurrectedExempt from decay (
decays: false):preference,identity,synthesis. A cold-start epoch (brain-mode/.brain-gardener-epoch) measures idle time from when the loop began observing, so legacy notes are never archived before they've had a chance to surface. Every pass writes a dateddaily_notes/<date>-memory-health.mdreport and abrain-mode/metrics.jsonlline, and commits the vault. Run it by hand anytime withpython3 tools/brain-gardener.py(dry run) or--apply.
Three hooks run before every tool call to prevent common mistakes:
Risk Classifier — hard-blocks destructive commands:
git reset --hard,git clean -f, force push to main/masterrm -rfon broad paths,chmod 777DROP TABLE,TRUNCATE,DELETE FROMwithout WHERE- Advisory warnings for
--no-verify,git checkout .
Pre-Commit Secrets — blocks commits containing:
- API keys (AWS, GitHub, Anthropic, OpenAI, Stripe, Google, Slack)
- Private keys (RSA, SSH, PGP), JWT tokens
- Database connection strings with embedded passwords,
.envfiles
Loop Detector — tracks tool calls in a rolling window and blocks after 5+ identical calls with a diagnostic message.
Session Guardian monitors two risks that cause partial achievement:
- Context exhaustion: Warns at 70% usage, urgently prompts handoff at 85%
- Runaway research: Flags 5+ consecutive read operations without writes
Run /session-guardian anytime for a status check.
When a command fails, the PostToolUseFailure hook checks your pattern store for matches. Responses adapt:
| Encounters | Response |
|---|---|
| 1st time | Full explanation with solution steps |
| 2-4 times | Brief reminder |
| 5+ times | Root cause investigation flag |
Two-row branded display with 256-color support:
🧠 Brain │ 📂 my-repo 🌿 main │ 🤖 Opus 4
🟢 captured │ ▓▓▓▓▓▓░░░░ 62% │ +47 -12 │ 📝 3 │ ⏱ 14m
Row 1: Brain branding, repo + branch (with worktree detection), model name Row 2: Brain state, context bar (color-coded), lines changed, dirty files, session duration
| Command | What It Does |
|---|---|
/brain-onboard |
Guided first-time walkthrough — identity → discover content → process inbox → catalog projects (--quick for identity only) |
/brain-intake |
Guided conversational interview — teach the brain who you are; populates IDENTITY.md |
/brain-discover [path] |
Scan a drive for existing writing/scripts/lyrics/audio not yet in the brain |
/brain-inbox |
Process loose files dropped into the vault and route them to their homes |
/brain-scan [path] |
Catalog a project directory into projects/ + index |
/brain-update [name] |
Refresh an existing project's brain entry after more work |
| Command | What It Does |
|---|---|
/brain-capture |
Extract patterns, prompts, and lessons from the current conversation |
/brain-graduate |
Promote learnings with reliability scoring (high/medium/experimental); --auto mode passively extracts learnings from completed work |
/daily-note |
Log a journal entry to daily_notes/ |
| Command | What It Does |
|---|---|
/pre-pr-scan |
Multi-agent quality gate — CI compliance, security, logic bugs, commit hygiene |
/brain-audit |
Vault health check — stale entries, missing indexes, broken links |
/brain-investigate |
Structured debugging with 3-level diagnostic (EXISTS → SUBSTANTIVE → WIRED) |
| Command | What It Does |
|---|---|
/session-guardian |
Check session health — context usage, read/write ratio, risk assessment |
/daily-sync |
Fast operational snapshot — vault health, git state, drift detection, priorities |
/brain-handoff |
Session continuity document — accomplished, in-progress, blockers, decisions |
/brain-evolve |
Self-improvement cycle — 3 auditor agents, 5-axis scoring, inline proposal review |
| Command | What It Does |
|---|---|
/brain-ship |
Ship completed work — push branch, create PR, update Linear, log to vault |
/brain-ticket |
Create work tickets in Linear from backlog |
/brain-linear-sync |
Sync Linear tickets with brain vault |
/brain-add-pattern |
Add an error pattern and solution to the pattern store |
/brain-setup |
First-time onboarding wizard |
/brain-relocate |
Move your vault to a new path |
| Command | What It Does |
|---|---|
/brain-game |
Game night — AI Fluency games (riddles, crosswords, RPG) and resumable quest campaigns |
Your vault lives at $BRAIN_PATH — wherever you choose during setup:
$BRAIN_PATH/
learnings/ # Graduated knowledge with reliability scores
prompts/ # Prompt and pattern library
projects/ # Project summaries by category
investigations/ # Structured debugging investigations
handoffs/ # Session continuity documents
daily_notes/ # Daily journal entries
evolution/ # Self-improvement proposals and synthesis
proposals/ # EVO-*.md scored proposals
synthesis/ # SYNTH-*.md cycle summaries
brain-mode/
pattern-store.json # Error patterns and solutions
.brain-state # Current hook state (idle/captured/error)
.brain-session-metrics.json # Session guardian tracking
.brain-cached-context.json # Cached context for fast /clear
.brain-errors.log # Hook error log
The vault is Obsidian-compatible but doesn't require Obsidian.
Brain mode needs one environment variable:
export BRAIN_PATH="/path/to/your/vault"This is set in two places (both are needed):
- Shell profile (
~/.bashrc,~/.zshrc, or~/.bash_profile) — for interactive terminal use ~/.claude/settings.jsonunder"env"— for hook subprocesses (which don't load shell profiles)
The /brain-setup wizard handles both.
claude-brain-toolkit/
agents/
brain-mode.md # Agent definition
hooks/
session-start.sh # SessionStart — vault context loading
pre-compact.sh # PreCompact — capture suggestion
post-tool-use.sh # PostToolUse — git commit detection
post-tool-use-failure.sh # PostToolUseFailure — error patterns
notification-idle.sh # Notification — idle capture offer
session-guardian.sh # PostToolUse — context & focus monitoring
risk-classifier.sh # PreToolUse — dangerous command blocking
pre-commit-secrets.sh # PreToolUse — secret leak prevention
loop-detector.sh # PreToolUse — repeated call detection
stop.sh # Stop — mechanical session capture + GSD ingestion (deployed globally)
lib/
brain-path.sh # Shared utilities
brain-context.sh # Vault context builder
global-skills/
brain-onboard/ # Guided first-time onboarding walkthrough
brain-intake/ # Identity interview -> IDENTITY.md
brain-discover/ # Drive scan for existing creative content
brain-inbox/ # Process & route loose vault files
brain-scan/ # Catalog a project into the brain
brain-update/ # Refresh an existing project entry
brain-capture/ # Pattern extraction
brain-graduate/ # Knowledge graduation (manual + --auto passive extraction)
brain-investigate/ # Structured debugging
brain-audit/ # Vault health check
brain-evolve/ # Self-improvement cycle
brain-handoff/ # Session continuity
brain-ship/ # PR shipping + Linear
brain-ticket/ # Linear ticket creation
brain-linear-sync/ # Linear sync
session-guardian/ # Context & focus protection
daily-sync/ # Operational snapshot
pre-pr-scan/ # Multi-agent quality gate
brain-game/ # Game night + quest campaigns
daily-note/ # Journal entries
commands/
brain-add-pattern.md # Error pattern management
brain-relocate.md # Vault relocation
onboarding-kit/
setup.sh # Automated installer
skills/ # Onboarding-only skills
settings.json # Template settings
statusline.sh # Two-row branded statusline
frameworks/ # AI Fluency Framework reference
If you're working on the toolkit itself:
- Clone the repo
- Create a
CLAUDE.local.md(gitignored) with your realBRAIN_PATH - Run
bash onboarding-kit/setup.shafter changes to deploy to~/.claude/
Changes to hook scripts in the repo don't take effect until deployed — the running hooks are the copies in ~/.claude/hooks/.
MIT. See LICENSE.
AI Fluency Framework content adapted from Dakan & Feller (CC BY-NC-ND 4.0). See frameworks/ai-fluency-framework.md for full attribution.