Skip to content

Commit 045ef77

Browse files
fullstackjamclaude
andauthored
chore: add SessionStart hook for Claude Code on the web (#27)
Pre-fetches Go modules and warms the build/test caches when a remote Claude Code session starts, so linters and unit tests can run without extra setup. Gated on CLAUDE_CODE_REMOTE=true so it is a no-op locally. https://claude.ai/code/session_01PeXAW2DA8BnTmFvStfNmWn Co-authored-by: Claude <noreply@anthropic.com>
1 parent a614015 commit 045ef77

3 files changed

Lines changed: 43 additions & 1 deletion

File tree

.claude/hooks/session-start.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
# Only run in Claude Code on the web; skip on local machines.
5+
if [ "${CLAUDE_CODE_REMOTE:-}" != "true" ]; then
6+
exit 0
7+
fi
8+
9+
cd "${CLAUDE_PROJECT_DIR:-$(pwd)}"
10+
11+
echo "[openboot session-start] Go version: $(go version)"
12+
13+
# Pre-fetch and verify Go module deps so tests/builds are fast and offline-safe.
14+
echo "[openboot session-start] Downloading Go modules..."
15+
go mod download
16+
17+
# Warm the build cache so the first `go build` / `go test` is fast.
18+
echo "[openboot session-start] Warming build cache (go build ./...)..."
19+
go build ./... >/dev/null
20+
21+
# Warm the test binary cache without executing tests.
22+
echo "[openboot session-start] Warming test cache (go test -count=0 ./...)..."
23+
go test -count=0 ./... >/dev/null
24+
25+
echo "[openboot session-start] Done."

.claude/settings.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"hooks": {
3+
"SessionStart": [
4+
{
5+
"hooks": [
6+
{
7+
"type": "command",
8+
"command": "$CLAUDE_PROJECT_DIR/.claude/hooks/session-start.sh"
9+
}
10+
]
11+
}
12+
]
13+
}
14+
}

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@ __pycache__/
3030

3131
# Work tracking (internal)
3232
.sisyphus/
33-
.claude/
33+
.claude/*
34+
!.claude/hooks/
35+
!.claude/settings.json
36+
.claude/settings.local.json
3437

3538
# Go vendor (deps downloaded at build time)
3639
vendor/

0 commit comments

Comments
 (0)