CLI reference
The carrybrain package on npm installs the MCP server and hooks for your agents, syncs skills and rules, and gives you small commands for memories. It needs Node 22 or newer and has no runtime dependencies.
npx carrybrain --help # try it without installing
npm i -g carrybrain # or install it for a stable pathcarrybrain --help (or -h) prints usage, carrybrain --version (or -v) the version.
Configuration
The CLI reads a URL and a key from ~/.config/carrybrain/config.json (written by login and install, mode 600). Environment variables win over the file, and when both are set no file is needed.
| Variable | Purpose |
|---|---|
CARRYBRAIN_URL | Your server's address, for example https://memory.example.com |
CARRYBRAIN_KEY | An API key (cb_...) |
CARRYBRAIN_HOME | Keep config and cache in one directory |
CARRYBRAIN_CONFIG_DIR, CARRYBRAIN_CACHE_DIR | Move just the config or just the cache |
XDG_CONFIG_HOME, XDG_CACHE_HOME | Standard XDG locations, used when the variables above are not set |
CLAUDE_CONFIG_DIR | Claude Code's config directory (default ~/.claude): where settings.json and skills/ live |
Plain http:// to a host other than localhost sends your key unencrypted. The CLI warns on stderr; pass --allow-http to login or install to silence it.
login
carrybrain login --url <url> --key <key> [--allow-http]Checks the key against the server and saves the config. --url and --key fall back to CARRYBRAIN_URL and CARRYBRAIN_KEY.
install
carrybrain install claude|codex|cursor|gemini [--url <url> --key <key>] [--yes]
carrybrain install --all --yes [--no-save]With --url and --key the login is saved first; without them the saved login is used.
| Target | What it does |
|---|---|
claude | Registers the MCP server with Claude Code (claude mcp add-json --scope user), using a headersHelper so the key is never in Claude's config. Adds SessionStart and SessionEnd hooks to ~/.claude/settings.json. Without a claude binary the hooks are still written and the MCP registration completes on the first session. |
codex | Adds [mcp_servers.carrybrain] to ~/.codex/config.toml, then syncs skills. |
cursor | Adds the server to ~/.cursor/mcp.json, then syncs skills. |
gemini | Adds the server to ~/.gemini/settings.json (httpUrl), then syncs skills. |
--all | Non-interactive and idempotent. Claude Code, plus Codex, Cursor and Gemini when ~/.codex, ~/.cursor or ~/.gemini exists, then syncs skills. Never reads stdin and exits 0 with a warning when the URL or key is missing or the server is unreachable, so it is safe in setup scripts. A key the server rejects installs nothing. |
Flags: --yes skips the "keep skills fresh in the background?" question for codex, cursor and gemini; --all never asks, and scripts pass --yes by convention. --no-save keeps the key out of config.json (use it with the environment variables). The Codex, Cursor and Gemini config files hold the key in plain text, created with mode 600.
init-repo
carrybrain init-repo [--dir .] [--url <url>] [--repo <remote>] [--commit-skills]For cloud agents that read only the repo. Writes files you can commit, with no secrets:
.mcp.jsonwith thecarrybrainserver (${CARRYBRAIN_URL}/mcp,Bearer ${CARRYBRAIN_KEY}), merged into any existing file..claude/settings.jsonwithenabledMcpjsonServers: ["carrybrain"]and a SessionStart command hook (npx -y carrybrain@latest hook claude-session-start).
--url only changes the printed next steps. --commit-skills also writes the repo-scoped skills to .claude/skills/carrybrain-* and .agents/skills/carrybrain-* (readable by everyone with repo access; personal, team and org skills are not included). --repo overrides the remote used to pick those skills. Safe to re-run. It prints the follow-up steps: commit, set the two variables in the platform, allow the host.
import
carrybrain import [--only rules,skills,memories] [--from claude|codex|cursor|gemini|all] [--dry-run] [--yes] [--overwrite]Copies rules, skills and Claude Code memories you already keep on this machine into your personal Carrybrain scopes. It prints a plan per source first (new, same, conflict), then asks before writing.
| Flag | Meaning |
|---|---|
--only | Comma list of rules, skills, memories. Default: all three. |
--from | Only one source. Default all. |
--dry-run | Show the plan and write nothing. |
--yes | Do not ask. Required when there is no terminal. |
--overwrite | Replace items that conflict with different existing content. Without it conflicts are skipped. |
Files read: ~/.claude/CLAUDE.md and ~/.claude/skills, ~/.codex/AGENTS.md and ~/.agents/skills, ~/.gemini/GEMINI.md, ~/.cursor/rules/*.md|mdc. Carrybrain's own blocks (<!-- carrybrain:start -->) and carrybrain-* skill folders are skipped. Only SKILL.md is imported from a skill folder; extra files produce a warning. The server splits markdown at ## headings (or # when there are none) into one rule per heading, keyed by the heading in kebab-case.
Memories come from ~/.claude/projects/*/memory/*.md (respecting CLAUDE_CONFIG_DIR); MEMORY.md index files are skipped. Each project folder is resolved back to its directory, and if that is a git repo the memories are linked to it; user and feedback memories stay global. All imported memories are private. Duplicates of memories you already have are reported as same and not written again.
doctor
carrybrain doctor [--dir .]Prints one check per line, with a fix for each failure, and exits 1 when a critical check fails. Checks: Node version, config source (environment or file), server reachable and TLS, key valid (and whether it is read-only), SessionStart hook, MCP registration, skills folders, repo id of the directory, autosync, and a nudge to import if you have not. Critical: Node, URL and key, reachability, key validity.
sync
carrybrain sync [skills] [--quiet] [--dir <dir>]
carrybrain sync cursor|codex [--dir <dir>] [--repo <remote>]sync (or sync skills) writes the skills that apply to you into the folders agents read: ~/.claude/skills/carrybrain-<name>/ and ~/.agents/skills/carrybrain-<name>/, plus the repo's .claude/skills and .agents/skills inside a git repo with a remote (git-excluded). Only carrybrain-* folders are ever touched. An unchanged state costs one conditional request. --quiet prints nothing and never fails, for hooks and timers. When shared skills (from teammates) change, the CLI tells you, because they run with your trust.
sync cursor writes the merged rules to .cursor/rules/carrybrain.mdc. sync codex writes AGENTS.override.md: the repo's own AGENTS.md followed by a Carrybrain block (Codex reads the override first). Both files are added to .git/info/exclude, and the repo is taken from the git remote of --dir unless you pass --repo.
autosync
carrybrain autosync enable|disable|statusRuns carrybrain sync --quiet every 15 minutes, for agents without Claude Code hooks. macOS uses a launchd agent, Windows a Task Scheduler task carrybrain-sync, Linux a systemd user timer or else a cron line.
rules, remember, recall
carrybrain rules [--repo <remote>]
carrybrain remember <text> [--team <name> | --org] [--repo <remote>]
carrybrain recall <query> [--repo <remote>] [--limit <n>]rulesprints the merged rules exactly as the session hook injects them.remembersaves a memory. It is private by default;--team <name>shares with one of your teams,--orgwith everyone (admin only). It printscreated memory #id, orupdatedwhen it merged a near-duplicate.recallsearches by meaning and prints one line per memory with its score.--limitdefaults to 5.
hook and mcp-headers
carrybrain hook claude-session-start|claude-session-end
carrybrain mcp-headersUsed by Claude Code, not by you. hook claude-session-start reads the hook event from stdin, finds the repo from the git remote, prints rules, recent memories and a skills catalog as session context, and starts a background skills sync. It never fails a session: on any error it prints {}, and when the server is slow or down it falls back to the last good copy, labelled as cached. claude-session-end starts the same sync. mcp-headers prints {"Authorization":"Bearer <key>"} and is registered as Claude Code's headersHelper.