brainjar
Shape how your AI thinks.
brainjar composes soul + persona + rules into prompts for AI agents.
It's a Go CLI that runs offline against a single local SQLite workspace.
No server, no network calls, no account.
Status: v0.2.0-dev — CLI local mode. Single-workspace, single-user.
Install
There are no binary releases yet. Build from source:
git clone https://github.com/brainjar-sh/brainjar
cd brainjar
go build -o brainjar ./cmd/brainjar
Or with the included just recipes:
just build # go build -o brainjar ./cmd/brainjar
just test # go test ./...
just lint # golangci-lint run ./...
Requires Go 1.25 or later. Put the resulting brainjar binary on your
PATH.
Quick start
brainjar init # create ~/.brainjar
echo "You speak with conviction" | brainjar soul create straight-shooter
echo "You are the CTO" | brainjar persona create cto
echo "Test before merging" | brainjar rule create testing
brainjar soul use straight-shooter
brainjar persona use cto
brainjar rule add testing
brainjar compose > prompt.txt # compose effective state
Content for soul create, persona create, and rule create comes
from stdin, --content "...", or --file <path> in that precedence.
Save the current soul+persona+rules as a reusable brain:
brainjar brain save cto
brainjar compose cto > prompt.txt # compose from a brain
brainjar compose --persona architect --task "design the auth layer"
Inspect what's active:
brainjar status
Commands
| Command |
Purpose |
brainjar init [--force] |
Create the home directory, run migrations, write config.yaml. |
brainjar reset [--yes] |
Remove brainjar.db and config.yaml from the home. |
brainjar soul create|list|show|delete|use|drop |
Manage souls — the top-level voice. |
brainjar persona create|list|show|delete|use|drop |
Manage personas — the role adopted. |
brainjar rule create|list|show|delete|add|remove |
Manage rules — composable guidance fragments. |
brainjar brain save|list|show|delete |
Named bundles of soul + persona + rules. |
brainjar compose [brain] [--persona slug] [--task "..."] |
Compose a prompt to stdout. |
brainjar status |
Show the effective state and layer chain. |
brainjar versions <type> <slug> [<n>] |
List or print archived versions of a soul, persona, or rule. |
brainjar pack export|import |
Export or import the workspace as a JSON bundle. |
Run brainjar <cmd> --help for flags and examples on any command.
Global flags
| Flag |
Description |
--home <dir> |
Override the brainjar home directory. |
--json |
Emit machine-readable JSON on stdout; errors go to stderr as a structured envelope. |
-h, --help |
Command help. |
-v, --version |
Print the binary version. |
Home resolution
The home directory is resolved in this order:
--home <dir> flag
$BRAINJAR_HOME environment variable
~/.brainjar
It holds config.yaml and brainjar.db (SQLite). Nothing else is
written there by brainjar itself.
Agent mode (--json)
Every command supports --json. In JSON mode:
-
Success output on stdout is a single JSON document.
-
Errors on stderr are a structured envelope:
{
"error": {
"code": "BAD_REQUEST",
"message": "invalid references",
"hint": "re-run `brainjar init --force` after backing up",
"invalid_refs": { "soul_slug": "ghost", "rule_slugs": ["missing"] }
}
}
code is one of NOT_FOUND, CONFLICT, BAD_REQUEST, UNAUTHORIZED,
FORBIDDEN, INTERNAL. hint and invalid_refs are optional.
-
Human warnings (missing slugs during compose, etc.) still go to
stderr so they don't pollute a piped prompt.
Shell completions
brainjar completion <shell> prints a completion script for bash,
zsh, fish, or powershell. For example, to enable completion in zsh:
brainjar completion zsh > "${fpath[1]}/_brainjar"
Exit codes
Exit codes are a stable contract — safe for scripts and CI:
| Code |
Meaning |
0 |
Success |
1 |
Generic error |
2 |
Bad usage or validation failure |
3 |
Not found |
4 |
Conflict (duplicate slug, etc.) |
5 |
Reserved for auth (unused in local mode) |
License
MIT — see LICENSE.