Run these first #
$ os-brain env # the clock, the project, git and which file the brain is $ os-brain stats # counts and the database path on line two $ os-brain doctor # dangling links, loops, index drift, integrity $ os-brain version # the build and the schema it writes os-brain 26110501 (schema v16)
Together those four answer almost every "it is not doing what I expected": which file, which project, which build and whether the brain is in good shape.
$ os-brain stats memories=5 (pinned 0, superseded 1) [A2 B2 C1] scopes=1 events=6 leads=1 measures=4/1 keys (1 outside band) ... db=/home/you/.claude/os-brain/brain.db
The brief did not appear at session start #
First check the command works, then check the hook does. They break in different ways.
$ os-brain wakeup
- It prints the brief. The command is fine and the hook is not set up. Look in the agent's config (for Claude Code,
.claude/settings.json) for entries whose command containsos-brain, or runos-brain initagain. It replaces its own hooks instead of adding more and says "nothing to do" when everything is already in place. - It says no brain here. There is no
brain.jsonin this directory or any parent. Run it from inside the project, or setOS_BRAIN_HOMEto the brain directory. - Command not found. The binary is not on this shell's PATH.
go installputs it in$(go env GOPATH)/bin, which is often not on PATH. Your agent's PATH can also differ from your terminal's, so check both. - It prints but the session still shows nothing. Some agents load hooks only when a session starts. Open a brand new one.
initsaid NOT WIRED. It found no agent it could configure in this project and printed the exact snippet to add by hand instead of pretending.os-brain init --agent claude(orcodex,cursorand the others) wires one by name. The agents page lists them.
$ os-brain wakeup # outside any project no brain here: /home/you/scratch and its parents hold no brain.json. Run `os-brain init` in the project root to create one, or set OS_BRAIN_HOME to an existing brain directory.
An agent that cannot run shell commands has no hooks at all. The MCP page says what such an agent can still do.
Recall returns nothing #
A script that searches with recall --json and matches nothing gets nothing back, never the closest thing or everything in the scope. That is on purpose: a script once fed a recall miss into forget and destroyed real memories. Try these, in order:
- Read the first line. Plain recall (without
--json) already shows the highest-scoring memories in scope when no memory shares your words and says so:(no lexical match for '...'; showing the highest-scoring memories in scope).--strictturns that off.--browseturns it on for--json. - Use fewer, rarer words. A long question can match only loosely. Two or three words that would appear in the memory itself work best.
os-brain coverage --near "<topic>"comes at it from the other side: it shows what this project holds close to what you asked about.- Search a wider scope. A recall inside
deploy:prodnever seesdeploy:staging. A memory filed in a neighbouring branch is invisible from where you are. - Look elsewhere on purpose. In a shared store, try
--all-projects. For what other projects published, tryos-brain global --recall "<topic>". os-brain reindexif you cangeta memory by id but cannot find it by searching. The full-text index has fallen out of step andreindexrebuilds it from the memories table.
Wrong store, wrong project #
| Symptom | What it is |
|---|---|
| 0 memories in a brain you know has some | Right command, wrong file. os-brain stats prints the path. A project that moved into the shared store with share no longer reads its old brain/brain.db and the reverse is also true. |
no memory #N in this project for an id you can see | It belongs to another project in a shared store. Read it with get N --all-projects if that project is not private. Leave a note to change it. |
| Memories filed under another project's name | Something named the wrong project, usually over MCP. os-brain relabel <label> --expect <n> --apply moves them back. |
| A second directory refused for a project name | The name is bound to the directory that first used it, so a clone or a same-named checkout cannot read the first one's memories. Give the new one its own "project" in brain.json, or run os-brain relabel --claim at a terminal if you really moved it. |
| Phantom projects in the index | Something meant for a scratch directory ran against your real shared store. For anything throwaway, point CLAUDE_CONFIG_DIR and OS_BRAIN_GLOBAL_DB at scratch paths first. |
A project's brain.json points at a server or an encrypted brain | os-brain keeps memories only in local files, so it cannot read that project's memories. It refuses rather than answer from a local file that does not hold them. |
Refusals and what each one protects #
| Refusal | What it protects you from | How to get past it |
|---|---|---|
| "#42 in global is already about this" | Two answers to one question in one scope, which is worse than one answer that admits it does not know. | --supersedes 42, update 42 or --allow-duplicate |
| "already holds this title ... Storing this would destroy the existing body" | A careless save overwriting a fact. | --update (the old body goes to history) or --supersedes |
| "#2 has already been superseded by #4" | Two current versions of one fact. | --supersedes 4 to chain, or --fork-ok |
| "refusing 'confirmed'" | A session marking its own guess as fact. | --source, --ref or --source "stated by the user" |
| "refusing to store what looks like" a credential or API key | A token in a memory, which then sits in every backup, snapshot and export. | Store a pointer to where it lives instead. --allow-secret only for a false positive. The prompt hook, lead and object have no override. |
forget refuses a pinned memory or a guardrail | A session deleting a rule because it got in the way. | Re-read it, then --force, or supersede it |
forget refuses a memory that supersedes others | Deleting it would bring back the old facts it replaced on purpose. | Supersede it with a correct version, or --force to accept them coming back |
update refuses an empty body | Wiping a memory by accident. An empty --body is usually a shell substitution that failed. | --force |
prune refuses tier A or B | The tiers that never fade hold the facts that are hardest to work out again. | --i-mean-it, after reading the dump it took |
prune refuses a same-day cutoff | An --older-than 0 that means "everything written this session". | Pick a real cutoff of a day or more |
prune refuses a large deletion | More than 25 deletions, or more than half of what it can reach, in one go. | --yes, or a narrower --scope or --tier |
forget --all --apply refuses | Emptying the project on a guess. | --i-mean-it, after the plan |
| export, snapshot or a dump refuses to overwrite | Overwriting a file this tool did not make, which is somebody's work. | --force, or write elsewhere |
| refuses a path git would track | A full copy of the brain committed to a repository for good. | Gitignore it, or --allow-tracked if you mean it |
| refuses a path outside the project | Every memory in cleartext landing somewhere nobody looks after it. | --allow-outside |
| "changing an axiom needs a person at a controlling terminal" | An agent (or a prompt-injected one) rewriting the rules every project follows. | Run it yourself, in a terminal you opened |
| "no project called '...' has ever opened this brain" | A note that would reach nobody, usually a typo in the name. | Use the name in that project's brain.json |
| "--everywhere stores a memory at the org" | A memory filed in this project while claiming to reach every project. A local brain has no organisation above it. | Publish a lesson with os-brain publish instead |
What doctor finds #
$ os-brain doctor ======================================================================== INVOICES BRAIN — DOCTOR ======================================================================== 5 live memories for invoices · 7 rows total, every project in this store · schema v16 · ... no problems found ## NOTES - 1 measure outside the declared band: pdf_render_p95 1250 above $ os-brain doctor --fix # repairs the repairable, names the rest
- Search index out of step. Index entries with no memory behind them and memories missing from the index, counted separately so the two cannot cancel out.
reindexrebuilds it. - Broken correction links and loops. A memory that says it replaced an id that no longer exists, or A replacing B while B replaces A.
--fixbreaks a loop at one link and leaves the chains into it retracted, so facts withdrawn on purpose stay withdrawn. - Identity hashes. A memory whose hash does not match its project, scope and title cannot be refined in place, so the next save of the same fact would make a second copy.
- Integrity. SQLite's own integrity check, unusable confidence values and measure readings that are not numbers.
- Notes, not faults. Confirmed memories with no date (nothing can age them, so
review --stale-daysnever shows them), too many pins, most memories still carrying the default source, a measure series that mixes units or sits outside its band, notes that reached nobody, a database file readable by others and a write-ahead log that has grown without a checkpoint (os-brain vacuum).
In a shared store doctor checks the whole file, because a fault in another project's rows is still a fault in the database you use. It shows counts and ids, never titles or bodies. --fix touches only your project's rows after dumping them.
Safety copies #
A copy of the whole store is made at session open, at most once a day and only when the store has changed. You do not run this. wakeup does and says nothing unless it acted.
$ os-brain backup --list 1 safety copy in /home/you/.claude/os-brain/backups/db7f48d762a42bbb 2026-11-20 23:59 288kB 7 memories schema v16 ok $ os-brain backup --verify # open each one and prove it reads $ os-brain backup --restore <file> # dry run: the copy against the live store restore from /home/you/.claude/os-brain/backups/db7f48d762a42bbb/brain-20261120-235952.db copy 7 memories schema v16 live 7 memories This was a dry run and nothing was written. Add --apply to do it. $ os-brain backup --restore <file> --apply
- A copy is a database, so restoring puts a file back instead of importing rows into whatever is there now.
- Every copy is checked as it is made: integrity, schema version and memory count against the live store. One that fails is kept and reported, never deleted, because a bad copy is evidence about the source.
- They live outside every project, in a
backupsdirectory beside the shared store, mode 600. Never in the working tree, where onegit add -Awould publish every memory. - Rotation keeps 14 and never discards the copy holding the most memories. Plain time-based rotation has a known failure: a store is emptied by accident, fourteen ordinary sessions follow and every good copy is replaced by a copy of the damage.
- If the store is smaller than its best copy, the brief says so and names the file to restore from. It never restores by itself, since
forget --allis something people run on purpose.
Restore refuses while any other session has the store open (a hook, an MCP server, the UI, another project on a shared store), because that session would go on writing into the file being thrown away. Close them first.
os-brain backup on its own writes a timestamped full dump on demand. To get copies off the machine, declare a command under "backups": {"push": "..."} in brain.json, with {file} where the path goes. It runs after a copy verifies and needs approval on each machine, because brain.json is committed and a cloned repository must not run a stranger's command at session open.
Export, import and snapshots #
$ os-brain export --out brain-backup.json # the whole project, as JSON $ os-brain import brain-backup.json --dry-run $ os-brain import brain-backup.json # merge: titles already here are skipped $ os-brain import brain-backup.json --events # also replay the activity log $ os-brain snapshot --out MEMORY.md # a generated, readable mirror
JSON is for moving rows between stores. Safety copies are for recovery. Every file these commands write is mode 600, refuses a path git would track or a path outside the project, refuses to overwrite a file without its own generated-by header and refuses to write through a symbolic link.
A dump is a file somebody handed over, so it does not get to say what a memory is worth. Rows arrive unpinned, with trust imported and confirmed only if a citation earns it. A dump that brings guardrails, or that would retract a pinned memory or a guardrail already here, is refused until you have read the dry run and pass --force. Axioms, standards, lessons and notes belong to every project and never come from a dump. Measures go in only when the project has none, because readings cannot be merged without doubling the series.
New versions and the schema #
$ os-brain backup # first: the database is the only copy $ go install github.com/chka/os-brain/cmd/os-brain@latest # or git pull and go build in your clone $ os-brain init # in a project with its own file: refreshes hooks and docs $ os-brain doctor
A newer binary migrates the database when it first opens it. Migrations only add (a column, a table, values rewritten in place), never drop data. Each one runs in a single transaction with the version stamp, so a failure leaves the database exactly as it was. Our tests migrate real old databases through every version in between, because migration bugs show up on old databases and never on new ones.
An older binary opens a newer database only when the database says that binary can read it safely. If not, it refuses instead of writing rows it does not understand. Since every project on the machine opens the shared store, that refusal means the binary on this machine needs replacing with a current one.
If a brain will not open after an update, do not try fixes of your own. List the safety copies with os-brain backup --list --verify and restore one.
Undoing a mistake #
$ os-brain history --id 42 # archived versions of one memory $ os-brain restore h7 # bring an archived version back $ os-brain update 42 --unsupersede # a supersede made by mistake
A body replaced with --update and a memory removed with forget are archived first, so they can come back. prune and forget --all write a full dump before deleting anything and print its path (os-brain import <dump> puts it back). forget also leaves a tombstone, so the same wrong fact is not learned again later. forget --purge is the exception: it keeps no archived version and nothing can restore it.
"Clear the memory" and "remove the brain" are different requests. os-brain forget --all empties the project (a plan until --apply --i-mean-it, with a dump first). os-brain uninstall takes the brain out of the project, as a dry run until --apply. It keeps the database unless you add --purge.
Reporting a bug #
If you are an agent in a project with a brain, the seventh axiom applies: tell the user what you ran, what you expected and what happened. Do not fix the tool yourself and do not quietly work around it. A bug one project hides is one every other project will hit.
Reports go to GitHub issues. Include the exact command, what you expected, what happened and the output of os-brain version. Leave memory contents and paths out unless they matter to the bug: an issue is public. Help has the rest.