The Era of Automatic Setup in Claude Code Cloud Sessions: Dependencies and API Keys Are Now Managed Autonomously
Originally published in Turkish. Read the original →

The new automatic environment setup Anthropic added to Claude Code cloud sessions autonomously discovers project dependencies and network access rules, while its agent proxy architecture provides top-tier security by fully isolating API keys from the AI model.
As the use of autonomous AI agents in software development spreads quickly, one of the biggest operational bottlenecks engineering teams face is the initial setup of remote working environments. When you hand a code repository over to a cloud-based AI agent, choosing the right runtime versions, installing package managers, preparing build tools and defining outbound network access permissions often requires tedious preparation. With a new architectural update announced for Claude Code, its terminal and cloud-based autonomous coding agent, Anthropic is removing this setup burden. Claude Code cloud sessions can now autonomously configure the virtual machine environment, dependency tree and secure API connections a project needs.
Made available by the Anthropic engineering team on the Pro, Max, Ultra, Team and Enterprise plans, this new infrastructure removes the need to write manual setup scripts for coding sessions started in the cloud, while also enabling deterministic customization through CLAUDE.md and .claude/settings.json and zero-trust API key isolation based on an Agent Proxy.
Autonomous Environment Discovery and Filesystem Snapshot Caching
In traditional CI/CD pipelines or cloud development containers, the developer has to prepare a detailed Dockerfile or devcontainer.json in advance for the project to come up. The new Claude Code cloud automatic setup mechanism instead clones the repository into an isolated micro-VM when a cloud session starts and runs the static and dynamic analysis process itself.
In the first stage, the agent scans the package manifest files in the repository root and submodules (package.json, pnpm-lock.yaml, requirements.txt, pyproject.toml, Cargo.toml, go.mod, Makefile). It identifies on its own all the system libraries needed to build the project, run linter checks and execute unit tests, and runs the installation commands. It also inspects the external service calls in the codebase to determine the required network access scopes and external API key requirements.
To avoid downloading hundreds of packages from scratch in every session in large monorepo projects, Anthropic added a persistent environment caching (filesystem snapshot caching) layer to the system. When Claude Code successfully completes the setup of a repository, it saves the virtual machine's filesystem state as a snapshot. Thanks to this cache, which is kept warm for about 7 days, all subsequent sessions started from the web interface (claude.ai/code), the desktop app, the mobile app or the terminal open with a ready environment within seconds:
claude --cloud
# Trigger an existing task to run autonomously in the cloud environment
claude --cloud "Update the JWT validation tests in the auth module and open a PR"
# Check local environment and connection health
claude doctor
CLAUDE.md Configuration for Cloud Sessions
When Claude Code runs on a cloud virtual machine, it cannot access the global ~/.claude/CLAUDE.md file or local MCP servers on the developer's own computer. That is why it is critical to keep a version-controlled CLAUDE.md file in the repository root, so the cloud agent correctly understands the project's architectural rules, custom build flags and environment requirements from the very first second.
A technical CLAUDE.md example that guides the autonomous setup mechanism can be structured like this:
# Project Architecture and Cloud Environment Guide (CLAUDE.md) ## Runtime and Package Manager - Node.js: v22.x LTS (should be activated via nvm or fnm) - Package Manager: Use only(do not runpnpmnpm oryarn) - Database: PostgreSQL 16 and thepgvector extension are required for local tests ## Core Commands - Install:pnpm install --frozen-lockfile - Type Check:pnpm run typecheck - Unit Tests:pnpm test --run - Database Migration:pnpm run db:migrate ## Network Access and Security Rules - Services that need outbound network access:api.stripe.com,api.openai.com,registry.npmjs.org - Never print API keys into code or test logs; all external requests are routed through the Agent Proxy.
Advanced Automation with .claude/settings.json and SessionStart Hooks
Although the autonomous discovery mechanism handles the vast majority of standard projects on its own, complex enterprise projects that require custom build steps, local database seeding or dynamic environment variables need deterministic hooks. Claude Code automatically triggers the SessionStart lifecycle hook defined in the repository's .claude/settings.json file every time a cloud session starts or is resumed (--resume).
The following .claude/settings.json configuration runs a custom setup script at the start of a session:
{
"permissions": {
"allow": [
"Bash(pnpm test:*)",
"Bash(pnpm run typecheck)",
"Bash(git status)",
"Bash(git diff:*)"
]
},
"hooks": {
"SessionStart": [
{
"matcher": "*",
"hooks": [
{
"type": "command",
"command": "bash .claude/hooks/cloud-setup.sh"
}
]
}
]
}
}
Using $CLAUDE_CODE_REMOTE and $CLAUDE_ENV_FILE
Because the .claude/settings.json file is read both on local developer machines and on cloud virtual machines, heavy setup scripts should only run in the cloud environment. For this, Anthropic provides two special environment variables at runtime:
1. $CLAUDE_CODE_REMOTE: Automatically set to "true" if the session is running in the cloud (remote sandbox).
2. $CLAUDE_ENV_FILE: Holds the path of the file used to persist the dynamic environment variables produced by the hook script into all Bash calls for the rest of the session.
An example .claude/hooks/cloud-setup.sh script using these two variables looks like this:
#!/usr/bin/env bash
set -euo pipefail
# Continue only if running on a Claude Code cloud (remote) virtual machine
if [ "${CLAUDE_CODE_REMOTE:-false}" != "true" ]; then
exit 0
fi
echo "[Claude Cloud] Remote virtual machine environment detected, verifying dependencies..."
# Install packages while sticking to the lockfile
if [ -f "pnpm-lock.yaml" ]; then
pnpm install --frozen-lockfile --prefer-offline
fi
# Save environment variables that will apply in all subshells for the session
if [ -n "${CLAUDE_ENV_FILE:-}" ]; then
{
echo 'export NODE_ENV="test"'
echo 'export NEXT_TELEMETRY_DISABLED="1"'
echo 'export PYTHONPATH="."'
} >> "$CLAUDE_ENV_FILE"
fi
echo "[Claude Cloud] Environment preparation complete."
Agent Proxy and Network Secrets: API Keys the Model Never Sees
The most critical security barrier to adopting cloud-based autonomous coding agents in enterprise architectures is protecting third-party API keys and database credentials (secrets). Giving critical keys such as STRIPE_SECRET_KEY or AWS_SECRET_ACCESS_KEY as plaintext environment variables to the virtual machine an AI agent runs on carries the risk of those keys leaking into the model's context window and the outside world through indirect prompt injection, faulty debug output (console.log(process.env)) or a malicious npm package.
To reduce this threat surface to zero in Claude Code cloud sessions, Anthropic implements an Agent Proxy and Network Secrets architecture. In this security model, neither the AI model nor the processes inside the virtual machine ever see the real API key values.
Technically, the architecture works in four layers:
* Out-of-VM Vault: The API keys the developer defines in the cloud environment settings are kept encrypted in Anthropic's control plane and are never copied into the virtual machine where the code runs. Inside the virtual machine there are only placeholder references or local proxy endpoints.
* Egress Security Proxy (Outbound Proxy): All HTTP/HTTPS traffic leaving the virtual machine for the outside world (according to the Trusted, Custom or Full network access tiers) passes through the secure Agent Proxy layer outside the virtual machine boundary.
* Domain-Scoped Header Injection: When code run by the agent sends a request to an external service (for example api.openai.com or an internal corporate API), after the packet leaves the virtual machine the Agent Proxy verifies the target domain and injects the real credential (Authorization: Bearer ... or a custom API header) into the network packet outside the virtual machine.
* GitHub Scoped Proxy: Similarly, the developer's personal access token (PAT) or SSH key never enters the virtual machine. The Git client inside the VM talks to GitHub only through a temporary, restricted proxy credential with read/write permission to the relevant repository.
As a result, even if code inside the virtual machine runs env or printenv, reads memory (a memory dump) or tries to send all environment variables to an external server, it cannot access the real API keys; and since the key is injected only for the defined target domain, stealing it by redirecting it to a different server (exfiltration) becomes technically impossible.
A Hybrid Workflow for Enterprise Engineering Teams
Claude Code's new cloud architecture, which brings together autonomous setup, 7-day filesystem caching, SessionStart hooks and Agent Proxy-based key isolation, takes standardization in software development teams to a new level. While engineers make on-the-spot architectural decisions in their local terminals, they hand off long-running refactoring tasks, multi-branch bug fixes and comprehensive integration tests to isolated cloud sessions with zero setup cost. Blending both speed and zero-trust cybersecurity principles in the same mix, this structure represents one of the most important milestones on the way to autonomous software engineering becoming standard at enterprise scale.




