Claude Code self-hosted environments: run cloud sessions on your own hosts

Claude Code self-hosted environments run cloud sessions on hosts you control. Plans, how runners work, quickstart commands, what stays local, when to use them.

By the Kipt team · Updated 24 November 2026 · 8 min read

What are Claude Code self-hosted environments?

A Claude Code self-hosted environment runs your cloud sessions on hosts your organization controls instead of on Anthropic's infrastructure. Developers still start a session from claude.ai, the mobile or desktop apps, claude --cloud or a cloud scheduled task. The difference is the environment picker: choose your environment and a runner inside your network clones the repository and does the work. Anthropic's self-hosted environments overview describes it as a public beta on Team and Enterprise plans (checked 24 November 2026).

This guide gives you the short version for deciding and the commands for a first test. It covers the three moving parts, the plan and data limits, the quickstart, and how self-hosting compares with Anthropic-hosted sessions, Remote Control and a plain terminal session.

One point first. If your team never uses cloud sessions, there is nothing to configure. A session in a terminal or IDE always runs on the developer's own machine. If you have not met cloud sessions yet, read Claude Code on the web first.

How do self-hosted environments work?

Self-hosting has three parts, according to the official overview.

Part What it is
Environment A named destination for sessions, created in claude.ai admin settings. It groups a set of runners.
Runner A program on hosts inside your network that executes sessions, like a self-hosted CI runner.
Session One Claude Code task a developer started. Each session runs as a child Claude Code process the runner spawns.

When a developer picks your environment, Anthropic's control plane puts the session on that environment's queue. A runner with free capacity claims it, clones the repository the developer chose, and starts a Claude Code process on your host. The runner uses git credentials you configure.

Every connection is outbound. The runner polls api.anthropic.com over HTTPS for work, and by default model inference goes there too. The docs state that Anthropic never connects into your network. Internal services and an internal git host are reached from inside your network.

Runners come in two styles. You can start them yourself and keep them running, or you can host the autoscaling orchestrator, a second process that starts runners as sessions queue.

What does the owner lock mean for fleet size?

A runner serves one owner at a time. The first session it picks up locks it to that session's owner, and it then runs sessions only for that owner, up to its --capacity. For a session a user starts, the owner is that user's account. The overview concludes that the minimum fleet size is the number of owners you expect to be active at once. The lock keeps checked-out code from mixing between owners.

By default the runner exits once its active sessions finish (--drain-grace-sec defaults to 0), so an orchestrator such as Kubernetes can restart it with a fresh disk.

Which plans and settings does it need?

Checked 24 November 2026 against the official pages:

Item What the docs say
Plans Public beta for Team and Enterprise organizations. Off by default.
Who enables it An Owner turns on Allow self-hosted environments on the Cloud environments admin page. Cloud sessions must be enabled first.
Zero Data Retention and HIPAA Unavailable for organizations with either applied.
Runner hosts Linux or macOS host or container. Windows is not supported as a runner host.
Claude Code version v2.1.224 or later. Earlier versions do not recognize the self-hosted-runner subcommand.
Git Git 2.24 or newer.
Billing Sessions consume your organization's Claude Code usage the same way Anthropic-hosted sessions do.

Sessions started from claude.ai/code, the mobile and desktop apps, cloud scheduled tasks and the terminal (with claude --cloud or an --environment dispatch) can run in a self-hosted environment. Claude Security and Code Review sessions do not route to them yet, and the docs say support for those two surfaces follows separately.

Repositories come from GitHub or GitHub Enterprise Server. Another git host works only for sessions started with an --environment dispatch.

Does my code leave my network?

Mostly no, with one large exception. The overview says repository checkouts, build artifacts, secrets and files a session creates or modifies stay on the machines you provision. The conversation does not: prompts, responses and tool results go to api.anthropic.com, and Anthropic stores the session transcript so you can resume from another supported surface.

