Skip to content

refactor(claude): split cloud bootstrap out of the SessionStart hook - #476

Merged
kyle-sexton merged 1 commit into
mainfrom
claude/cloud-bootstrap-migration-laaylj
Aug 15, 2026
Merged

kyle-sexton merged 1 commit into
mainfrom
claude/cloud-bootstrap-migration-laaylj

Conversation

@kyle-sexton

Copy link
Copy Markdown
Member

No linked issue

Related

  • N/A

Summary

Migrates the Claude Code cloud bootstrap from the SessionStart-hook layout to the split cloud-bootstrap layout. Claude Code builds its plugin/command/skill registry at process start and never re-reads it, so plugins installed by a SessionStart hook are invisible to the session that ran the hook. The account environments' setup scripts run the repo's committed bootstrap (with CLAUDE_CODE_REMOTE=true) after clone and before the session process launches — that pre-launch call is what gets plugins loaded at turn one. The SessionStart hook stays registered and runs the same script per start/resume as drift repair against a stale environment cache.

Changes

  • git mv .claude/hooks/install-plugins.sh .claude/cloud-bootstrap.sh — this repo's SessionStart script was named install-plugins.sh (there was no session-start.sh); it is the script serving the cloud-bootstrap role.
  • Added the CLAUDE_CODE_REMOTE=true guard the split layout requires (the script previously had none and ran in local sessions too); provisioning logic and idempotency are unchanged.
  • Fixed the repo_root fallback (.. instead of ../..) for the script's new location one directory higher — without this the fallback resolved outside the repo and the script saw 0 enabled plugins. CLAUDE_PROJECT_DIR remains the preferred root source.
  • Rewrote the header to describe the two callers (pre-launch environment setup; SessionStart drift repair) and renamed the log prefix to cloud-bootstrap:.
  • Repointed the SessionStart hook (startup|resume) in .claude/settings.json at bash "$CLAUDE_PROJECT_DIR/.claude/cloud-bootstrap.sh"; all other settings untouched.

No other references to the old path exist in docs, CI, or scripts.

Verification

  • bash -n passes; shellcheck not available in the session container.
  • Ran twice in a cloud session with CLAUDE_CODE_REMOTE=true: both report cloud-bootstrap: 65 enabled, 0 newly installed; second run is a fast no-op (~1.7s, spent on claude plugin list).
  • Ran once with CLAUDE_CODE_REMOTE unset: exits 0 in ~4ms with no output and no plugin/marketplace mutation (plugin count 65 before and after).
  • With CLAUDE_PROJECT_DIR unset, bash -x shows the fallback resolving repo_root to the repo root, not its parent.

🤖 Generated with Claude Code

https://claude.ai/code/session_01FJb49tbTWHPXxBr5WCp514


Generated by Claude Code

Claude Code builds its plugin/command/skill registry at process start and
never re-reads it, so plugins a SessionStart hook installs are invisible to
the session that ran the hook. Move .claude/hooks/install-plugins.sh to
.claude/cloud-bootstrap.sh so the account environment's setup script can run
it (with CLAUDE_CODE_REMOTE=true) after clone and before the session process
launches - the only path that gets plugins loaded at turn one. The
SessionStart hook (startup|resume) keeps running the same script as drift
repair against a stale environment cache.

- Guard the script on CLAUDE_CODE_REMOTE=true so it is a no-op outside
  cloud sessions, matching the split-layout contract.
- Fix the repo-root fallback (.. instead of ../..) for the script's new
  location one directory higher.
- Repoint the SessionStart hook command in .claude/settings.json.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FJb49tbTWHPXxBr5WCp514
@cursor

cursor Bot commented Aug 15, 2026

Copy link
Copy Markdown

Bugbot is not enabled for your account, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

@claude

claude Bot commented Aug 15, 2026 •

Copy link
Copy Markdown

Claude finished @kyle-sexton's task in 2m 34s —— View job


Claude finished the code review

  • Read trigger request and repo review criteria (REVIEW.md, CLAUDE.md)
  • Fetch PR diff (git diff -M origin/main...HEAD)
  • Review .claude/cloud-bootstrap.sh for correctness
  • Review .claude/settings.json hook repoint
  • Post findings (inline + summary)

