Skip to content

Commit cf5243b

Browse files
mydeaclaude
andauthored
chore(dev): Support Claude Code cloud (remote) sessions (#22573)
Enables this repo to run in Claude Code cloud (remote) sessions by committing the bootstrap needed to install and build the monorepo on session start. - `scripts/claude-cloud-setup.sh` — runs `yarn install --ignore-engines --frozen-lockfile` (matching CI) then `yarn build:dev`, with `VOLTA_FEATURE_PNPM=1` exported. - `.claude/settings.json` — a `SessionStart` hook runs that script, gated to cloud sessions via `CLAUDE_CODE_REMOTE=true` so local sessions are untouched. - `.claude/CLOUD.md` — documents the one-time per-environment settings that can't be committed (setup script, network access, env vars). The hook runs install + build on **every** cloud session rather than depending on the cached environment-creation setup script, because the working branch changes constantly and a cached build would be stale. Repeated runs stay cheap: a frozen-lockfile install is a no-op when `node_modules` is warm, and Nx only rebuilds packages whose inputs changed. `build:dev` (transpile + types) is used instead of the full production `yarn build` — enough for editing and unit tests, and faster on each session. --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 8aa02a3 commit cf5243b

3 files changed

Lines changed: 71 additions & 0 deletions

File tree

.claude/CLOUD.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Running this repo in Claude Code cloud (remote sessions)
2+
3+
Most of the setup is committed to the repo and works automatically:
4+
5+
- **`scripts/claude-cloud-setup.sh`** — bootstrap: `yarn install --frozen-lockfile` + `yarn build:dev`. Runs **every** session so the checkout is always built against the current branch. Repeated runs are cheap (frozen install is a no-op when warm; Nx only rebuilds changed packages).
6+
- **`.claude/settings.json`** — a `SessionStart` hook runs that script, but only in cloud sessions (`CLAUDE_CODE_REMOTE=true`). Local sessions are unaffected.
7+
8+
## One-time environment setup (done in the `claude.ai/code` UI)
9+
10+
These cannot live in the repo and must be set once per environment:
11+
12+
1. **Setup script** — install the language runtime the sandbox lacks, e.g.:
13+
14+
```bash
15+
bash scripts/claude-cloud-setup.sh
16+
```
17+
18+
Do not rely on the cached result for freshness: install + build re-run on every session via the SessionStart hook, because the working branch changes constantly. This runs the same script mostly to warm the caches (node_modules, Nx) so the first real session is fast.
19+
20+
2. **Network access:** `Trusted` (default) is sufficient — it already allows the npm registry and GitHub, which is all the install needs.
21+
22+
3. **Environment variables:** none required for build/test. Add any Sentry DSNs or tokens here only if you intend to run E2E/integration suites that need them (visible to anyone who can edit the environment — do not put long-lived secrets here).
23+
24+
## Notes
25+
26+
- Node/Yarn versions come from `package.json` (Volta locally). In the cloud we use the sandbox runtime and pass `--ignore-engines`, matching CI.
27+
- The full production `yarn build` is not run at startup; `build:dev` (transpile + types) is enough for editing and running unit tests. Run `yarn build` manually if you need bundles.

.claude/settings.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
{
22
"env": { "ENABLE_LSP_TOOL": "1" },
3+
"hooks": {
4+
"SessionStart": [
5+
{
6+
"matcher": "startup|resume",
7+
"hooks": [
8+
{
9+
"type": "command",
10+
"command": "if [ \"$CLAUDE_CODE_REMOTE\" = \"true\" ]; then bash \"$CLAUDE_PROJECT_DIR\"/scripts/claude-cloud-setup.sh; fi"
11+
}
12+
]
13+
}
14+
]
15+
},
316
"permissions": {
417
"allow": [
518
"Bash(find:*)",

scripts/claude-cloud-setup.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Bootstrap the Sentry JavaScript monorepo for a Claude Code cloud session.
4+
#
5+
# Wired as the repo's SessionStart hook (see .claude/settings.json), gated to
6+
# cloud sessions. It runs on every session so the checkout is always installed
7+
# and built against the *current* branch -- the code changes constantly, so a
8+
# build cached at environment-creation time would be stale. Repeated runs are
9+
# cheap: a frozen-lockfile install is a no-op when node_modules is warm, and Nx
10+
# only rebuilds packages whose inputs actually changed.
11+
#
12+
# Node/Yarn versions come from `package.json` (managed by Volta locally); in the
13+
# cloud we rely on whatever runtime the sandbox provides and pass --ignore-engines
14+
# to match CI (.github/actions/install-dependencies).
15+
set -euo pipefail
16+
17+
cd "$(dirname "$0")/.."
18+
19+
# Required by the repo's package-manager setup (some workspaces use pnpm via Volta).
20+
export VOLTA_FEATURE_PNPM=1
21+
22+
echo "node: $(node --version 2>/dev/null || echo 'not found')"
23+
echo "yarn: $(yarn --version 2>/dev/null || echo 'not found')"
24+
25+
echo "Installing dependencies (yarn install --frozen-lockfile)..."
26+
yarn install --ignore-engines --frozen-lockfile
27+
28+
echo "Building packages (yarn build:dev)..."
29+
yarn build:dev
30+
31+
echo "Cloud setup complete."

0 commit comments

Comments
 (0)