If you send model requests to Amazon Bedrock or Google Cloud's Agent Platform, the conversation still goes to api.anthropic.com in the session's event stream. The control plane also stays Anthropic-hosted: orchestration, queueing and the claude.ai interface. Read the Bedrock and Vertex side in Claude Code on Bedrock and Vertex.

Two further limits matter for governance. On a runner configured for Bedrock or Agent Platform, server-managed settings and organization policies from claude.ai do not reach sessions. And the runner and the optional orchestrator honor proxy and mTLS variables such as HTTPS_PROXY and NO_PROXY.

How do I set up a first self-hosted environment?

The quickstart builds the smallest working setup: one runner on one host, serving one test session. Confirm the host is ready:

claude self-hosted-runner --help

On v2.1.224 or later this prints the runner's usage text, listing flags such as --environment-secret-file. On older versions it prints the general claude --help output, so update Claude Code first. Our Claude Code setup guide covers installation.

What is the guided setup?

If you hold an Owner role and can run an interactive session, use the guided path. Sign in with claude auth login first, using an Owner account.

claude self-hosted-runner setup

It walks you through creating the environment, starts a local runner with the secret file you save, confirms the runner registers, and writes a cheat sheet to ./runner-setup/CHEAT-SHEET.md. It does not start a test session itself. You do that at claude.ai/code.

What are the manual steps?

  1. In claude.ai admin settings, open Cloud environments. Under Self-hosted environments select New, name it, and select Create. On the second step select Copy environment key. The docs say claude.ai shows the secret once, and that it expires 365 days after creation.
  2. On the runner host, save the secret in a file only you can read, then start the runner:
mkdir -p /etc/claude
(umask 077 && cat > /etc/claude/environment-secret)
claude self-hosted-runner --environment-secret-file '/etc/claude/environment-secret' --base-dir '<writable-dir>'

Paste the secret, press Enter, then Ctrl-D for the second command. Use a directory dedicated to the runner as --base-dir, not your home directory, because the runner treats what it finds at <writable-dir>/<repo-owner>/<repo> as its own clone and can reset it. The runner logs Registered: runner_id=<runner-id> once it registers.

  1. Back on Cloud environments, the status should change from No runners deployed to Healthy within seconds.
  2. Start a session at claude.ai/code, pick your environment, and choose a public repository or one the host can clone over HTTPS without credentials. The runner logs Picked up session <session-id>.

Started this way the runner exits after serving one session, so start it again each time. To message a running session from any machine where you have run claude auth login:

claude -p "your message" --cloud <session-id>

What do the runner flags control?

The reference page is the authority. Run claude self-hosted-runner --help for the list on your installed version. These are the flags most people touch first, with the defaults the reference states.

Flag What it does Default
--environment-secret-file <path> File holding the environment secret Required
--base-dir <path> Directory for checkouts and per-session working directories /workspace
--capacity <n> Maximum concurrent sessions, all for the same locked owner 1
--drain-grace-sec <n> Seconds to keep polling for the locked owner after sessions finish 0
--exec-path <path> Binary or wrapper script to spawn for each session The runner's own binary
--hooks-dir <path> Directory of lifecycle hook scripts Unset
--retire-at <epoch-seconds> Retire the runner at a known kill time Unset
--confine-repo-settings <mode> warn, enforce or off for repository settings that reach outside the workspace warn

Use the same --base-dir and --capacity on every runner in an environment. The reference also documents a /healthz health endpoint, Prometheus metrics and an orchestrator subcommand with its own flags, such as --hook-timeout and --min-idle.

What should I check before connecting real repositories?

