How to run Claude Code 24/7 in the cloud without managing a VPS

When your laptop sleeps, local coding agents stop. You can move Claude Code to the cloud without maintaining a Linux VPS, but the right choice depends on whether you run isolated tasks or need an always-on workspace.

Quick answer and decision checklist

You can run Claude Code in the cloud without managing a VPS by using Anthropic's hosted cloud sessions, CI runners like GitHub Actions, cloud dev environments like GitHub Codespaces, programmatic AI sandboxes, or a managed always-on workspace like AlwaysAgent. None of these require you to configure SSH keys, firewalls, or operating system updates, though they differ sharply in how long they stay awake and what they retain between runs.

Before picking a platform, answer four questions about your workflow:

  • Is the job a run-to-completion task or an always-on workspace? If you want an agent to fix a single issue, open a pull request, and exit, task runners and CI workflows fit well. If you want an interactive environment that stays open between coding sessions with your files and processes intact, you need a persistent machine.
  • Do you have a claude.ai subscription? Anthropic's built-in cloud sessions require a paid claude.ai subscription (Pro, Max, Ultra, Team, or Enterprise with qualifying seats).
  • Do you use an API key, a gateway, or other models? Anthropic's cloud sessions do not accept Anthropic Console API keys or third-party providers. If you pay per token via ANTHROPIC_API_KEY, route through OpenRouter or an LLM gateway, or also run OpenAI Codex, you need an environment where you control the CLI credentials.
  • Do you need custom toolchains, databases, or long-running processes? Ephemeral sandboxes and CI jobs start from a fresh clone or template and shut down when the task ends or a timer expires. Running local databases, background watchers, or preview servers 24/7 requires persistent compute and storage.

1. Anthropic cloud sessions & scheduled tasks (Best for subscription users on GitHub)

Anthropic offers built-in cloud execution through Claude Code on the web and cloud scheduled tasks, allowing you to hand off repository tasks without running anything on your own computer.

How it works

Per Anthropic's documentation, a cloud session runs on infrastructure Anthropic manages rather than on your local machine. The session continues running after you close your laptop, and you can monitor or steer it from a browser at claude.ai/code, the Code tab in the Claude mobile app, the Desktop app, or the terminal via claude --cloud.

For recurring or automated background work, Anthropic provides cloud scheduled tasks (formerly called routines, currently in research preview). Scheduled tasks launch autonomous cloud sessions on a recurring cadence (custom cron expressions that run more often than once per hour are rejected), on demand via a dedicated HTTP POST API trigger, or in response to GitHub repository events such as pull requests or releases. Anthropic also offers Projects (public beta on select plans), where Claude coordinates multiple parallel cloud sessions from one conversation.

