Step-by-step wiring of the brain into your Claude Code config.
git clone https://github.com/mustafa-bharmal-shipveho/brainstack.git
cd brainstack
./install.sh --minimal # brain + recall CLI only, no host edits--minimal creates ~/.agent/ with the 4-layer memory scaffolding, all
tools, and the recall CLI, and edits nothing under ~/.claude/. The full
install (./install.sh, which prints its plan and asks once) does register
auto-recall hooks in ~/.claude/settings.json; opt out with
--no-auto-recall. The rest of this page is the manual wiring path for
people who want to place each piece themselves.
If you've been using Claude Code's auto-memory at
~/.claude/projects/<slug>/memory/ and want to bring those entries
into the brain:
./install.sh --migrate ~/.claude/projects/<slug>/memoryThis does two things:
-
Migrates content losslessly into
~/.agent/memory/. Both flat layouts (feedback_*.md,user_*.md,project_*.md,cycle-*.md,reference_*.mdat root) and modern nested layouts (personal/profile/,personal/notes/,personal/references/,semantic/lessons/) are handled. Frontmatter is preserved on both the companion.mdand as structured columns onlessons.jsonl.MEMORY.mdhook annotations (— one-line description) survive the regenerated index. -
Replaces the source dir with a symlink to
~/.agent/memory. The original content is moved to<source>.bak.<unix-ts>first. After this, Claude Code's native auto-memory writes flow into the brain on every session. Re-running--migrateon an already-symlinked source is a no-op.
To skip step 2 (keep the source dir untouched), pass --no-symlink. Note
that without the symlink, native writes after migration will NOT reach the
brain — you'd be on your own to forward them.
If your source is already a symlink to somewhere other than the brain
(advanced setup, dotfiles repo, network mount), --migrate will refuse
rather than silently overwrite the link target.
Open ~/.claude/settings.json in your editor. Find the hooks.PostToolUse
array (create it if missing). Add this entry alongside any existing
hooks — do not replace them:
{
"hooks": {
"PostToolUse": [
// ...existing hooks (roux, crystl, custom...) — leave them...
{
"matcher": "Bash|Edit|MultiEdit|Write|Task|TodoWrite",
"hooks": [
{
"type": "command",
"command": "/opt/homebrew/bin/python3.13 /Users/yourname/.agent/harness/hooks/agentic_post_tool_global.py"
}
]
}
]
}
}Use absolute paths — do NOT use $HOME or ~ in the command. The
hook command is shell-evaluated by Claude Code; a hostile $HOME
environment variable (set by a sourced .envrc in some project) could
otherwise redirect the hook to attacker-controlled Python. The
installer prints the resolved absolute paths it recommends — paste
those literally.
Replace /opt/homebrew/bin/python3.13 with whatever Python 3.10+
interpreter you have. If you don't know:
which python3.13 python3.12 python3.11 python3.10Validate the JSON before saving:
python3 -m json.tool ~/.claude/settings.json > /dev/nullOpen any Claude Code session. Run a tool call (read a file, run a Bash command). Then check:
tail ~/.agent/memory/episodic/AGENT_LEARNINGS.jsonlYou should see one new JSONL row per matched tool call. If the file stays empty, the hook isn't firing — review the matcher pattern and the command path.
If you have an existing ~/.claude/commands/dream.md, replace it with
the review-staged-candidates flow:
cp <your-brainstack-clone>/templates/dream-command.md.template \
~/.claude/commands/dream.mdNow /dream walks tools/list_candidates.py output and prompts you to
graduate or reject each with required rationale.
See git-sync.md.
Drop a .agent-local-override file in any project root:
cd /path/to/project
touch .agent-local-overrideThe global hook will skip that project entirely. See
hook-precedence.md.
The framework's snippet adds one new entry to the PostToolUse
array. It does not touch any other hook category (Notification,
PreToolUse, Stop, etc.) and does not modify existing PostToolUse
entries. Other hooks fire independently:
"PostToolUse": [
{ "matcher": "*", "hooks": [{ "command": "bash ~/.claude/crystl-hook.sh PostToolUse", ... }] },
{ "matcher": "Bash|Edit|...", "hooks": [{ "command": "python3 ... agentic_post_tool_global.py", ... }] }
]Both run on every matching tool call.
Symptom: AGENT_LEARNINGS.jsonl stays empty after tool calls
Check Claude Code's hook log (varies by version; usually visible in verbose mode). Common causes:
- Wrong Python path in the hook command
~/.agent/doesn't exist (re-run./install.sh).agent-local-overrideexists in your project root unintentionally
Symptom: python3 ... agentic_post_tool_global.py errors with
unsupported operand type(s) for |: 'type' and 'NoneType'
You're using Python <3.10. The vendored hook code uses 3.10+ syntax.
Use python3.13 (or any 3.10+) in the command.
Symptom: dream cycle never runs
Check launchd:
launchctl list | grep agent-dream
launchctl print user/$(id -u)/com.user.agent-dreamIf the job isn't loaded, launchctl load ~/Library/LaunchAgents/com.user.agent-dream.plist.