Docs · install

The binary, the brain
and the hour after.

Four steps. Everybody skips one of them: checking the hooks really work. If the brain depends on the agent remembering to read it, one day it won't. The hook is what makes sure it does.

1 · Get the binary #

os-brain is built from source. You need Go 1.26.4 or newer and nothing else: no cgo and no C compiler.

$ git clone https://github.com/chka/os-brain
$ cd os-brain
$ go build -o ~/.local/bin/os-brain ./cmd/os-brain
$ os-brain version
os-brain 26110501 (schema v16)

Or in one line, which puts the binary in $(go env GOPATH)/bin (usually ~/go/bin):

$ go install github.com/chka/os-brain/cmd/os-brain@latest

The only dependencies are the Go standard library, a pure Go SQLite driver and golang.org/x/text. The result is one file, fully static when built with CGO_ENABLED=0 (the default where no C compiler is installed). It cross-compiles like any Go program, so GOOS=darwin GOARCH=arm64 go build ./cmd/os-brain on a Linux box gives you a Mac binary.

Put the binary on the PATH your agent's hooks run with. That is often not the same PATH as your interactive shell. A hook that cannot find os-brain fails without telling anyone and the session starts with no brief.

There are no release downloads yet and no installer script. Read the source first if you like: it is all in the repository.

2 · Create the brain #

$ cd ~/projects/yours
$ os-brain init
To autowire your agent you need to tell us what agent you want to use:
   1) Claude Code
   2) Codex CLI
   ...
  11) Kilo
  12) I will do it myself
Choose 1-12:

At a terminal, init asks which agent to connect. I will do it myself sets up nothing and prints each agent's config for you to add by hand. Pass --agent claude (or codex, cursor and so on) to skip the question. With no terminal, as when an agent runs it, init doesn't ask: it sets up the agent you named, or the ones it finds.

It tells you everything it creates. On a project with Claude Code it prints:

brain ready at ~/projects/yours/brain/brain.db
  + brain.json for 'yours'
  + brain.db at schema v16
  + .gitignore entry for brain/brain.db*
  + HOWTO.md
  + BEST-PRACTICES.md
  + SessionStart hook -> OS_BRAIN_HOME="$CLAUDE_PROJECT_DIR/brain" os-brain wakeup
  + Stop hook -> OS_BRAIN_HOME="$CLAUDE_PROJECT_DIR/brain" os-brain hook-stop
  + PostToolUse hook -> OS_BRAIN_HOME="$CLAUDE_PROJECT_DIR/brain" os-brain hook-tool
  + SessionEnd hook -> OS_BRAIN_HOME="$CLAUDE_PROJECT_DIR/brain" os-brain hook-end
  + UserPromptSubmit hook -> OS_BRAIN_HOME="$CLAUDE_PROJECT_DIR/brain" os-brain hook-recall
  + .claude/commands/who.md
  ...
WhatWhy it is there
brain/brain.jsonThe project's name, its scopes and the project notes added to every brief.
brain/brain.dbThe memories themselves. A versioned SQLite database in WAL mode, readable only by you (mode 600).
.gitignoreLines for the database, its dumps and snapshots. Memories don't belong in the repository.
brain/HOWTO.md
brain/BEST-PRACTICES.md
Copied out of the binary, so your agent already knows how to use the brain and what is worth saving. They go in brain/, not the repository root.
brain/autoexec.shA small script that finds this brain from where the script itself lives, so a hook works whatever directory the agent runs it from. It is for agents that don't tell their hooks which project they are in.
agent hooksIn the config of the agent you picked or it found. The table below lists them.
.claude/commands/Claude Code only: seven slash commands for messaging other sessions on the same machine (/who, /msg, /inbox and the rest).

init does not edit CLAUDE.md or any other instructions file. A line in a markdown file is a request the agent may ignore, while a hook runs every time. brain.json, the two docs and autoexec.sh hold no memories, so they are safe to commit. init rewrites the two docs whenever they differ from the ones in the binary, so don't edit them.

Useful flags: --dir marketing/brain puts the brain somewhere other than brain/. --project "Acme Sales" names it when the folder name is wrong. --agent claude,codex sets up those agents instead of looking for them. --no-hook, --no-auto-recall and --no-gitignore each skip one piece. --channel registers the direct-message channel in .mcp.json.

You can run init again at any time. It upgrades the database in place and replaces its hooks instead of adding new ones next to them, so you end up with exactly one per event. It never overwrites brain.db, which is the only copy of that project's memory.

3 · Check the hooks really work #

This is the step people skip. It is also the one that decides whether any of this works.

$ os-brain wakeup

That prints exactly what a session gets when it opens: the brief, the working tree read from git and this project's own checks. If you see them, the command works. Then open a new session and look for the brief before you type anything. wakeup shows the command works. A new session shows the hooks do.

If init could not set up any hook, it says so:

NOT WIRED nothing will load this brain until a human adds one of these.
This command cannot write these files for you, so it has not pretended to:

Then it prints the exact file and the exact config to add for every agent, installs the brain anyway and exits with status 1. It does not fall back to writing instructions into some file instead, because that would look like it worked when it didn't.

If init reports another memory store

You will see ANOTHER MEMORY STORE IS ALREADY LOADED FOR THIS PROJECT, naming a MEMORY.md, a memory/ directory or Claude Code's own auto-memory for this project.

Two memory stores that both load on their own will contradict each other without telling you. Every session reads both. Nothing says which is newer, so the session believes whichever it read, even a fact the other one corrected months ago. You find out from a wrong answer on some ordinary day and nobody traces it back to this.

Do not delete the old store. Copy what is still true into the brain with os-brain remember, then let the user delete it. It is theirs and only they know which parts are still true.

