Prerequisites
Before you begin, make sure you have the following:- A Claude Team or Enterprise organization with self-hosted environments enabled by an Owner. See Anthropic’s prerequisites.
- A GitHub repository connected to Claude and accessible from your account. Start with a test repository. Follow the Claude Code web app documentation to connect GitHub.
- A CoreWeave API access token with the
SANDBOX_USERIdentity and Access Management (IAM) action, and serverless capacity for the resources described in this section. The recipe explicitly uses CoreWeave authentication. - A Linux or macOS computer with Git, Python 3.11 or later, and
uv
Quick start with the recipe
Create a Claude environment, deploy the orchestrator, and verify a worker’s output before stopping the deployment.Create the Claude environment
Follow Anthropic’s environment setup. On the Cloud environments admin page, an Owner enables Allow self-hosted environments and creates an environment under Self-hosted environments. An Owner creates this Claude Code cloud environment in the claude.ai admin settings. Claude Managed Agents uses a separate environment and key created in the Claude Console. Keep the environment key and itsccpool_... ID. If you can’t access the admin page, ask an Owner to provide them. The ID identifies the environment, and the key authenticates the orchestrator. The recipe deploys the orchestrator and worker infrastructure in the following steps.
Install the recipe
Install the recipe locally and configure the credentials the orchestrator requires..env file and set both variables:
Keep the
.env file private and out of version control. You can instead inject these variables from a secret manager. Existing environment variables take precedence over the .env file.
Deploy the orchestrator
Replace[ENVIRONMENT-ID] with your ccpool_... ID:
Connected after it connects to Anthropic. Setup can take several minutes. A timeout doesn’t imply cleanup. Inspect status and logs before retrying.
Keep the local .deployment.json file. It records the IDs and settings needed to manage the deployment and contains no credentials. Run subsequent commands from the recipe directory.
Send a task
In the Claude Code web app, select your organization, connected repository, and self-hosted environment. To create the file used in the verification step, send exactly this prompt:Verify the result
From your terminal, list the deployment:Connected: True and a Worker: line containing a sandbox ID. After Claude finishes, replace [WORKER-ID] in the following command with that ID:
CWS_CLOUD_OK. This checks the sandbox’s file through the Sandbox SDK, independently of Claude’s response. Read it before the worker becomes idle and stops. If you sent a different task, read a file that task created instead.
Clean up
After saving your results, stop the deployment:.deployment.json file. It interrupts running tasks and discards files stored only in those sandboxes. The Claude environment remains available for a later deployment.
How the integration works
The recipe deploys two roles:
The worker uses the Anthropic git proxy for repository access. The recipe doesn’t copy your local Claude login or GitHub token into the worker. Model requests, prompts, responses, and tool results still pass through Anthropic.
The hook follows the Anthropic on-demand runner contract: submit the workload asynchronously and use a single-use work order to register it. The recipe records order IDs on the orchestrator’s disk to avoid duplicate submissions after an orchestrator process restart. An uncertain create fails closed and requires inspection before retrying.
Workers run under a process wrapper that records the exit code and completes the sandbox without retrying the process. Check the logs after a startup failure. Sandbox completion alone doesn’t prove task success.
The recipe pins Claude Code to
2.1.284 and the Sandbox SDK to 1.14.2. Each sandbox starts from python:3.12-bookworm and installs Git and Claude during bootstrap. Worker startup includes scheduling, installation, registration, and repository checkout.
Configure the deployment
Set options when you rundeploy:
Both lifetime options accept 1 to 720 hours. The idle timeout must be at most 10,080 minutes (7 days) and shorter than the worker lifetime minus 5 minutes. For a 30-day orchestrator, add
--orchestrator-hours 720 at deployment. Lifetimes can’t be extended after creation.
Run only one recipe deployment per Claude environment. The recipe does not replace orchestrator sandboxes automatically. Its supervisor restarts the Claude Code orchestrator process within the same sandbox, preserving the local order ledger. A failed or expired sandbox loses that ledger. Monitor the deployment, save session results, and plan replacement before expiration. For a planned replacement, finish active work, run stop, and redeploy. Inspect pending sessions and existing resources before recovering from an uncertain submission or host failure.
To add a toolchain, edit the worker branch in the recipe’s bootstrap.sh script and test it with your repository. For lifecycle hooks and session configuration, see Customize sessions in self-hosted environments.
Monitor sessions
Inspect the connection, workers, and recent logs:status reports the orchestrator’s connection and approximate expiration time. After all sessions become idle and the idle timeout elapses, expect zero workers if no new sessions are queued. When capacity is available, a new session creates a worker. Follow-ups can continue on the current worker while it remains attached.
The orchestrator’s health listener stays inside its sandbox. These commands use the Sandbox SDK and require no public endpoint.
For a worker’s installation output, add --bootstrap to its log command. That log also contains Anthropic runner output after setup.
Save results before a worker stops
The Anthropic runner releases idle sessions and exits. It also starts retiring 5 minutes before its sandbox lifetime ends. A long-running turn can still reach the hard lifetime cutoff and be interrupted. Ask Claude to commit and push work you want to keep, then verify the branch in GitHub. For a text artifact, use the recipe’sread command and redirect its output to a local file. The recipe configures no automatic pushes or snapshots. A follow-up after release can run in a fresh worker, so don’t rely on unpushed files surviving.
For persistence options in other workflows, see File system snapshots. For Anthropic runner release behavior, see Anthropic’s runner reference.
Troubleshoot
If you restrict outbound traffic, account for both Anthropic runner traffic and bootstrap downloads from Debian, PyPI, and Claude’s download services. This recipe doesn’t configure an egress allowlist. For network requirements and hardening, review Anthropic’s production deployment guidance.
Next steps
Use the following resources to validate changes or explore other integrations:- Run the recipe’s offline and live checks after modifying it.
- Use Anthropic’s end-to-end tests for additional diagnostics.
- Explore other agent integrations.