Skip to content

feat(defense-in-depth): bootstrap Safe Chain from a Claude Code SessionStart hook - #66

Merged
jaredwray merged 1 commit into
mainfrom
cursor/claude-code-session-hook-0ac4
Sep 27, 2026
Merged

jaredwray merged 1 commit into
mainfrom
cursor/claude-code-session-hook-0ac4

Conversation

@jaredwray

Copy link
Copy Markdown
Owner

Claude Code on the web never runs the Dev Container postCreateCommand or Cursor's install, so those sessions started without Safe Chain shims. writr#553 is the setup that fixes that. This teaches defense-in-depth-nodejs to produce it.

What the skill now copies

  • .claude/hooks/session-start.sh runs only when CLAUDE_CODE_REMOTE=true, cds to $CLAUDE_PROJECT_DIR, and runs scripts/setup-cloud-environment.sh with stdout sent to stderr. Hook stdout is injected into the session, so the install log must not land there.
  • .claude/settings.json registers that script as a synchronous SessionStart command with a 600s timeout. The default 60s timeout kills a cold Safe Chain install. There is no matcher, so resume, /clear, compaction, and forks re-run it.
  • .gitignore uses .claude/* plus !.claude/settings.json and !.claude/hooks/. A blanket .claude ignore cannot be negated, so the hook would never be committed.
  • Shim PATH stays in setup-cloud-environment.sh, written to CLAUDE_ENV_FILE before the bootstrap can fail, with blocking stubs until Safe Chain replaces them. The hook does not append PATH after the script returns — that write is skipped when the bootstrap fails, which would leave pnpm unshimmed.
  • agentic-upstream-sync treats the hook script as a verbatim copy, same as setup-cloud-environment.sh.

The § 2 Safe Chain catalog line names the hook, the 600s timeout, and the gitignore exceptions, so a repo that already checked the item off with an inline command is re-audited.

Verification

  • node scripts/validate-skills.mjs
  • node scripts/validate-safe-chain-setup.mjs (hook is a silent no-op locally; in a cloud session the install log stays off stdout, and a failed bootstrap still writes the shim PATH)
Open in Web Open in Cursor 

…t hook

Claude Code on the web does not run the Dev Container or Cursor install, and
hook stdout is injected into the session. Bootstrap from session-start.sh with
a 600s timeout, keep the install log on stderr, and track the hook in git.

Co-authored-by: Jared Wray <me@jaredwray.com>
@jaredwray
jaredwray marked this pull request as ready for review September 27, 2026 04:37
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 27, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-27T04:41:07.385969Z e0d4f02 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@jaredwray
jaredwray merged commit dc296c7 into main Sep 27, 2026
6 checks passed
@jaredwray
jaredwray deleted the cursor/claude-code-session-hook-0ac4 branch September 27, 2026 05:11
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