Cloud environments: inject "Environment variables" into the Setup script
Summary
In Claude Code cloud environments (claude.ai/code), values entered in the Environment variables field are not available to the Setup script at the time it runs. This forces secrets needed during setup to be duplicated inline as export statements in the setup script, which doubles the secret surface and creates operational risk.
Current behavior
When configuring a cloud environment, the modal exposes two distinct fields:
- Environment variables — a key/value list, presented as the canonical place for secrets.
- Setup script — a bash script that runs at session start to install dependencies, configure tooling, register MCP servers, etc.
The values from (1) are not injected into the shell that runs (2). Anything the setup script needs at install time (auth tokens for private package installs, API keys for MCP server registrations that require an Authorization header at registration time, etc.) has to be hard-coded inline at the top of the setup script.
Why this is a problem
- Doubled secret surface. The same token has to be pasted into two places. The setup script content is visible to anyone with access to the cloud environment settings page.
- Re-paste hazard. Re-pasting the setup script (e.g. when updating it) silently resets the inline secrets to placeholders. Users who don't notice end up with a broken environment.
- Audit/rotation friction. Rotating a credential means updating two fields per environment, with no single source of truth.
Proposed behavior
Run the Setup script with the values from the Environment variables field already exported into its shell — the same way they're injected into the routine session itself.
This matches user expectations: most people assume "environment variables" means "available in the environment, including during setup". It would let users keep all secrets in the env-vars field with no inline duplication.
Environment
- Claude Code cloud environments at https://claude.ai/code (project view → cloud icon → Add cloud environment)
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