Skip to content

Secrets

.gitignore excludes *.env. The token file ~/.config/claude-dev-doctor/claude-remote.env holds real tokens at mode 0600 and must never be committed, here or anywhere else. A token is never passed as a command-line argument either, because other users on the machine can read the process list.

On the Linux host, GITHUB_TOKEN and GITHUB_PERSONAL_ACCESS_TOKEN hold the bot account's token, not the owner's. It is an OAuth token from rotate.sh rotate github (the gh device flow), written to the token file. It is active:

  • in the sandboxes at once;
  • in the home session after systemctl --user restart claude-remote;
  • in a login shell from the next login.

status.sh reports the token file and the running home session's token separately, each with the account it acts as (token-rotation.md).

One store on the host

On the host this one file is the store that everything writes and reads; there is no copy (#319):

  • the home session's user unit names it as its EnvironmentFile;
  • the sandboxes' token helper reads it on every refresh;
  • a block in ~/.profile exports it into login shells, so a claude started over SSH has the home session's tokens (linux-host.md).

Three keys are the exception:

  • GITHUB_TOKEN and GH_TOKEN reach neither login shells nor the home session. gh would prefer them to its own login, so the ~/.profile block skips them and the home unit unsets them (#304).
  • ANTHROPIC_API_KEY, which vault.sh sync writes to the file, reaches a login shell but not the home session. Remote Control refuses API-key auth, so only the home unit unsets it.

Every process of claude can read the file. That widens nothing: claude owns the file and could read a running session's /proc/<pid>/environ anyway.

Bitwarden as the source

With Bitwarden Secrets Manager, the token file becomes a cache. The tokens live in a project in the vault, and vault.sh sync of dev-env:ops-doctor writes them into the file; every reader of the file stays as it is. The machine then stores one secret: its machine account's access token.

  • An hourly timer syncs each machine.
  • After a rotation, vault.sh refresh runs that sync at once and shows vault.sh check, the machine's base-setup check (#479).
  • Where the janitor runs, a queued {"kind": "vault_sync"} entry starts the same sync at its next pass (janitor.md).

Setup, rotation and the gotchas: ops-doctor remote-access.md (plugins/dev-env/skills/ops-doctor/remote-access.md) (#376).

The store on Windows

On Windows the equivalent store is the user environment (HKCU), not a file. %USERPROFILE%\.claude is synced to Google Drive there, so a token written into a settings file would leave the machine. vault.ps1 of dev-env:ops-doctor syncs the vault into the user environment, with BWS_ACCESS_TOKEN as the bootstrap user variable (plugins/dev-env/skills/ops-doctor/remote-access.md, #413):

  • its scheduled task ops-vault-sync is the hourly sync, run through conhost.exe --headless so no terminal window opens (#841); vault.ps1 task registers it again after each dev-env update;
  • vault.ps1 refresh runs it at once and shows vault.ps1 check;
  • a janitor vault_sync entry starts it too.

Docker Sandboxes

The bot sessions in a Docker Sandbox (linux-host.md) get no token at all. sbx keeps a secret per service on the host. Inside the sandbox the variable holds a placeholder, and the sbx proxy replaces it with the real value in requests to that service's hosts:

Secret Kind Token file key Hosts
github service secret GITHUB_PERSONAL_ACCESS_TOKEN (the gh device-flow token) GitHub (gh, git push)
AIKIDO_API_KEY custom secret AIKIDO_API_KEY ide.aikido.dev, app.aikido.dev
CONTEXT7_API_KEY custom secret CONTEXT7_API_KEY mcp.context7.com
GEMINI_API_KEY custom secret SBX_GEMINI_API_KEY generativelanguage.googleapis.com

Each secret stores a command, not a value: sbx secret set … --command with the token helper ~/.local/lib/claude-sandbox/sbx-token <KEY>, which prints one key of the token file. sbx runs it on the host when it needs the value. So the token file stays the one store, and no value goes onto a command line.

scripts/sandbox/sandboxes.sh setup:

  • installs the helper, mode 0700, outside every workspace. It refuses a target inside one: sbx does not confine the helper, so a helper that a sandbox could edit would hand out every token;
  • sets the four secrets, a custom secret only once its key is in the token file.

sandboxes.sh and dev-doctor list the secrets by name.

sbx's own Docker sign-in is not a sandbox secret. When it is lost, sandboxes.sh login signs in again from the token file's DOCKERHUB_USERNAME and DOCKERHUB_TOKEN (a Docker personal access token with Read scope). The token goes only to sbx's stdin, and the helper does not serve these keys (linux-host.md).

The Anthropic sign-in and its 28 days

On the Linux host the sandboxes sign in to Anthropic the same way: the owner runs /login once inside a sandbox, as the bot account, and sbx keeps that OAuth sign-in on the host and refreshes its access token (#753). Windows sandboxes, which are on hold since 2026-11-21, did the same; their details are under the owner's workstation below. The VM's ~/.claude/.credentials.json holds only sbx's sentinels and refreshTokenExpiresAt, a time.

  • The sign-in ends about 28 days after the /login (#836). The refresh token has a fixed lifetime; refreshing the access token does not extend it. Past that end the proxy's refresh gets nothing back, Claude Code empties .credentials.json, and every session in the sandbox answers Login expired · Please run /login; Remote Control disconnects. sbx secret ls still lists anthropic (oauth configured).
  • Renewing: sbx exec -it <sandbox> claude, then /login as the bot account, before the end. That renews the host's sign-in for every sandbox. A sandbox whose file was already emptied stays signed out until /login runs in it too, once per such sandbox.
  • Who warns:
    • sandboxes.sh (status, Linux) and Sandboxes.ps1 (status, Windows) ask each running sandbox from inside with GET /v1/models and show the end per sandbox: a warning naming the day in its last 3 days, a failure after it, on an emptied file or a refused answer. A failure makes status exit 1. The value reaches curl through a config on stdin; only the HTTP status and the time leave the VM.
    • ops-patrol on the Linux host pushes signin:<sandbox> when the sign-in is expiring or gone, with the owner's step, so a sandbox whose coordinator is signed out is still noticed; ops:watch reads the same state.
    • Each coordinator's maintenance task anthropic-signin (workflow:maintenance) runs the same check at start and daily from inside, and pushes a notification while the coordinator can still run.

On the owner's workstation

Windows sandboxes are on hold and not in use since 2026-11-21 (#947); what follows is kept for the day the work resumes. There the sandboxes act as the bot account, as on the host. Each token is stored once in Bitwarden and fixed there when it is invalid. Every value the sandboxes need comes from the Bitwarden project dev (#625, #790); the owner's own sessions on the workstation keep reading owner and ops through vault.ps1, and the sandboxes never read HKCU. The only value a person enters on the workstation is the dev access token, stored by Sandboxes.ps1 dev-token.

The lookup rule in dev. With <name> the key without an SBX_ prefix, the entry SBX_<name> wins when it exists, else <name> is used. An SBX_ entry that exists but is empty counts as missing, with no fallback, so a deliberately blanked value is reported rather than silently replaced. status names the entry each value came from, never the value. The Linux host does not follow this rule yet: its sandboxes read the token file.

Value Entry in dev, first that exists
GITHUB_PERSONAL_ACCESS_TOKEN SBX_GITHUB_PERSONAL_ACCESS_TOKEN, GITHUB_PERSONAL_ACCESS_TOKEN
AIKIDO_API_KEY SBX_AIKIDO_API_KEY, AIKIDO_API_KEY
CONTEXT7_API_KEY SBX_CONTEXT7_API_KEY, CONTEXT7_API_KEY
SBX_GEMINI_API_KEY SBX_GEMINI_API_KEY, GEMINI_API_KEY
the commit identity, Name <email> on one line SBX_GIT_IDENTITY, GIT_IDENTITY
Secret Kind Source Hosts
anthropic sbx's OAuth sign-in /login inside a sandbox, as the bot account; sbx keeps and refreshes the tokens in its own store on the workstation, none in HKCU or Bitwarden api.anthropic.com
github service secret GITHUB_PERSONAL_ACCESS_TOKEN of dev (the bot account's gh token, classic scopes), read through bws GitHub (gh, git push)
AIKIDO_API_KEY custom secret AIKIDO_API_KEY of dev, read through bws ide.aikido.dev, app.aikido.dev
CONTEXT7_API_KEY custom secret CONTEXT7_API_KEY of dev, read through bws mcp.context7.com
GEMINI_API_KEY custom secret SBX_GEMINI_API_KEY of dev, read through bws generativelanguage.googleapis.com

The helper there is scripts/windows/sbx-token.ps1. Each secret stores pwsh -NoProfile -NonInteractive -File <%LOCALAPPDATA%>\claude-sandbox\sbx-token.ps1 <KEY> with the path written out, because sbx runs it through cmd from a fresh temp directory. It prints only the four keys above and refuses any other; setup reads the identity with the same lookup and passes it to provisioning as --git-identity.

  • Sandboxes.ps1 install-helper installs the copy, outside the checkouts and the worktree base.
  • Sandboxes.ps1 setup sets the secrets, and status lists them by name (owners-workstation.md).

The helper's key stays SBX_GEMINI_API_KEY, the same name as on the Linux host, where a bare GEMINI_API_KEY in the token file would take over the owner's own agy (#632); in dev the entry may be either name.

sbx keeps each value for 55 minutes (#721). setup registers every custom secret with --refresh 55m, sbx's default for its service secrets, and replaces one registered otherwise under its placeholder. The reason:

  • On demand, the default for a custom secret, sbx runs the helper for every request within a fixed deadline that cannot be configured.
  • The helper, a pwsh cold start of 1.5 to 2.5 s from a terminal, missed that deadline under the daemon. The proxy then sent the request with no credential at all (secrets: failed to resolve custom secret, error_class: timeout in sbx's daemon.log), so Claude in the sandbox was not signed in.

The cost: a rotated or revoked token reaches the sandboxes within 55 minutes, not with the next request. After a rotation in dev, Sandboxes.ps1 refresh-secrets alone hands the new value over at once: it sets every custom secret again under its placeholder, so no sandbox has to be created again.

Reading dev. The helper runs one bws secret list at the moment sbx asks, so a rotation in dev reaches the sandboxes without anything run on the workstation. No value of dev enters HKCU or any environment that the owner's claude and gh read, and the helper never takes the owner's value of the same name from HKCU. There is no cache: a value kept between two calls would have to live in a file, and one bws call per request is cheap next to the request itself. setup and status read every value with one listing too. The helper reads three files in %LOCALAPPDATA%\claude-sandbox:

  • dev-access-token: an access token with read access to dev, encrypted for the Windows user (DPAPI). Sandboxes.ps1 dev-token stores it with hidden input, from a terminal only, after bws has accepted it. It is not BWS_ACCESS_TOKEN and not a user variable, which every process of the user would read. It reaches bws through that one process's environment, never -t.
  • sbx-token.env (optional, no secret): overrides. BWS_SERVER= replaces the default https://vault.bitwarden.eu, applied before the first bws call, so the access token never goes to Bitwarden's US cloud. PROJECT_ID= names the project; without it the project is the one the access token reads, which the listing's projectId fields tell. A token that reads no project or several, with no PROJECT_ID, gives nothing: dev-token does not store it, setup prints !! naming the projects, creates no sandbox and exits 1, status prints !! and exits 1, and the helper exits 1.
  • bws-config.toml: bws's own config for the helper, passed as --config-file with --profile sbx-token. The helper writes it itself; it holds no secret. Its profile holds server_base and state_opt_out = "true" (#636):
    • By default bws keeps a session per access token in ~/.config/bws/state and answers later calls from it without asking the server. A revoked dev token would then go on working until that session expires. With the opt-out, each call logs in instead; the state of the owner's vault.ps1 is not touched.
    • The helper passes no --server-url and clears BWS_SERVER_URL for the call: given a server URL, the released bws (up to 2.1.0) reads no config at all.
    • The value is a string because 2.1.0 refuses a TOML boolean there.

A missing access token, a revoked one or a key missing in dev makes the helper exit 1, naming the key and the missing piece (for a missing key both entries and dev); status shows it as one row, and setup leaves that secret out with a -- note and goes on. git-identity beside the helper, one line, overrides the identity of dev; SANDBOX_IDENTITY_FILE names another file.

The Anthropic sign-in is sbx's own: the owner signs in once with /login inside a sandbox, as the bot account, and sbx keeps that OAuth sign-in on the host (#753). The steps are in owners-workstation.md.

  • sbx's proxy keeps the credentials for api.anthropic.com to itself. On every request to that host it removes Authorization and x-api-key and puts in only its own anthropic credential: a garbage value, a custom secret's placeholder and a header with any other name all got the same 401 x-api-key header is required (#753, sbx v0.51.0 and v0.53.0). Other hosts are not affected. So a custom secret cannot sign Claude in there, and the earlier CLAUDE_CODE_OAUTH_TOKEN custom secret with a claude setup-token token never did.
  • sbx's anthropic credential takes an API key (sbx secret set anthropic) or an OAuth sign-in. The sign-in cannot be started from sbx secret set locally; /login in Claude Code inside a sandbox starts it. The proxy takes the token exchange, keeps the tokens on the host and refreshes them, and Claude Code in the sandbox keeps only sbx's sentinel (sk-ant-oat01-proxy-managed) in ~/.claude/.credentials.json. The sign-in is global: every sandbox uses it.
  • setup removes an anthropic API key: sbx sends it as x-api-key and prefers it to the sign-in (#626). It keeps an anthropic entry that is the sign-in, which sbx secret ls lists as (oauth configured), because sbx secret rm anthropic removes the key and the sign-in together.
  • setup removes the CLAUDE_CODE_OAUTH_TOKEN custom secret. A sandbox created with it keeps the variable, which Claude Code ranks above the sign-in, so that sandbox is created again before anyone signs in there: stop it, fetch its branches (sbx rm deletes the ones never fetched), sbx rm, setup. The helper no longer prints SBX_ANTHROPIC_OAUTH_TOKEN.
  • status shows the sign-in among the secrets and asks each running sandbox from inside with GET /v1/models, sending the credential Claude Code would use, in its order: CLAUDE_CODE_OAUTH_TOKEN (reported, not sent); then the apiKeyHelper of ~/.claude/settings.json: sbx's own echo proxy-managed is not run, its sentinel proxy-managed goes as x-api-key, and any other helper is reported and never run, since it is text from inside the VM; then the access token of ~/.claude/.credentials.json as Authorization: Bearer with anthropic-beta: oauth-2025-04-20. A value reaches curl through a config on stdin. It prints only the HTTP status and exits 1 unless the answer is 2xx or 429, or when the sandbox is not signed in or still has CLAUDE_CODE_OAUTH_TOKEN.
  • setup creates no sandbox when a secret step fails, as sandboxes.sh does (#605): sbx refuses to list the secrets, to remove a retired one or to set any secret, or the bot's token is fine-grained. A key or helper missing on the workstation is only a note, and setup goes on, as for every secret.
  • A sandbox created while an anthropic API key was set keeps the kit's apiKeyHelper in its ~/.claude/settings.json, which outranks the sign-in. Once the key is removed, the proxy refuses what it prints and status fails that sandbox: it is created again as above. A helper the kit writes for the sign-in itself passes.

The Gemini API key for agy

sandbox-provision.sh installs agy, the Antigravity CLI, in every sandbox (#632). A sandbox has no browser for Google OAuth, so provisioning sets modelProvider to gemini in ~/.gemini/antigravity-cli/settings.json, and agy reads the Gemini API key from GEMINI_API_KEY. The variable alone does nothing without that setting. The key bills the Gemini API account that issued it.

  • Model: provisioning also sets model there to Gemini 3.8 Flash (High) (AGY_MODEL in sandbox-provision.sh, #667) instead of agy's own default, Gemini 3.1 Pro. It costs about a third as much per token, and reviews are what agy is for. agy keeps the model by its label, the second column of agy models; the slug (gemini-3.8-flash-high) in settings.json resolved to Gemini 3.1 Pro (Low). A hard review escalates for one run with agy --model "Gemini 4 Argon (Medium)". A slug such as gemini-4-argon-medium may fall back the same way; agy's log (--log-file) names the model that ran in Propagating selected model override to backend: label=…. Setup puts the default back over a model chosen with /model.
  • Where it lives: in the Bitwarden project dev. On the host as SBX_GEMINI_API_KEY, which vault.sh sync writes into the token file (without the vault, set-token.sh SBX_GEMINI_API_KEY stores it there). On the workstation the helper reads it from dev itself, entry SBX_GEMINI_API_KEY, else GEMINI_API_KEY (#790).
  • Why not GEMINI_API_KEY on the host: the owner's own agy reads that name and would switch from Google OAuth to the key. The token file carries no bare GEMINI_API_KEY; only the custom secret names it, inside the sandboxes.
  • Rotate: create the new key in Google AI Studio and store it under the same name in dev. Run vault.sh refresh on the host; on the workstation nothing, or Sandboxes.ps1 refresh-secrets to hand it over at once. Then delete the old key in AI Studio. The helper reads the store whenever sbx refreshes the value, so the sandboxes follow within 55 minutes. No setup or recreate is needed.
  • Before the first key: setup leaves the secret out and says so, and provisioning reports no GEMINI_API_KEY. agy is installed all the same and exits at startup, naming the variable. Once the key is stored, setup sets the secret. It reaches only the sandboxes created after it (sbx rm and setup).

Two things surprise:

  • A custom secret reaches only the sandboxes created after it, so setup replaces one under its old placeholder.
  • The github secret is not GITHUB_TOKEN: a fine-grained token cannot read check runs, and coordinator status fails.