Text of code.claude.com › docs › en › self-hosted-environments-deploy as Styx crawled it on Nov 20, 2026. The page may have changed since. Only its words are kept, without pictures or layout, and only the first part of a long page.

Open the live page

Deploy self-hosted environments to production - Claude Code Docs

Documentation Index Fetch the complete documentation index at: /docs/llms.txt Use this file to discover all available pages before exploring further. Skip to main content Assistant Responses are generated using AI and may contain mistakes. Self-hosted environments are in public beta on Team and Enterprise plans; Availability and limitations covers the enablement path. This page covers running the fleet in production; see the quickstart for your first runner and session.

A self-hosted environment runs Claude Code cloud sessions on runners you deploy inside your network, and in production those sessions execute model-directed code on behalf of everyone who can dispatch a session to the environment. This page is for the operator taking a working environment to production. It works through the deployment in order: what to lock down before connecting real systems, the egress the fleet needs, how sessions authenticate to your git host, the deployment recipes themselves, and what to check when sessions misbehave.

Harden your deployment A self-hosted runner executes arbitrary, model-directed code on your infrastructure on behalf of everyone who can dispatch a session to its environment. That’s any member of your Anthropic organization, and anyone who can start a Claude Tag channel session in a scope an Owner routed to the environment. Work through each item before you connect an environment to production systems: Ephemeral, per-session containers : run each runner process in a fresh container or VM that’s destroyed when the process exits, with --capacity 1 and the default --drain-grace-sec 0 so each container serves exactly one session.

At a higher capacity, or with a positive drain grace, one container serves multiple sessions from the same locked owner ; see Runner lifecycle . Don’t reuse a filesystem between runner restarts, except in the deliberate pre-warmed checkout setup, and never across owners. When the runner stops a session, it sends no signal to a process still running after its shell command exited, such as a service that daemonized. Destroying the container or VM ends that process.

No broad credentials in the image : don’t include long-lived SSH keys, cloud-provider credentials, or personal access tokens that grant more than a session needs. Mint credentials used during a session, such as push or API tokens, per session from your wrapper script . The initial clone happens before the wrapper runs, so handle it with a checkout lifecycle hook , or with --use-anthropic-git-proxy when all of a session’s repositories are on github.com.

For both, see Configure git . Keep the host’s GitHub credentials away from sessions : Claude can use any GitHub credential a session can read, with whatever access that credential grants. Keep the runner host’s own broadly scoped GitHub credentials out of anything a session can read. Such a credential can be a personal access token, the token gh auth login saves for your account, or a GH_TOKEN in the runner’s environment.

With Anthropic-managed git : with such a credential, Claude reaches GitHub directly instead of through Anthropic-managed git. Without Anthropic-managed git : a clone credential can stay in the image if you scope it as tightly as Ship git config in your image describes. Keep the environment secret off session-running hosts : the environment secret can register runners and pick up any session queued on the environment. On a fixed fleet it lives on every runner host, where any session’s code can read the secret file.

Prefer on-demand runners , where the secret stays on the orchestrator host, which never runs user code, and each runner receives a single-use work order that registers exactly one runner. On a fixed fleet, treat the environment-secret file as readable by every session and rotate the secret after any suspected session compromise. After a suspected compromise, first revoke the suspect session : before you stop its runner or revoke the secret, select Revoke token in the session’s menu on the Activity tab.

No runner can then resume it. Then replace the secret : have an Owner create a new secret and revoke the old one from the environment’s Configuration tab, then roll out the new one. Anthropic refuses every orchestrator and runner on the old secret, on-demand runners from its work orders included. Your runners exit, interrupting their sessions. Default-deny network egress : restrict runner and session container outbound traffic at your own network boundary on every environment; Default-deny egress covers what to allow and why.

Least-privilege host IAM : the compute identity attached to the runner host, such as an instance profile or node service account, should grant only what the runner itself needs. Sessions should obtain their own credentials through your wrapper script rather than inheriting the host’s. Block the cloud metadata endpoint from sessions : keeping sessions off the host identity requires blocking their access to the cloud metadata endpoint, and subnet-level egress policies don’t intercept link-local metadata traffic, so block it in the container itself: IMDSv2 with a hop limit of one GKE Workload Identity with metadata concealment An explicit deny for 169.254.169.254 in the session container’s network namespace The block applies to your wrapper script and lifecycle hooks too, since they share the container.

Authenticate any token exchange with the session JWT against your own token service over allowlisted egress, or use a file-based web identity such as IAM Roles for Service Accounts (IRSA) on Amazon EKS. Per-runner filesystem isolation : each runner process gets its own working directory that no other process on the host can read or write. Make --hooks-dir , the wrapper script, and the host’s ~/.claude/ read-only to the session, either built into the image or mounted read-only.

Dispatch has no per-environment access control : any member of your Anthropic organization can dispatch a session to any of its environments. If an Owner routes Claude Tag channels to the environment , anyone the Claude Tag access setting admits can start channel sessions that run there. By default that’s anyone in the connected Slack workspace, with or without a Claude account. Treat every runner host as reachable for code execution by everyone who can dispatch to it, and place on a runner host only data and credentials that all of those people are allowed to read. --lock-to-account bounds which account’s sessions a given host executes, but it doesn’t narrow who can dispatch into the environment.

To make self-hosted environments the only picker option, an Owner can hide Anthropic-hosted environments for the whole organization from the Cloud environments page . Enforce the repo-settings guard : choose the guard mode with --confine-repo-settings . The default warn logs a violation and still spawns the session, enforce refuses the session, and off disables the scan. The runner scans each repository’s committed settings for: A grant that resolves outside that session’s own workspace: an additionalDirectories entry, an Edit , Write , or NotebookEdit rule in permissions.allow , or a sandbox.filesystem.allowWrite or allowRead entry A non-empty env block An operator-posture override such as sandbox.enabled: false The guard runs regardless of --trust-workspace , and doesn’t cover repository hooks, .mcp.json , or Bash rules; see Permissions and tool approval for where those grants belong.

If your organization has IP allowlisting enabled, add the public egress addresses of your runners and session containers to the allowlist before you start them. If you run on-demand runners , add the orchestrator host’s address too. Don’t rely on the allowlist as a network control for runner or session traffic. Apply default-deny egress at your own network boundary instead. Network requirements The runner and the session children it spawns make outbound connections to the hosts be

The rest of this page is on the live site.