The deploy page is the hardening guide. The runners execute model-directed code on your infrastructure for anyone who can dispatch a session to the environment, so treat that as the threat model. These points come from its hardening section, which you should read in full before production:

  • Run each runner in a fresh container or VM with --capacity 1 and the default --drain-grace-sec 0, so one container serves one session.
  • Do not bake SSH keys, cloud credentials or personal access tokens into the image. Mint per-session credentials from a wrapper script.
  • Keep host GitHub credentials away from sessions, since a session can use any GitHub credential it can read.
  • Protect the environment secret. Prefer on-demand runners over a fixed fleet where every host holds it.
  • Default-deny egress at your own network boundary, and give hosts least-privilege IAM.
  • Block the cloud metadata endpoint from sessions inside the container itself, for example IMDSv2 with a hop limit of one, GKE Workload Identity with metadata concealment, or an explicit deny for 169.254.169.254.
  • Remember that dispatch has no per-environment access control: any member of your Anthropic organization can send a session to any of its environments, so keep only data that all of them may read on a runner host.
  • Consider --confine-repo-settings enforce to refuse sessions whose committed settings try to escape the workspace.

For the Claude settings side of safe automation, see Claude Code permissions and Claude Code sandboxing.

Should I self-host, or use hosted sessions, Remote Control or a local terminal?

Anthropic's own advice is that most teams are better served by Anthropic-hosted environments, which need no infrastructure. Self-hosting is for teams whose network, tooling or compliance needs call for session execution on infrastructure they control. You then own the runner image, the fleet and its network.

Option Where code runs Who operates it Pick it when
Anthropic-hosted cloud session Anthropic's infrastructure Anthropic You want no infrastructure to run
Self-hosted environment Runners in your network Your organization Sessions must reach internal services, use custom tooling or keep checkouts on your hosts
Remote Control Your own always-on machine You You want to drive your own machine from other devices
Local terminal or IDE The developer's machine The developer Day-to-day work with your own checkout

The docs name three reasons to self-host: network access to internal services and registries, custom tooling pre-installed in the runner image, and compliance control over checkouts and build artifacts. Session content still goes to api.anthropic.com. For wider team rollout questions see Claude Code for enterprise, and for cloud scheduled tasks see Claude Code scheduled tasks.

Where do prompts and skills fit in?

Self-hosting changes where sessions run, not how you write prompts. A task prompt for a cloud session is still a prompt, so keep the ones that work. Kipt stores prompts and Agent Skills as Markdown in your own GitHub repo, which suits instructions a team reuses across local and cloud sessions. Nothing in the self-hosted docs depends on it.

Questions

A self-hosted environment runs Claude Code cloud sessions on infrastructure your organization operates, using runner programs you deploy inside your network. Developers start sessions from the same places as before, such as claude.ai/code, and pick your environment from a picker. As of 24 November 2026 the feature is in public beta.

Team and Enterprise plans, in public beta. The feature is off by default: an Owner turns on Allow self-hosted environments on the Cloud environments admin page, and cloud sessions must be enabled for the organization. It is unavailable with Zero Data Retention or the HIPAA configuration.

Repository checkouts, build artifacts, secrets and files a session creates stay on the machines you provision. The conversation itself, including prompts, responses and tool results, goes to api.anthropic.com, and Anthropic stores the session transcript. Anthropic never connects into your network.

Self-hosted environments run cloud sessions on a fleet of runners that your organization manages, started from claude.ai and other cloud surfaces. Remote Control is for running Claude Code on your own always-on machine and driving it from other devices, and it is also available on Pro, Max and Ultra plans.

Install Claude Code v2.1.224 or later on a Linux or macOS host, then run claude self-hosted-runner with --environment-secret-file pointing at the environment secret and --base-dir pointing at a writable directory. The quickstart also offers claude self-hosted-runner setup as a guided path.

More in Claude Code

All guides

Your prompts and skills, one keystroke away.

Explore

Use it from your agent.

Save it to Kipt, in your own GitHub, then ask your agent for it by name while you work.

  • Claude Code
  • Codex
  • Cursor
  • VS Code
  • Claude
  • ChatGPT
  • Gemini CLI
  • Windsurf
  • and any MCP client
Get started