4 · Fill it, if the project has history #

Install a brain into a six-month-old project and it starts empty, while the history sits on disk as session transcripts.

$ os-brain bootstrap

This writes nothing to the brain. It finds this project's Claude Code session transcripts, lists them oldest first (12 at a time, -n changes it) and prints the rules for pulling facts out of them. Your agent does the reading and decides what to keep. With no transcripts it says so and tells you to start storing as you work.

There is no automatic extractor. Pattern matching over transcripts fills a new brain with confident noise, which is worse than an empty one.

Finish with os-brain bootstrap --done. It records that the job is finished so no later session does it again. --again goes through the transcripts once more.

Your first memories #

$ os-brain remember --type infra \
    --title "TLS terminates at nginx on 8443, not at the app" \
    --body "the app listens on 127.0.0.1:8080 and never sees a cert" \
    --source "nginx/sites-enabled/app.conf"
remembered #4 [global/infra] TLS terminates at nginx on 8443, not at the app
  review on 2026-12-20 (default for infra, 30d ...)

$ os-brain prefer "run the tests before every commit, without asking" --why "said so twice"
remembered #3 [global/preference] run the tests before every commit, without asking

$ os-brain log "deployed 1.4 to staging" --kind deploy
logged event #3 [deploy] deployed 1.4 to staging

$ os-brain recall "TLS nginx"

Facts about the world (infra and access) ask to be re-checked after 30 days, because a host can move without any commit saying so. --review <date> moves the date and --no-review drops it.

Your next session opens knowing all of that, plus the time of day, the branch and any rule you have saved. Read the memory model before you save much: the type you pick matters more than anything else you choose.

Which agents get set up #

When it doesn't ask, init looks for .claude/, .codex/, .cursor/, .gemini/, .opencode/, .kilo/, .copilot/, .qwen/, .hermes/, .continue/ and .devin/ in the project and under $HOME (OpenCode, Kilo and Devin CLI also under ~/.config/). Each agent keeps its config in its own file and handles hook output its own way, so init has to find each one rather than write one shared config. For Claude Code it writes these into .claude/settings.json. Other agents get whichever of these their hooks support, listed on the agents page.

EventCommandWhat it does
SessionStartos-brain wakeupThe brief, the current git state and this project's checks, before you type.
UserPromptSubmitos-brain hook-recallSaves what you typed, then searches the brain for it and adds what it finds. What it stores.
PostToolUseos-brain hook-toolDelivers a direct message from another session on this machine at its next tool call.
Stopos-brain hook-stopWhat this session did and whether it stored any of it.
SessionEndos-brain hook-endMarks the session gone, so nobody sends it a message.

What the prompt hook stores

The hook that runs on every message keeps a word-for-word copy of each prompt you type, before your agent answers it. That way a memory can later point back at the message it came from.

It all stays in the local database. init tells you this in one line when it sets up the hook.

An agent that can't run shell commands has no hooks and cannot type os-brain commands. That is what MCP is for: over stdio when the client can start the server itself, over HTTP when it cannot.

Where things live

Each project keeps its memories in its own brain/brain.db. A thin shared store at ~/.claude/os-brain/brain.db holds what crosses projects: axioms, house standards, the project index, notes between projects and lessons a project chose to publish. Sharing covers it. These variables move things for one run or one shell:

VariableWhat it changes
OS_BRAIN_HOMEThe brain directory, instead of searching upward from the current one. The Claude Code hooks set it.
OS_BRAIN_PROJECTThe project name, instead of the one in brain.json.
OS_BRAIN_DBThe database file.
OS_BRAIN_GLOBAL_DBThe shared store.
CLAUDE_CONFIG_DIRWhere Claude Code keeps its files (~/.claude by default). The shared store sits under it.

Windows

os-brain builds for Windows with GOOS=windows go build ./cmd/os-brain. Setting up hooks there is not covered. The hooks init writes expect a Unix shell: Claude Code's set OS_BRAIN_HOME in shell syntax and the other agents' call brain/autoexec.sh, a shell script. We haven't tested either on Windows, so expect to set them up by hand.

Upgrading #

There is no upgrade command and no update check. To move to a newer version, build it again:

$ cd os-brain && git pull && go build -o ~/.local/bin/os-brain ./cmd/os-brain

Then, in each project:

$ os-brain backup    # first: the database is the only copy
$ os-brain init      # refreshes the docs and hooks, keeps brain.db and brain.json
$ os-brain doctor    # check the store on this project's own data

A newer binary migrates the database schema when it first opens it. Each migration runs as one transaction and is undone completely on any error, because a half-finished migration would fail on every later command. An older binary opens a database written by a newer one only when the database says that is safe (most steps only add a column or a table) and refuses it when the meaning of stored rows has changed. After an upgrade, check on the project's own data: doctor finds nothing, the counts in stats haven't changed and a recall whose answer you already know still gives it.

Uninstalling #

$ os-brain uninstall                  # dry run: every file and line it would touch
$ os-brain uninstall --apply          # hooks and files go, brain.db STAYS
$ os-brain uninstall --apply --purge  # also deletes the memory

The dry run lists every file, hook and .gitignore line it would remove, then says Nothing has been changed. Add --apply to do it. With --apply it writes a dump first, with or without --purge. Without --purge your memories stay, so one os-brain init puts everything else back. The one exception is brain/brain.json, which is deleted: copy it first if you set scopes or project notes in it.

It removes only the hooks init wrote for this brain, so your own hooks and other tools' hooks stay. Removal is a command because an agent that did it by hand once deleted a project's whole .claude/settings.json.

If you are the agent doing this #

Four rules. They change what you do, not what you read.