Summary

Reviewed the two changed files (.claude/cloud-bootstrap.sh, .claude/settings.json) against origin/main...HEAD (2 files, +22/-12). Scope: code-review lane only (correctness, design, conventions, error handling, observability, tests, docs) — this repo carries claude-security-review.yml/claude-security-review-self.yml, so security is left to that lane.

No blocking or suggestion-level findings. The functional deltas in this diff are exactly the two the PR describes, and both check out:

  • CLAUDE_CODE_REMOTE guard (L16) — placed before any work (repo_root resolution, claude/jq checks) so local/interactive sessions exit immediately without cost. Correct set -e-safe idiom ([[ ... ]] || exit 0).
  • repo_root fallback fix (L18) — the script moved one directory shallower (.claude/hooks/install-plugins.sh → .claude/cloud-bootstrap.sh), so dirname/.. (one hop) is the correct replacement for the old dirname/../.. (two hops). Verified independently by walking the path math, not just by re-stating the author's test output.

Everything else in the diff is the git mv rename, comment/header rewording, and the install-plugins: → cloud-bootstrap: log-prefix rename — no behavior change there. The enabledPlugins/marketplace provisioning logic in the bottom two-thirds of the script is untouched from the prior PR (#475).

Also checked, per the PR's own claim:

  • git grep -n "install-plugins" HEAD — no remaining references to the old path/name anywhere in the committed tree (docs, CI, scripts).
  • .claude/settings.json at HEAD — the SessionStart hook command now points at cloud-bootstrap.sh; rest of the file untouched; JSON structurally well-formed.

Note: I did not independently re-run the script in a cloud session with CLAUDE_CODE_REMOTE=true (no such environment available here), so that portion of the PR's Verification section is author-claimed and unverified by me — the guard and path-fallback logic check out by static analysis, which is as far as I could confirm.
· Branch

@claude

claude Bot commented Aug 15, 2026 •

Copy link
Copy Markdown

Claude finished @kyle-sexton's task in 1m 14s —— View job


Claude Security Review

  • Gather context (PR diff, changed files)
  • Apply skip gate
  • Review changed files for security-relevant surface
  • Report findings

No security issues found.

This PR is a mechanical refactor of the cloud-bootstrap plugin-install script (git mv + path fix + comment rewrite) plus a one-line hook-command repoint in .claude/settings.json. Reviewed both changed files against the diff (origin/main...HEAD):

  • .claude/cloud-bootstrap.sh — the new [[ "${CLAUDE_CODE_REMOTE:-}" == "true" ]] || exit 0 guard narrows the script's execution surface (it previously ran unconditionally in every session, local included; now it's confined to cloud/remote sessions). No new sink was introduced: source_repo is still read from the repo-committed .claude/settings.json via jq (same logic as before the rename, just reworded comments), and the claude plugin marketplace add "$source_repo" / claude plugin install "$id" calls are unchanged. No injection surface, no credential handling, no permission widening.
  • .claude/cloud-bootstrap.sh#L18 — the repo_root fallback path fix (../.. → ..) is a correctness fix for the file's new location one directory up; it still resolves within the repo checkout and does not change trust boundaries.
  • .claude/settings.json#L86 — only the hook's script path changed; the command string, quoting, and timeout are otherwise identical to before.

No pull_request_target/workflow_run usage, no unpinned action/dependency changes, no permissions-block edits, and no new untrusted-input handling in this diff.

@github-actions

Copy link
Copy Markdown

Last security-reviewed head: e72e2c0e2777d090f1c8709bfecf808644d41424. On the next push, the relevance gate compares only the commits since this SHA; delete this comment to force a full re-review.

@github-actions

Copy link
Copy Markdown

Claude has reviewed this PR 1 time. The lane skips further automatic reviews after 5; deleting this comment resets the count.

@kyle-sexton
kyle-sexton merged commit d58bb2f into main Aug 15, 2026
1 check passed
@kyle-sexton
kyle-sexton deleted the claude/cloud-bootstrap-migration-laaylj branch August 15, 2026 05:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants