Skip to content

Add a SessionStart hook for Claude Code cloud sessions - #80

Merged
matt-edmondson merged 5 commits into
mainfrom
claude/cloud-session-setup-luxi33
Nov 4, 2026
Merged

matt-edmondson merged 5 commits into
mainfrom
claude/cloud-session-setup-luxi33

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Requested by Matt · project thread

Before: a Claude Code cloud session had no .NET SDK, so nothing here could be built or tested.

After: a SessionStart hook installs the .NET 10 SDK (10.0.402 today; this repository has no global.json, so the hook asks for 10.0.100 or later) plus the .NET 8 and 9 runtimes into ~/.dotnet, puts it on the session's PATH, and runs dotnet restore. A session can build and test straight away.

How: .claude/hooks/install-dotnet.sh tries the official dotnet-install.sh first. The default cloud network policy blocks builds.dotnet.microsoft.com but allows mcr.microsoft.com, so it falls back to unpacking usr/share/dotnet from the official mcr.microsoft.com/dotnet/sdk and runtime image layers. If the environment later allows the Microsoft host, the first route takes over with no change here. The hook does nothing outside cloud sessions and is a no-op once everything is installed. The same two files go to every ktsu repo in the Holotype project.

Validated in a cloud container: the hook ran clean and dotnet test test/Sdk.Examples.Tests/Sdk.Examples.Tests.csproj --filter StyleConfigContentTests passed 14/14. The end-to-end example tests were not run here.

Note: no version tag in the commit, so the version scripts will pick the bump from the files changed. Add [skip ci] or a tag on merge if a release for this is unwanted.


Generated by Claude Code

The cloud image has no .NET SDK, and Ubuntu's own dotnet-sdk-10.0 is the
1xx feature band, whose compiler is too old for ktsu.Sdk.Analyzers
(CS9057). The hook installs the SDK global.json asks for into ~/.dotnet,
puts it on the session's PATH and restores the solution.

dotnet-install.sh is tried first. The default cloud network policy blocks
builds.dotnet.microsoft.com, so the SDK falls back to the layers of the
mcr.microsoft.com/dotnet/sdk image, which the policy allows.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FGcrXbknJ2JWPDzNoNhPCw
@matt-edmondson matt-edmondson self-assigned this Oct 20, 2026
Comment thread .claude/hooks/install-dotnet.sh Outdated
Comment on lines +84 to +87
for layer in $(jq -r '.layers[].digest' <<<"$manifest"); do
curl -fsSL -o "$work/layer.tgz" "$registry/blobs/$layer"
tar -xzf "$work/layer.tgz" -C "$root" --strip-components=3 --wildcards "$wanted" 2>/dev/null || true
done

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 8e5dd46. Each layer is now checked with sha256sum against the digest its manifest names before it is extracted. A mismatch or a non-sha256 digest stops the install.


Generated by Claude Code

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FGcrXbknJ2JWPDzNoNhPCw
@matt-edmondson
matt-edmondson force-pushed the claude/cloud-session-setup-luxi33 branch from 7a4a559 to 8e5dd46 Compare October 20, 2026 12:06
dotnet-install.sh is fetched and run with nothing to verify it against, and
its host is blocked in cloud sessions anyway, so the installer now always
takes the MCR route, whose layers are checked against their digests.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FGcrXbknJ2JWPDzNoNhPCw

Copy link
Copy Markdown
Contributor Author

SonarCloud's quality gate is still failing on f9652f1, with "C Security Rating on New Code". The only new code is the two shell scripts and .claude/settings.json.

Two pushes were aimed at this:

  • Each container layer is now checked against its manifest sha256 before it is unpacked.
  • The unverified dotnet-install.sh download-and-run route has been removed.

Neither cleared the gate, so the finding is something else. sonarcloud.io is blocked from the cloud session I'm working in (proxy 403), so I can't see which rule or line it is. Once someone can read the issue on the dashboard, I'll fix it or explain why it doesn't apply.


Generated by Claude Code

curl -L follows a redirect to any protocol, so a registry redirect could
downgrade a layer download to plain HTTP. --proto '=https' refuses that,
and --tlsv1.2 refuses the old TLS versions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017vfJW5jpiuVuBRXSgitSY1
@sonarqubecloud

sonarqubecloud Bot commented Nov 4, 2026

Copy link
Copy Markdown

@matt-edmondson
matt-edmondson merged commit c4eeeb6 into main Nov 4, 2026
9 checks passed
@matt-edmondson
matt-edmondson deleted the claude/cloud-session-setup-luxi33 branch November 4, 2026 01:51
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.

3 participants