Skip to content

Commit f6139d4

Browse files
committed
Add the Claude Code web SessionStart hook and bump the drift pin to v5
PythonTap was one of three repos in the family without the canonical SessionStart hook. Fresh Claude Code web containers clone bare -- no submodules, no pre-commit hook -- so agent commits could bypass the local format layer entirely and fail the clang-format gate on code a local clone would have fixed at commit time. The hook initializes source/min-api recursively, installs the pinned pre-commit hook, and warms its clang-format. The drift pin moves v4 -> v5 in the same commit because that is what makes the hook guarded rather than merely present: v4 does not carry .claude/hooks/session-start.sh, so the drift job's conditional guard would skip it silently. At v5 the guard becomes active. Verified this cannot break the gate: v4 and v5 carry byte-identical .clang-format, .clang-tidy, STYLE.md, .pre-commit-config.yaml and scripts/tidy.sh -- the tags differ only by the addition of the hook -- and every file the v5 drift job will compare here matches its canonical blob exactly, including the new hook at b7c2a49. .claude/settings.json is the canonical copy, created because none existed; it stays unguarded by design. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JhhQ93r2E1QTnCx46YfX8j
1 parent 4484a04 commit f6139d4

3 files changed

Lines changed: 52 additions & 2 deletions

File tree

.claude/hooks/session-start.sh

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/bin/bash
2+
# Canonical Tap House SessionStart hook for Claude Code on the web.
3+
#
4+
# Fresh web-session containers clone the repo bare: no submodules, no
5+
# pre-commit hook installed — so `git commit` runs unformatted and the
6+
# clang-format CI gate fails on code a local clone would have fixed at commit
7+
# time. This hook closes that gap at session start:
8+
#
9+
# 1. init submodules recursively (kernels, SDKs, vendored test harnesses)
10+
# 2. install pre-commit and register the repo's canonical hook
11+
# (.pre-commit-config.yaml — the Tap-wide pinned clang-format)
12+
# 3. warm the pinned clang-format binary so the first commit doesn't
13+
# pay the download (the container snapshot caches it)
14+
#
15+
# Canonical copy: taphouse (distributed by scripts/sync.sh alongside
16+
# .clang-format / .clang-tidy / .pre-commit-config.yaml; drift-guarded where
17+
# present). Web-only; local clones are untouched.
18+
set -euo pipefail
19+
20+
if [ "${CLAUDE_CODE_REMOTE:-}" != "true" ]; then
21+
exit 0
22+
fi
23+
24+
cd "$CLAUDE_PROJECT_DIR"
25+
26+
echo "session-start: initializing submodules ..."
27+
git submodule update --init --recursive
28+
29+
echo "session-start: installing pre-commit ..."
30+
if ! python3 -m pre_commit --version >/dev/null 2>&1; then
31+
python3 -m pip install --quiet pre-commit
32+
fi
33+
python3 -m pre_commit install
34+
python3 -m pre_commit install-hooks
35+
36+
echo "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+
}

.github/workflows/style.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ on: [push, pull_request]
1414

1515
jobs:
1616
drift:
17-
uses: tap/taphouse/.github/workflows/drift-check.yml@v4
17+
uses: tap/taphouse/.github/workflows/drift-check.yml@v5
1818
with:
19-
ref: v4
19+
ref: v5
2020

2121
clang-format:
2222
runs-on: ubuntu-latest

0 commit comments

Comments
 (0)