Setup guide
Use BotPassword from Claude Code
Add the BotPassword MCP server to Claude Code, grant it credentials, and run it inside a session. Covers sealed and disclosing grants and command-runner rules.
Status: P4-9. bpw agent install claude-code sets Claude Code up in one step. This guide adds bpw mcp to Claude Code as a stdio MCP server, so Claude Code can use your credentials through BotPassword’s intents. No intent returns a value; a run_with grant you mark --allow-disclosure lets the command it starts read one.
The short path
cargo build --release -p bpw -p botpasswordd # until signed installers exist (M1-11)
mkdir -p ~/.local/bin && cp target/release/bpw target/release/botpasswordd ~/.local/bin/
export PATH="$HOME/.local/bin:$PATH" # put this line in your shell profile too
bpw daemon install # macOS: start the daemon at every login
bpw init --server http://127.0.0.1:8787 --kit-out ~/botpassword-kit.txt # once; see Get started
bpw agent install claude-code # register the server, add the instructions
bpw agent enroll claude-code # macOS: let grants name Claude Code
bpw agent run -- claude # start the harness inside a session
Copy the programs to a directory only you can write (~/.local/bin above), and run them from there, not from target/release. The login item and the harness start these files as you every time, so bpw agent install and bpw daemon install refuse a binary, or a directory above it, that group or other users can write, or that another user owns. The daemon runs before bpw init because init talks to it (elsewhere than macOS, start botpasswordd yourself instead of bpw daemon install); init comes before agent run because an agent needs an account. Get started explains it.
Then give the agent something to use with bpw grant add (below); it can use nothing until you do.
bpw agent install claude-code does two things, and says what it did:
- Registers the server by running Claude Code’s own
claude mcp add --transport stdio --scope user botpassword -- <absolute path of bpw> mcp --agent claude-code. That stores it in~/.claude.jsonfor you, in every project.bpwdoes not edit that file itself, because Claude Code rewrites it as it runs. - Adds the instructions to
~/.claude/CLAUDE.md, between two marker lines (<!-- BEGIN botpassword ... -->and<!-- END botpassword -->). They are the sentences of ADR 0058 section 3, which tell Claude Code to use thebpwtools instead of asking you to paste a secret, and to ask you before any action you did not request.
It makes no grant and no session, and writes no secret anywhere. Your existing CLAUDE.md text is kept, a copy is saved as CLAUDE.md.bak before the first change, and a second run changes nothing and says so. --dry-run prints what would change and changes nothing; it does run the harness’s read-only --version and mcp get commands to find out what is already there. The harness’s command is found on your PATH, skipping relative entries and anything in the current directory, and the path it will run is printed. A symbolic link at any file it would write is refused, never followed. If claude is not on your PATH, nothing is changed and the error shows the claude mcp add line to run yourself.
To remove it: bpw agent uninstall claude-code. It unregisters the server and removes exactly the marked block and the one blank line install put before it; the rest of the file stays as it was, and a file that held nothing else is deleted. Your .bak copy is left in place. bpw daemon uninstall stops the login agent (that locks the vault, because the daemon holds the keys in memory). Neither touches your vault, grants, sessions or data directory.
For a project-shared .mcp.json and an AGENTS.md in the current directory instead, run bpw agent install generic. A project file gets no .bak (git is its backup). If bpw on your PATH is the one you ran, it writes just bpw as the command, so no home-directory path lands in a file you may commit; otherwise it writes the absolute path and says so. The rest of this page is the longer explanation and the by-hand steps.
What Claude Code gets
What Claude Code gets: one tool per intent (status, list_credentials, run_with, http_request, store_secret and the rest of the catalog). No tool is built to return a secret value. run_with and http_request inject a credential you granted and return output with that value redacted (best effort: the raw, base64, hex and percent-encoded forms are caught, other transformations are not). The other intents are checked against policy and then return not_implemented in this build.
Before you start
-
Build the two binaries and note where
bpwis. Claude Code starts the server itself, so use an absolute path.cargo build --release -p bpw -p botpasswordd BPW="$(pwd)/target/release/bpw" -
Start the daemon (
bpw daemon installon macOS keeps it running; elsewhere runbotpassworddyourself) and set up a vault (scripts/e2e-two-devices.shshows every step). For a trial, use a disposable vault against the local control plane (pnpm -C services/control-plane dev, which listens on port 8787) and synthetic keys only.target/release/botpasswordd & "$BPW" init --server http://127.0.0.1:8787 --kit-out ~/botpassword-trial-kit.txt -
Add a credential and grant it. Only you can make a grant, and it always asks for your master password, even while the vault is unlocked. Agents cannot make or change grants.
printf '%s' 'sk_test_synthetic_trial_0001' | "$BPW" item add --kind api_key --title "Trial API key" --secret-stdin printf '%s' 'sk_test_synthetic_trial_0002' | "$BPW" item add --kind api_key --title "Trial CLI key" --secret-stdin "$BPW" item list # copy the two item IDs (or let the agent ask, below) "$BPW" grant add <api-key-id> --intent http_request \ --host api.example.com --path '/v1/*' --method GET --expires-in-hours 8 "$BPW" grant add <cli-key-id> --intent run_with --command curl --allow-disclosure --expires-in-hours 8 "$BPW" grant listGrant
http_requestalone for any credential whose host scope matters. Arun_withgrant hands the value to a command the agent chooses. That command can send it to any host, ignoring--host,--pathand--method, and can recover it through a transformation the redactor does not catch (rev,cut, wrapped base64). The daemon starts the command outside the harness and its sandbox, with your full user privileges and network. Grantrun_withonly for a value you would be willing to hand the agent outright. That is why arun_withgrant must say so with--allow-disclosure(bpw grant listlabels it “this agent can read this secret”) and must list each executable it may start with--command: the daemon records each one’s resolved path and SHA-256, starts only those, and refuses a shell or interpreter given code inline (sh -c,python -c,node -e) and launchers such asenvandxargs(ADR 0015). A--commandtakes any arguments, so the agent has that program’s full command-line power: an allowlisted tool that runs code the agent can write (a script file, a build tool) still discloses. Command runners, interpreters and shells are refused as--command.git,gh,npmandcargocan be granted with--argv, and so can an interpreter running one script (below). The other runners (make,ssh,npx,pnpm,docker, …) cannot be granted at all.bpw grant addwarns when one grant has both intents.--hosttakes exacthostorhost:portnames, never wildcards or IP addresses.--methodtakesGETorHEADonly, unless every--hostis a provider API with an endpoint table (api.github.com,api.cloudflare.com,api.stripe.com,iam.amazonaws.com,sts.amazonaws.com). On those hosts only the endpoints the table lists are allowed, and an endpoint that creates tokens or keys answersminting_blocked. Elsewhere a request that names an RPC operation (anActionquery key, agraphqlpath) is refused; redirects are returned, never followed (ADR 0016). The value goes in theauthorizationheader asBearer <value>unless you pass--headerand--prefix.--project <dir>limits the grant to agent sessions opened in that directory or below it (bpw agent run --project); the agent cannot choose the directory.
Command runners: git, gh, npm and cargo
A command runner runs other commands named in its arguments (git -c alias.x='!…', npm exec, cargo --config …), so a grant for the bare executable would let any subcommand get the value. Grant it with an argv pattern instead (ADR 0040):
"$BPW" grant add <gh-token-id> --intent run_with --allow-disclosure --expires-in-hours 8 \
--argv 'git push origin *' --argv 'git fetch origin' --argv 'gh pr create --fill'
"$BPW" grant add <npm-token-id> --intent run_with --allow-disclosure --expires-in-hours 1 \
--argv 'npm publish --access public'
The agent then injects the value under the runner’s token name:
- git and gh:
GH_TOKENorGITHUB_TOKEN. git reads it only throughgh auth git-credential(gh auth setup-git). - npm:
NPM_TOKENorNODE_AUTH_TOKEN, as your.npmrcnames it. - cargo:
CARGO_REGISTRY_TOKEN.
Any other name is scope_denied for a runner. Every run_with grant also refuses a best-effort list of names that change how a program runs or where it connects: the loader (LD_*, DYLD_*), shells and the base environment (PATH, HOME, BASH_ENV, LC_*), proxies and TLS roots (*_PROXY, SSL_CERT_FILE), interpreters and compilers (NODE_*, PYTHON*, CC), and the runners’ own configuration (GIT_*, GH_*, NPM_CONFIG_*, CARGO_*, RUSTUP_*). ADR 0040 has the full list. It is not complete for other tools, so for a plain command or a script, choose the variable name with care. The daemon’s log says which name was refused.
How patterns work:
-
The pattern is the program, then the exact arguments, separated by single spaces. A final
*matches further operands, never options. -
Every runner is deny by default. A pattern starts with one of the runner’s listed subcommands, and nothing may come before it. That refuses
git -c …,git -C …,cargo +nightly …andcargo --config …. Only subcommands that use the token are listed:- git:
push,fetch,ls-remote,pullandclone; - cargo:
publish,ownerandyank; - most of gh’s
pr,issue,release,run,workflow,search,secretandvariablesubcommands; - npm’s registry subcommands.
ADR 0040 has the tables.
- git:
-
Options are an allowlist per subcommand, spelled exactly. No abbreviations, aliases or clusters.
--access publicand--access=publicare different patterns, and so are reordered options. An option that takes a value needs the value in the pattern:pr create --title *is refused. -
Name the remote.
*never stands for a remote or a URL:git push *andgit fetch *are refused; writegit push origin *. Operands after the remote are screened when the agent asks. -
A git ref is a branch or tag. It is a one-part name (
main,v1.2.0) orrefs/heads/…orrefs/tags/…(refs/heads/feature/x). It is never:- an object id or an abbreviation of one, 4 or more hex digits (spell a branch named
cafeasrefs/heads/cafe); git describeoutput, a name ending in-gand 4 or more hex digits (v1.0-1-g600b5d3);- revision syntax (
main~1,FETCH_HEAD^0,stash@{0}); HEAD,FETCH_HEADor another pseudo-ref;- a review ref on any forge (
pull/1/head,merge-requests/…,changes/…).
Name the branch the agent should push. A push may still force (
+main) or delete (:main), sopush origin *allows both; writepush origin mainto rule them out. - an object id or an abbreviation of one, 4 or more hex digits (spell a branch named
-
push origin *decides what a laterpullbrings in. An exactgit pull origin mainmerges whatevermainholds on the remote. Withpush origin *, the agent can make that any commit a local branch names. Do not combinepush origin *,pullfrom the same remote, and a rule that runs project code (npm ci,npm install,cargo publish, a script); name the push refspec instead. -
Subcommands whose operands name code, files, destinations or lasting rights are exact only. Write their operands out:
git cloneandgit pull;npm publish,install,view,owner,access,dist-tag,deprecateandunpublish;gh pr merge,release create,upload,downloadanddelete, andsecretandvariableset/delete.gh pr reviewnever takes--approve, since an approval can satisfy a required review;cargo ownerandyank.
Even written out, an operand cannot be an absolute or
~path, a..path, a URL other than https or ssh to a host, or an npm git, GitHub, file or URL spec. -
Not grantable at all:
- git
config,remote,submodule,rebaseand every local subcommand; - gh
api,auth,alias,extension,pr checkout,repo cloneandrepo set-default; - npm
exec,runandpack; - cargo
build,run,installandtest; - any option that names another host or repository, or opens a browser or editor (
--hostname,--repo,--web,--editor); - any option that reads a file (
--body-file,-F).
- git
-
rustup’s cargo.
~/.cargo/binis not on the daemon’s run PATH, so grant it by absolute path:--argv '/Users/you/.cargo/bin/cargo publish'. The agent sends the same path.cargo publishbuilds the crate to verify it, which runs every dependency’s build script with the token in its environment. If you build and test separately, grantcargo publish --no-verify. -
Interpreters and shells (
python3,node,bash,sh,ruby,deno,bun,pwsh,java, …) are granted only to run one script inside the project:--argv 'python3 scripts/deploy.py *'. The script comes first, by its path in the project, with no interpreter option before it.java -jar build/app.jarandpwsh -File scripts/x.ps1are the two exceptions.*after the script matches operands only, never a URL or a path outside the project. The script decides what those arguments do. A grant made earlier with--command python3(or another listed interpreter) no longer matches; remake it with--argv. The list goes by name and cannot name every interpreter, so treat any--commandas able to run code. -
bpw grant listshows each rule with its runner and the label “runs project code”.
What a runner rule promises: an agent that controls only the command line and the variable name cannot:
- run code with the value in its environment;
- send the value to a host the pattern does not name;
- write files outside the working tree;
- change configuration that a later run reads.
That is an agent with MCP access and no file access. An interpreter rule promises less: the agent cannot choose the code, but the script decides what its arguments do. A --command promises none of this.
The “runs project code” label marks everything else. Each runner still runs hooks, lifecycle scripts or build scripts, and reads configuration from files:
- git:
.git/configand.git/hooks; - npm:
.npmrcandpackage.jsonscripts; - cargo:
build.rsand.cargo/config.toml; - gh:
~/.config/gh.
An agent that can edit the project can still make git push run its own code or send the token elsewhere. So a runner grant needs --allow-disclosure like any run_with grant, and is never sealed. Prefer http_request for API tokens. Use a runner rule only for a value you would hand the agent outright, with a short expiry and a --project.
Add the server by hand
bpw agent install claude-code does this for you (the short path). Do it by hand to see each step or to pick another scope. --agent claude-code is a label that BotPassword shows in status and in the notes of anything Claude Code stores. Any program can claim any label, so BotPassword never grants anything because of it.
Command line (stored in ~/.claude.json, for you only):
claude mcp add --transport stdio --scope user botpassword -- "$BPW" mcp --agent claude-code
Use --scope local (the default) for the current project only, or --scope project to write a .mcp.json your team shares. Everything after -- is passed to bpw unchanged.
Project file (.mcp.json at the project root), if you prefer to write it by hand:
{
"mcpServers": {
"botpassword": {
"command": "/absolute/path/to/target/release/bpw",
"args": ["mcp", "--agent", "claude-code"]
}
}
}
Claude Code asks you to approve a project-scoped server the first time.
Never put a secret in this config. No env block is needed. bpw mcp looks for the daemon in $BPW_SOCKET_DIR, then $XDG_RUNTIME_DIR/botpassword, then ~/.botpassword/run, and Claude Code can read its own configuration.
Check it
claude mcp list # botpassword should show as connected
In a session, /mcp shows the server and its tools. Claude Code names them mcp__botpassword__status, mcp__botpassword__run_with and so on.
A run_with call can last up to 100 seconds (timeout_seconds). If Claude Code gives up on a slow command first, raise its MCP tool timeout (the MCP_TOOL_TIMEOUT environment variable, in milliseconds).
Start it in a session
Agents act only inside a session (ADR 0014). There are two ways to give Claude Code one.
Start it normally, then approve it. This needs Claude Code enrolled (below), and works on macOS and Linux. Start claude the way you always do. Its first BotPassword tool call answers session_required. BotPassword then lists it as a waiting agent:
- in the desktop app, on the Agents page, with a count beside Agents in the sidebar;
- at a terminal, with
bpw session pending.
The app does not pop up, take focus or make a sound. The count shows only within 5 minutes of entering your master password in the app. Using the app does not extend those 5 minutes.
Each row shows Claude Code’s name, how it was recognized, its process ID, when it started, the program it runs, a path it was started under, and its folder. These help you notice a wrong row. None of them proves the row is your agent. Code running as you can start a real Claude Code, with its own configuration, in your project folder, and its row looks the same. The app and bpw session pending mark a row in two cases. One is when another waiting row is the same client in the same folder, or in a folder inside the other’s. The other is when another client is shown with the same name. Two Claude Code sessions in unrelated projects are not marked. They also say how many agents asked in the last 10 minutes and were not listed. Any program running as you can raise that number, so it means only that something did not fit. If BotPassword has stopped noticing waiting agents, they say that, and bpw daemon restart fixes it. When in doubt, dismiss them all and use bpw agent run.
To approve one, give the project folder, a length (1 hour by default, 12 hours at most) and your master password. bpw session approve asks for the password, shows the row, then asks Approve? [y/N]:
bpw session pending # the waiting agents, with their IDs
bpw session approve ID # asks for your master password, then y/N
bpw session approve ID --project ~/Developer/your-project --minutes 240
bpw session dismiss ID # not listed again for 10 minutes
If the folder could not be shown exactly, name it with --project; the app asks you to type it.
The session covers everything that Claude Code process runs, until it exits or the session runs out. If the process is an app, such as an editor, the session also covers that app’s other extensions and terminals. The ledger can say less about who asked than for a session bpw agent run started. Ask Claude Code to try again after you approve.
A waiting agent goes away after 10 minutes, when its process exits, or when you lock the vault. Up to 8 wait at a time. Approval never becomes standing: each one covers one process. Windows does not have this yet; use bpw agent run there.
Or start it through bpw, from the project directory:
cd ~/Developer/your-project
bpw agent run --minutes 120 -- claude
bpw agent run asks for your master password, opens a session for this directory, runs claude as its child and ends the session when it exits. bpw mcp started by Claude Code is inside it.
Without a session, every tool but status answers session_required, and status reports only whether the vault is unlocked. A grant bound to a project (bpw grant add --project) applies only to sessions opened in that directory or below it. bpw session list and bpw session end ID show and end sessions. An approved session is marked attached there.
Enroll Claude Code
Enrolling tells BotPassword how to recognize Claude Code, so a grant can be for Claude Code only. Until you enroll it, every session’s client is unenrolled, and a grant for unenrolled serves any session that is not an enrolled client’s.
bpw agent enroll claude-code # asks for your master password
bpw agent clients # the enrolled clients and their IDs
bpw grant add ITEM --client ID ... # a grant only Claude Code's sessions can use
On macOS, bpw agent enroll claude-code recognizes the program by its code signature: the signing team Q6L2SF6YDW and the identifier com.anthropic.claude-code. The native installer and the Homebrew cask install that signed program. An install that runs Claude Code as a script under node is not that program, so it is not recognized this way. Enrolling node itself by signature is refused, because that would match every script node runs.
Elsewhere, or for a program without a usable signature, enroll it by path: bpw agent enroll --name "Claude Code" --path /full/path/to/claude. The file and every directory above it must be owned by you or root and not writable by others. BotPassword checks this when you enroll and again each time it matches. Such a client is labeled “recognized by path”. Anyone who can replace that file can act as that client.
bpw agent run fixes the session’s client when it starts Claude Code: right after starting it, bpw asks the daemon, which reads bpw’s one child process itself and recognizes it. bpw prints the client it was recognized as, or that the session is unenrolled. The client stays fixed for the whole session, even if the program later replaces itself with another one. If the daemon cannot fix it, for example because the vault is locked, bpw stops Claude Code and ends the session. bpw session list shows each session’s client.
If bpw status says the list of enrolled clients cannot be read, no session is recognized as a client. Run bpw agent clients --reset with the master password, then enroll your clients again.
Grants are not moved when you enroll. A grant made for unenrolled keeps serving unenrolled sessions only. To let the enrolled Claude Code use a credential, revoke the old grant and add one with --client. When Claude Code asks with request_access and you approve, the grant is made for its client.
bpw agent unenroll ID removes a client. Its sessions end, and any command they started is stopped. Its grants stay but no session can use them; the command says how many are left, and bpw grant revoke removes them.
What a refusal tells Claude Code
When BotPassword refuses a request, the result keeps its outcome code (for example session_required, vault_locked or scope_denied) and adds two sentences next to it. message says what happened. next_step says what to do now: for example, ask you to unlock BotPassword, or call request_access so that you can approve a grant. A next_step never tells Claude Code to ask you for a password or a secret in chat, or to get around the refusal.
The same applies at a terminal. bpw agent <intent> prints the outcome, then message: and next step:. Add --json to get one JSON object on stdout and nothing else there; it holds the same fields as the MCP result and never a secret value. bpw status --json works the same way.
A script can tell the results apart by the exit status of bpw agent <intent> (bpw agent run is different: it exits with the status of the command it ran):
| Status | Meaning |
|---|---|
| 0 | Done |
| 1 | Failed: BotPassword could not be reached, the arguments were wrong, or something broke inside bpw. With --json each of these is still one object: failed with a message when bpw turned the arguments down or broke, daemon_unavailable for an unreachable daemon, daemon_incompatible for a daemon that answers in a form this bpw cannot read (update bpw and the daemon to the same build) |
| 2 | The command line could not be parsed. With --json that is also one object, usage_error |
| 3 | Refused: BotPassword answered and said no, for example vault_locked or scope_denied |
| 4 | Not finished: a person must act. This is approval_required (an approval is waiting for you) or partially_rotated. Do not treat it as done |
The credential helpers (git-credential-bpw, docker-credential-bpw, bpw aws-creds, bpw kube-creds) keep the exit status their own tool defines.
What to expect
| Ask Claude Code to | Tool | Typical outcome |
|---|---|---|
| “Check BotPassword” | status |
success, with the session’s client (its ID once enrolled, otherwise unenrolled) and agent "claude-code", self-asserted |
| “Which credentials can you use?” | list_credentials |
Only granted items, with their allowed intents |
“Run env with my trial CLI key as API_KEY” |
run_with |
success; the output shows [bpw:redacted] where the value was |
| “GET https://api.example.com/v1/user with my trial API key” | http_request |
success with status, headers and redacted body; a host outside the grant gives scope_denied, and a granted name that resolves to a private or loopback address gives host_restricted |
| “Store this new key: …” | store_secret |
success and a new item ID |
| “Ask me for access to my trial API key for api.example.com” | request_access |
approval_required with a request ID; approve it in the desktop app’s Ledger or with bpw access approve ID, and the agent’s next check reads approved with the grant |
| In a fresh session with no grants: “Ask me for the key you need to read api.example.com” | request_access with looking_for |
approval_required with a request ID and no item; you choose the item in the Ledger (or bpw access approve ID --item ITEM) and approve, and its next list_credentials shows the item |
Anything after bpw lock |
any | vault_locked |
run_with runs the program directly, not through a shell, and only an executable the grant lists; a shell runs a script file (["/bin/sh", "script.sh"]), never -c. The child gets only PATH, HOME, LANG and the injected variables, never your shell’s environment. Claude Code’s own sandbox does not apply to the command: the daemon starts it, outside Claude Code, with your user’s privileges and network.
Approving what the agent asks for
When the agent calls request_access, nothing changes until you decide. See what is waiting and decide from a terminal:
"$BPW" access list # what the daemon knows, then the agent's own words
"$BPW" access approve <request-id> # asks for your master password, shows the request, then asks y/N; --ttl-seconds shortens it
"$BPW" access approve <request-id> --item <item-id> # for a request that describes what it wants: choose the item first
"$BPW" access deny <request-id>
"$BPW" access ledger # every request, decision and grant, with no values
The desktop app shows the same requests on its Ledger page, with a count beside Ledger in the sidebar. The grant you approve is exactly what was asked, bound to the project the session was opened in, and replaces any grant the item already has. The agent’s name and reason are its own words: read them, but decide from the item, the scope and the project. Approval on your phone is planned (P4-2b).
An agent with no grant cannot name an item: it has no way to learn an ID, and BotPassword does not say whether one exists. So it describes what it needs instead, with looking_for (“the API key for api.example.com, to read the deploy status”), and the request reaches you with no item. The Ledger shows the description, labelled as the agent’s own words, and lists your items with those that match its words first. Choose one, and the sheet shows that item’s facts and the grant like any other request; choosing grants nothing. Approve with your master password, or decline. Until you approve, the agent learns nothing about your items, not even whether one matched (ADR 0069).