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
~/.profileexports it into login shells, so aclaudestarted over SSH has the home session's tokens (linux-host.md).
Three keys are the exception:
GITHUB_TOKENandGH_TOKENreach neither login shells nor the home session.ghwould prefer them to its own login, so the~/.profileblock skips them and the home unit unsets them (#304).ANTHROPIC_API_KEY, whichvault.sh syncwrites 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 refreshruns that sync at once and showsvault.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-syncis the hourly sync, run throughconhost.exe --headlessso no terminal window opens (#841);vault.ps1 taskregisters it again after each dev-env update; vault.ps1 refreshruns it at once and showsvault.ps1 check;- a janitor
vault_syncentry 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 answersLogin expired · Please run /login; Remote Control disconnects.sbx secret lsstill listsanthropic (oauth configured). - Renewing:
sbx exec -it <sandbox> claude, then/loginas 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/loginruns in it too, once per such sandbox. - Who warns:
sandboxes.sh(status, Linux) andSandboxes.ps1(status, Windows) ask each running sandbox from inside withGET /v1/modelsand 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 reachescurlthrough a config on stdin; only the HTTP status and the time leave the VM.ops-patrolon the Linux host pushessignin:<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:watchreads 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-helperinstalls the copy, outside the checkouts and the worktree base.Sandboxes.ps1 setupsets the secrets, andstatuslists 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
pwshcold 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: timeoutin sbx'sdaemon.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 todev, encrypted for the Windows user (DPAPI).Sandboxes.ps1 dev-tokenstores it with hidden input, from a terminal only, afterbwshas accepted it. It is notBWS_ACCESS_TOKENand not a user variable, which every process of the user would read. It reachesbwsthrough that one process's environment, never-t.sbx-token.env(optional, no secret): overrides.BWS_SERVER=replaces the defaulthttps://vault.bitwarden.eu, applied before the firstbwscall, 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'sprojectIdfields tell. A token that reads no project or several, with noPROJECT_ID, gives nothing:dev-tokendoes not store it,setupprints!!naming the projects, creates no sandbox and exits 1,statusprints!!and exits 1, and the helper exits 1.bws-config.toml:bws's own config for the helper, passed as--config-filewith--profile sbx-token. The helper writes it itself; it holds no secret. Its profile holdsserver_baseandstate_opt_out = "true"(#636):- By default
bwskeeps a session per access token in~/.config/bws/stateand answers later calls from it without asking the server. A revokeddevtoken would then go on working until that session expires. With the opt-out, each call logs in instead; the state of the owner'svault.ps1is not touched. - The helper passes no
--server-urland clearsBWS_SERVER_URLfor the call: given a server URL, the releasedbws(up to 2.1.0) reads no config at all. - The value is a string because 2.1.0 refuses a TOML boolean there.
- By default
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.comto itself. On every request to that host it removesAuthorizationandx-api-keyand puts in only its ownanthropiccredential: a garbage value, a custom secret's placeholder and a header with any other name all got the same401 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 earlierCLAUDE_CODE_OAUTH_TOKENcustom secret with aclaude setup-tokentoken never did. - sbx's
anthropiccredential takes an API key (sbx secret set anthropic) or an OAuth sign-in. The sign-in cannot be started fromsbx secret setlocally;/loginin 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. setupremoves ananthropicAPI key: sbx sends it asx-api-keyand prefers it to the sign-in (#626). It keeps ananthropicentry that is the sign-in, whichsbx secret lslists as(oauth configured), becausesbx secret rm anthropicremoves the key and the sign-in together.setupremoves theCLAUDE_CODE_OAUTH_TOKENcustom 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 rmdeletes the ones never fetched),sbx rm,setup. The helper no longer printsSBX_ANTHROPIC_OAUTH_TOKEN.statusshows the sign-in among the secrets and asks each running sandbox from inside withGET /v1/models, sending the credential Claude Code would use, in its order:CLAUDE_CODE_OAUTH_TOKEN(reported, not sent); then theapiKeyHelperof~/.claude/settings.json: sbx's ownecho proxy-managedis not run, its sentinelproxy-managedgoes asx-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.jsonasAuthorization: Bearerwithanthropic-beta: oauth-2025-04-20. A value reachescurlthrough 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 hasCLAUDE_CODE_OAUTH_TOKEN.setupcreates no sandbox when a secret step fails, assandboxes.shdoes (#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, andsetupgoes on, as for every secret.- A sandbox created while an
anthropicAPI key was set keeps the kit'sapiKeyHelperin its~/.claude/settings.json, which outranks the sign-in. Once the key is removed, the proxy refuses what it prints andstatusfails 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
modelthere toGemini 3.8 Flash (High)(AGY_MODELinsandbox-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 ofagy models; the slug (gemini-3.8-flash-high) insettings.jsonresolved to Gemini 3.1 Pro (Low). A hard review escalates for one run withagy --model "Gemini 4 Argon (Medium)". A slug such asgemini-4-argon-mediummay fall back the same way; agy's log (--log-file) names the model that ran inPropagating 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 asSBX_GEMINI_API_KEY, whichvault.sh syncwrites into the token file (without the vault,set-token.sh SBX_GEMINI_API_KEYstores it there). On the workstation the helper reads it fromdevitself, entrySBX_GEMINI_API_KEY, elseGEMINI_API_KEY(#790). - Why not
GEMINI_API_KEYon the host: the owner's ownagyreads that name and would switch from Google OAuth to the key. The token file carries no bareGEMINI_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. Runvault.sh refreshon the host; on the workstation nothing, orSandboxes.ps1 refresh-secretsto 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:
setupleaves the secret out and says so, and provisioning reportsno GEMINI_API_KEY.agyis installed all the same and exits at startup, naming the variable. Once the key is stored,setupsets the secret. It reaches only the sandboxes created after it (sbx rmandsetup).
Two things surprise:
- A custom secret reaches only the sandboxes created after it, so
setupreplaces one under its old placeholder. - The
githubsecret is notGITHUB_TOKEN: a fine-grained token cannot read check runs, andcoordinator statusfails.