(Note: Do not confuse cloud sessions with Anthropic's Remote Control feature. Per the documentation, Remote Control is only a window into a local session, so "your computer has to stay on and the claude process has to keep running".)

What you need

  • A Pro, Max, Ultra, or Team plan, or an Enterprise account with premium seats or Chat + Claude Code seats (plus the cloud sessions permission if your organization uses custom roles).
  • A connected GitHub account (or GitHub Enterprise Server on Team and Enterprise plans) so the cloud environment can clone repositories and push branches.
  • A configured cloud environment if you need custom environment variables, network access levels, or startup setup scripts.

Limits

  • Duration and idle behavior: Per Anthropic's docs, an idle session's VM pauses with its files saved, and cloud sessions stop after a period of inactivity, after which the VM is reclaimed. You can reopen the session from claude.ai/code to provision a fresh VM; your conversation history is restored, but background work that was still running (shell commands, subagents, session-scoped scheduled tasks) is not.
  • State persistence: According to Anthropic's docs, "Cloud sessions start from a fresh clone of your repository. Anything you commit to the repo is available. Anything you've installed or configured only on your own machine isn't available in the session." In Projects, Anthropic notes that if a thread's sandbox cannot be resumed, the thread continues from a fresh clone, so uncommitted changes can be lost.
  • Authentication and models: Cloud sessions require a claude.ai account. Anthropic states they "aren't reachable with an Anthropic Console API key or from a third-party provider such as Amazon Bedrock".
  • Billing: Cloud sessions and scheduled tasks count toward your Claude plan's usage limits alongside your other usage, with "no separate charge for the cloud VM".

2. Claude Code GitHub Actions (Best for PR & event-driven automation)

If your goal is to have Claude Code respond to repository events, triage issues, or review and write pull requests automatically, Claude Code GitHub Actions runs the agent inside your CI pipeline.

How it works

You add the anthropics/claude-code-action step to a GitHub Actions workflow file (.github/workflows/claude.yml). Whenever a matching GitHub event occurs—such as an @claude mention in an issue or pull request comment, an opened PR, or a cron schedule—the workflow runs on a GitHub Actions runner, where Claude Code works on the prompt and can push commits or post a reply.

What you need

  • Admin access to a GitHub repository to install the Claude GitHub App (granting read and write permissions for Contents, Issues, and Pull requests) and configure repository secrets.
  • Either an ANTHROPIC_API_KEY from the Claude Console or a CLAUDE_CODE_OAUTH_TOKEN generated from a Pro, Max, Ultra, Team, or Enterprise subscription using claude setup-token. You can also configure OpenID Connect (OIDC) to route inference through Amazon Bedrock, Google Cloud's Agent Platform, or Microsoft Foundry.
  • Quick setup via /install-github-app inside Claude Code, or manual workflow file setup.

Limits

  • Duration cap: On standard GitHub-hosted runners, GitHub documentation specifies that each workflow job can run for a maximum of 6 hours of execution time; if a job reaches this limit, it is terminated. (Self-hosted runners allow up to 5 days of job execution.)
  • Idle behavior and state persistence: CI runners are ephemeral and non-interactive. Each GitHub-hosted runner job starts in a fresh environment. Nothing persists outside of what is committed to Git or uploaded as a workflow artifact.
  • Billing: You pay for model usage (via your API key, cloud provider, or subscription token) plus GitHub Actions runner compute. See GitHub's Actions billing documentation for current pricing and included minutes.

3. GitHub Codespaces (Best for interactive cloud IDE sessions)

Managed cloud development environments like GitHub Codespaces give you a container-backed Linux environment in your browser or VS Code where you can install and run the Claude Code CLI just as you would locally.

How it works

When you create a codespace on a repository, GitHub provisions a virtual machine running a dev container with your repository checked out. You open a terminal in the browser client or connect via VS Code, install the Claude Code CLI, sign in with your subscription or export ANTHROPIC_API_KEY, and run interactive coding sessions.

What you need

  • A GitHub account and a repository. Personal accounts include a monthly quota of free compute time and storage; per GitHub's docs, usage is blocked once you use up the quota unless a valid payment method is on file, and spending may be limited by budgets.
  • The Claude Code CLI installed inside the codespace (or added to your devcontainer.json so it persists across container rebuilds).

Limits

  • Idle stop policy: Codespaces is designed to stop when you step away. According to GitHub's documentation, a codespace stops running after a period of inactivity—by default, 30 minutes. Per GitHub's docs, you can change the timeout in your personal settings (between 5 and 240 minutes), and interaction such as typing or using the mouse, as well as terminal input or output, resets the idle timer.
  • Hard duration cap: GitHub's docs state unambiguously: "Regardless of your idle timeout setting, a codespace has a maximum lifetime of 12 hours." This means a codespace cannot run continuously beyond that limit.
  • State persistence: When a codespace stops, "any running processes are stopped," though saved changes and terminal history are preserved for the next time you start it.
  • Billing: Active codespaces bill for compute in core hours (active duration multiplied by the machine type's core multiplier), and storage is billed for as long as a codespace exists.

4. AI agent sandbox platforms (Best for developers building custom agent apps)

If you are writing your own orchestration code in Python, TypeScript, or Go and want to spawn isolated Linux environments via SDK to execute Claude Code or custom agents programmatically, several infrastructure platforms specialize in agent sandboxes.

How it works

Instead of logging into a workstation yourself, your application calls an API or SDK to boot a container or microVM, injects credentials, runs commands over a programmatic shell or SSH gateway, and pauses or destroys the sandbox when done. Four documented options include:

  • E2B: Provides isolated microVM sandboxes controlled via Python and JavaScript/TypeScript SDKs. You create a sandbox with Sandbox.create(), run commands, and either kill it or pause it. Pausing a sandbox saves both its filesystem and memory state, and per E2B's docs "a paused sandbox is kept indefinitely" until you kill it, which permanently deletes it.
  • Daytona: Offers sandboxes that run as Linux containers by default, with VM sandboxes as a separate option; VM sandboxes support pause/resume and memory snapshots, per Daytona's docs. Sandboxes can be managed via SDK, CLI, API, or SSH.
  • Modal Sandboxes: Provides secure containers for running untrusted or LLM-generated code, with Python, JavaScript, and Go SDKs. Volumes can be mounted in Sandboxes, and Filesystem Snapshots can preserve state for runs that need to continue past the maximum lifetime. Exit Snapshots capture the filesystem when a Sandbox exits; check Modal's docs for how long they are retained.
  • Fly.io Machines: Fast-launching VMs driven by a REST API or the flyctl CLI. A Machine's root filesystem is ephemeral, so any data you want to keep belongs on an attached Fly Volume (a slice of an NVMe drive on the same physical server as the Machine).

What you need

  • Custom integration code using the platform's SDK or API, plus custom templates or Docker images with Claude Code installed.
  • Programmatic secret injection (such as passing ANTHROPIC_API_KEY via environment variables or platform secret managers).

Limits

  • Duration caps and idle timeouts: In E2B, sandboxes can run continuously for up to 24 hours on Pro or 1 hour on Hobby. In Modal, Sandboxes have a default maximum lifetime of 5 minutes, accept a timeout of up to 24 hours, and can be configured with an idle_timeout. In Daytona, sandboxes have idle-based lifecycle settings; Daytona's SSH documentation notes that a long-running command that produces output without further input does not reset the idle clock.
  • State persistence nuances: Persistence differs by platform and sandbox type, so check each provider's lifecycle documentation for what survives a stop, pause, or delete.
  • Billing: These platforms use usage-based billing. For example, E2B bills running sandboxes per second for provisioned CPU and RAM.

5. AlwaysAgent (Best for a plug-and-play 24/7 server in your browser)

If you want a persistent Linux machine that stays online 24/7 so Claude Code and background services never stop, but you do not want to manage a raw VPS yourself, AlwaysAgent provides a preconfigured server behind a browser workspace.

How it works

Each user gets a dedicated cloud Linux server with its own public IP address and both Claude Code and OpenAI Codex preinstalled. You access the server through a workbench in your computer or phone browser—which includes AI chat, a file manager, a terminal, remote browser preview, and version history—without installing an app or configuring SSH. When you close your browser tab or shut your laptop, the server remains online 24/7 and your tasks continue running.

What you need

  • An AlwaysAgent account and your own model credentials. In the workspace settings, you enter your own Base URL and API Key—supporting official Anthropic or OpenAI keys, third-party relays, domestic model APIs, or OpenRouter. Your keys are stored only on your own server; the platform does not proxy AI calls, add markup, or resell model quota.

Limits

  • Duration and state: The server stays online 24/7. Your files, installed packages, databases, and running processes persist on your server across sessions, and monthly plans include automatic daily snapshots.
  • Billing: Hourly trials require a minimum $10 top-up and bill at approximately $0.05/hour; billing continues even if the server is powered off and stops only when you delete the server (unspent balance within 14 days of top-up is refundable minus processing fees). Monthly plans with unlimited bandwidth auto-renew and can be canceled anytime: Starter at $9.9/mo (2 vCPU, 4 GB RAM, 40 GB disk), Developer at $17.9/mo (4 vCPU, 8 GB RAM, 75 GB disk), Pro at $24.9/mo (6 vCPU, 12 GB RAM, 100 GB disk), and Power at $44.9/mo (8 vCPU, 24 GB RAM, 200 GB disk). Hourly servers can be converted to monthly plans in one click with data migrated.

If you are comfortable handling SSH hardening, firewall rules, and tmux yourself, see our tutorial on setting up Claude Code on your own VPS.

Comparison of cloud options for Claude Code

Use the table below to match your requirements against how each cloud runtime behaves.

Option Always-on 24/7 State persists Needs Claude subscription API key / other models Runs your own tools & services Setup effort Billing model
Anthropic Cloud Sessions No (runs per task; stops after inactivity) Partly (starts from a fresh Git clone; idle VMs pause, then may be reclaimed) Yes (Pro, Max, Ultra, Team, Enterprise) No (claude.ai account only) Via setup scripts in cloud environment Low (connect GitHub) Included in plan usage limits
Claude Code GitHub Actions No (6h max per job on hosted runners) No (ephemeral CI runner) Optional (OAuth token or API key) Yes (API key, Bedrock, Google Cloud, Foundry) Within CI job duration Low (/install-github-app or YAML) CI compute minutes + model usage
GitHub Codespaces No (30m default idle stop; 12h max lifetime) Yes (saved changes kept across stops; processes stop) Optional Yes (full CLI control) Yes (while active) Low (browser or VS Code) Core hours while active + storage
AI Agent Sandboxes (E2B, Modal, Daytona) No (e.g., 24h max continuous on E2B Pro; Modal timeouts up to 24h) Varies (pause/resume, volumes, or snapshots, depending on platform) Optional Yes (inject via SDK/env) Yes (inside sandbox limits) High (requires SDK code & templates) Usage-based (e.g., per-second compute)
AlwaysAgent Yes (dedicated 24/7 Linux server) Yes (full disk & running processes) No Yes (BYO API key, Base URL, OpenRouter, Codex) Yes (dedicated server + public IP) Low (ready in browser tab) ~$0.05/h or $9.9–$44.9/mo + your own API usage

What to check before you pick

Cloud platforms use the words "background" and "persistent" differently. Verify these six details before committing your workflow:

  1. Maximum session duration: Check if the platform enforces a hard wall-clock ceiling. GitHub-hosted Actions jobs terminate at 6 hours, GitHub Codespaces have a 12-hour maximum lifetime regardless of the idle timeout setting, E2B Pro caps continuous runtime at 24 hours, and Modal Sandboxes accept timeouts up to 24 hours. Only an always-on server runs indefinitely without a hard reset.
  2. Idle timeout rules: Find out what triggers an automatic shutdown. In Codespaces, the default is 30 minutes of inactivity. In Daytona over SSH, a long-running command that only prints output does not reset the idle timer without client input. If your agent pauses to wait for an approval prompt, an idle timer may stop the environment mid-task.
  3. Filesystem vs. process persistence: Keeping files on disk is not the same as keeping processes in memory. Stopping a Codespace or using a Modal Exit Snapshot preserves your files, but stops running processes. Anthropic's cloud sessions restore conversation history after expiry but not background work, and start from a fresh clone of your repository. E2B's memory+filesystem pause and always-on servers keep both files and running processes.
  4. Where credentials live and what they unlock: If you rely on ANTHROPIC_API_KEY, a custom ANTHROPIC_BASE_URL gateway, or OpenRouter, Anthropic's hosted cloud sessions will not work. Make sure your chosen runtime lets you store environment secrets on the machine or in repository secrets without routing your keys through an untrusted proxy.
  5. How idle vs. active billing works: Codespaces bills compute while a codespace is active and storage for as long as it exists, and E2B bills running sandboxes per second; check each provider's pricing for paused or stopped states. AlwaysAgent hourly servers bill until you delete the server, even when powered off.
  6. Mobile access when you are away: If you want to check progress or approve edits from your phone, check the client interface. Anthropic cloud sessions work in the Claude iOS/Android app (terminal-only commands such as /plugin and /resume are unavailable in cloud sessions), GitHub Actions workflows can be triggered by @claude comments on issues and pull requests, and AlwaysAgent provides its full workbench directly in a mobile web browser without installing an app. For a deeper comparison between Anthropic's hosted cloud and a dedicated server workspace, read Claude Code Cloud vs. AlwaysAgent.

FAQ

Can I run Claude Code in the cloud without a VPS?
Yes. You can use Anthropic's hosted cloud sessions at claude.ai/code, automate repository tasks with Claude Code GitHub Actions, run the CLI inside GitHub Codespaces, build on programmatic sandboxes like E2B or Modal, or use a preconfigured browser-based server like AlwaysAgent. None of these require manual Linux server administration.
Does Anthropic's Claude Code on the web work with an API key?
No. According to Anthropic's documentation, cloud sessions at claude.ai/code require a paid claude.ai subscription (Pro, Max, Ultra, Team, or qualifying Enterprise seats) and cannot be used with an Anthropic Console API key or third-party providers like Amazon Bedrock. To use an API key or a custom base URL in the cloud, use GitHub Actions, Codespaces, an agent sandbox, or AlwaysAgent.
Why does Claude Code stop when I use GitHub Codespaces?
GitHub Codespaces stops running after a period of inactivity (30 minutes by default) and enforces a hard maximum lifetime of 12 hours regardless of your timeout setting. When a codespace stops, running processes—including Claude Code—are stopped, though saved changes are kept for your next session.
What is the difference between Anthropic's Remote Control and cloud sessions?
Cloud sessions run on infrastructure managed by Anthropic, so they keep working when you turn off your computer. Remote Control connects the Claude mobile app or browser to a Claude Code process running on your own machine; per Anthropic's docs, your computer must stay on and the local claude process must stay running for Remote Control to work.
How can I schedule Claude Code to run recurring tasks in the cloud?
You have three main options that do not require your computer to stay on: Anthropic's cloud scheduled tasks (which run on a schedule, via HTTP API, or on GitHub events; recurring runs more often than once per hour are not accepted), Claude Code GitHub Actions triggered by a cron schedule in your workflow YAML, or a cron job / background process on an always-on server such as AlwaysAgent.
Do cloud sessions keep my uncommitted files and installed packages?
In Anthropic's cloud sessions, each session starts from a fresh clone of your GitHub repository; an idle session's VM pauses with files saved but can later be reclaimed, in which case reopening provisions a fresh VM. Commit and push work you want to keep. If you need uncommitted files, local databases, and custom packages to stay in place permanently without rebuilding, use a persistent server workspace like AlwaysAgent.

Need an always-on workspace right now?

AlwaysAgent gives you a dedicated Linux server with Claude Code and OpenAI Codex preinstalled in a browser tab. No SSH keys, no firewall setup, and your tasks keep running when you close your laptop.

Try it for $0.05/h →