Summary
Add a SessionStart hook so Claude Code on the web sessions can run swift build, swift test, swift-format, swiftlint, etc. without manual setup. Sessions today start without a Swift toolchain, so any code-validation step the agent attempts fails immediately.
Proposed approach
Two new files under .claude/:
.claude/hooks/session-start.sh — install Swift + project tooling. Guarded by CLAUDE_CODE_REMOTE=true so it's a no-op for local sessions.
.claude/settings.json — register the hook for the SessionStart event.
The script should:
- Install Swift's runtime apt deps on Ubuntu 24.04 (
libcurl4-openssl-dev, libxml2-dev, libz3-dev, libstdc++-13-dev, etc.). Tolerate failures from unrelated third-party PPAs (apt-get update -qq || true).
- Download the Swift 6.1 toolchain (matches
Package.swift's swift-tools-version: 6.1) from https://download.swift.org/swift-6.1-release/ubuntu2404/swift-6.1-RELEASE/swift-6.1-RELEASE-ubuntu24.04.tar.gz into ~/.swift/.
- Install
mise and run mise install against the existing mise.toml to fetch swift-format 602.0.0, swiftlint 0.62.2, periphery 3.7.4, swift-openapi-generator 1.10.3.
- Persist
PATH (Swift bin + ~/.local/bin) and the mise env into $CLAUDE_ENV_FILE so they're visible to the session.
- Be idempotent — skip apt/Swift/mise installs when already present.
Open questions
- Sync vs. async hook: synchronous guarantees tools are ready before the agent can run anything (no race), but adds ~2–4 min to first-time session startup (cached after that). Async swaps the trade-off. Recommendation: start synchronous.
- Swift version pinning: the hook should use
6.1 to match swift-tools-version. CI tests against 6.1/6.2/6.3 — agent sessions only need one.
Reference implementation
A working draft was prototyped in this branch's history (commit 36f52f8, since reverted in abf43b9) on PR for #256. It validated the apt step locally; the Swift download and mise install couldn't be exercised in the prototyping sandbox because download.swift.org was on a host allowlist denylist there. The actual web sandbox is expected to permit it.
Acceptance criteria
Summary
Add a
SessionStarthook so Claude Code on the web sessions can runswift build,swift test,swift-format,swiftlint, etc. without manual setup. Sessions today start without a Swift toolchain, so any code-validation step the agent attempts fails immediately.Proposed approach
Two new files under
.claude/:.claude/hooks/session-start.sh— install Swift + project tooling. Guarded byCLAUDE_CODE_REMOTE=trueso it's a no-op for local sessions..claude/settings.json— register the hook for theSessionStartevent.The script should:
libcurl4-openssl-dev,libxml2-dev,libz3-dev,libstdc++-13-dev, etc.). Tolerate failures from unrelated third-party PPAs (apt-get update -qq || true).Package.swift'sswift-tools-version: 6.1) fromhttps://download.swift.org/swift-6.1-release/ubuntu2404/swift-6.1-RELEASE/swift-6.1-RELEASE-ubuntu24.04.tar.gzinto~/.swift/.miseand runmise installagainst the existingmise.tomlto fetchswift-format 602.0.0,swiftlint 0.62.2,periphery 3.7.4,swift-openapi-generator 1.10.3.PATH(Swift bin +~/.local/bin) and the mise env into$CLAUDE_ENV_FILEso they're visible to the session.Open questions
6.1to matchswift-tools-version. CI tests against 6.1/6.2/6.3 — agent sessions only need one.Reference implementation
A working draft was prototyped in this branch's history (commit
36f52f8, since reverted inabf43b9) on PR for #256. It validated the apt step locally; the Swift download andmise installcouldn't be exercised in the prototyping sandbox becausedownload.swift.orgwas on a host allowlist denylist there. The actual web sandbox is expected to permit it.Acceptance criteria
swift --versionreturning Swift 6.1.swift build,swift test,swift-format,swiftlint,periphery,swift run swift-openapi-generatorall resolvable onPATH.