← Claude Code Hub
Oct 15, 2026 · 4 min read ✦ Tip #229

Claude Code cloud setup script: why installs fail and sessions boot slow

Claude Code's cloud setup script: the network level that blocks installs, the five-minute limit that costs you the cache, and what belongs in a SessionStart hook instead.

Claude Code cloud setup script: a timeline with the roughly five-minute limit, one script that finishes in time and gets a snapshot, one that runs over and repeats every session, and the split between the setup script (machine tools) and a SessionStart hook (project dependencies)

TL;DR Keep the setup script to tools the machine doesn't ship with, and keep it under five minutes. Your project's npm install goes in a SessionStart hook that only runs in the cloud.

Update, October 31, 2026: A setup script that exits with an error no longer blocks the start: cloud sessions you open from the web, desktop or mobile app start anyway, just without whatever failed to install.

The setup script on a cloud environment runs as root on Ubuntu 24.04, before Claude Code starts. If it finishes in about five minutes, Anthropic snapshots the disk and later sessions start from that snapshot without running it again. Both problems come from that mechanism: the script that fails, and the session that takes forever to start.

The split that avoids them:

Setup script (on the environment)   machine tools          once, cached
SessionStart hook (in the repo)     project dependencies   every session

Why installs fail

If the script exits non-zero, a session you open from the web, desktop or mobile app still starts, just without whatever failed to install. The usual causes:

Cause What happens Fix
Network access set to None Every package registry is blocked Go back to Trusted
Custom without the default list Only your domains get through, so npm and PyPI are out Check the box that adds the common package managers
The private registry key in Network secrets The script runs before Claude Code connects to the proxy that adds the key That install can't live in the setup script
Bun It has known issues with the security proxy Use npm or pnpm
Prebuilt binaries The machine is x86_64, even if your Mac is ARM Use the x86_64 Linux build

To see which command failed, start the script with set -x. Put || true after anything non-critical, so a flaky step doesn't mark the whole script as failed.

One asymmetry that trips people up: a network access change reaches open sessions within a minute, but a script change only reaches a new session.

Why sessions boot slow

1. Go past five minutes and there's no snapshot

The environment isn't cached, so every new session goes through the script again, and it can hang or fail with a generic container error. Run independent steps in parallel:

#!/bin/bash
set -x
(apt update && apt install -y shellcheck) &
docker pull mcr.microsoft.com/mssql/server:2022-latest &
wait

If a single download won't fit the budget, move it to a SessionStart hook that starts it in the background. And drop the sleep in your retry loops: it counts against the five minutes.

2. The snapshot keeps files, not processes

Packages, Docker images and files the script writes survive. A PostgreSQL the script started, or a docker compose up, doesn't. Ask Claude to start them each session, or do it in the hook.

3. The snapshot doesn't notice your package.json

It's only rebuilt when you change the script or the allowed domains, or when it expires after roughly seven days. Change your project's dependencies and the script won't run again until then. That's why those dependencies belong somewhere else.

Setup script or SessionStart hook

Setup script SessionStart hook
Where you set it On the environment In the repo's .claude/settings.json
When it runs Before Claude Code, skipped when there's a snapshot After, every session, including resumes
Where it runs Cloud only Local and cloud
What it's for Tools the machine doesn't ship with Project dependencies

1. Add the hook to the repo

In .claude/settings.json, like any other hook:

{
  "hooks": {
    "SessionStart": [
      {
        "matcher": "startup|resume",
        "hooks": [
          {
            "type": "command",
            "command": "bash \"$CLAUDE_PROJECT_DIR\"/scripts/install_pkgs.sh"
          }
        ]
      }
    ]
  }
}

2. Write the script it calls

In scripts/install_pkgs.sh:

#!/bin/bash
if [ "$CLAUDE_CODE_REMOTE" != "true" ]; then
  exit 0
fi
cd "$CLAUDE_PROJECT_DIR" || exit 1
npm install

CLAUDE_CODE_REMOTE is true on the cloud machine and never on yours, so on your laptop the script exits without installing anything. The docs' version also stores a hash of package.json and package-lock.json and skips npm install when they haven't changed, so the hook doesn't add time to every start.

Three limits on the hook:

  • It has to live in the repo. Hooks in your ~/.claude/settings.json don't travel to the cloud. Neither do your MCP servers, though the setup script can add them with claude mcp add --scope user.
  • It's cut off at 600 seconds unless you set a timeout.
  • A session with several repos loads none of their .claude/settings.json files. There, dependencies go back to the setup script.

Official docs: Configure cloud environments · Troubleshoot setup

Requirements

  • A Pro, Max or Team plan (or Enterprise with a premium seat) and GitHub connected.
  • Checked against the docs on October 15, 2026. Anthropic gives the snapshot budget of five minutes and the seven-day expiry as approximate.

Found this useful? See more of wmedia.es in your Google results.

Add wmedia.es as a preferred source on Google
FREE GUIDE

You don't need Opus every time.

Model and effort are two settings, not one. 8 pages with the settings that actually move your bill, a three-question diagnostic for when something fails, and the price ladder.

  • 1. What "better" means capability, time and money
  • 2. Model who you send
  • 3. Effort how much rope you give
  • 4. Diagnostic three questions when something fails
  • 5. The bill where it comes from
Are you a professional Web developer?

You'll receive the guide by email · You join the Gravitas newsletter · Unsubscribe anytime

of 8
#

Wmedia · 8 pages
FREE GUIDE · 8 pages · 2 dials

You don't need Opus every time.

Model and effort are two settings, not one. 8 pages with the settings that actually move your bill, a three-question diagnostic for when something fails, and the price ladder.

Are you a professional Web developer? · Unsubscribe anytime
How I use AI

My Claude Code workflow.

The skills, agents and instructions I use as a professional Software Engineer. It's called Craft, and it's a plugin you can install.

See the skills

Using Opus for everything? See when you don't need it.