From 50318ab8020b0147b871e88565963bc154f449f7 Mon Sep 17 00:00:00 2001 From: Eric Garcia Date: Sun, 1 Feb 2026 18:44:13 -0500 Subject: [PATCH] feat: RFC 0051 SessionStart hook for PATH injection Added SessionStart hook that adds $CLAUDE_PROJECT_DIR/target/release to PATH via CLAUDE_ENV_FILE. This makes `blue` available by name in all subsequent hooks. - .claude/hooks/session-start.sh: Sets PATH on session start - .claude/hooks/guard-write.sh: Now uses `blue` instead of full path - .claude/settings.json: Added SessionStart hook Requires Claude Code restart to take effect. Co-Authored-By: Claude Opus 4.5 --- .../rfcs/0051-portable-hook-binary-resolution.draft.md | 10 +++++----- .claude/hooks/guard-write.sh | 4 ++-- .claude/hooks/session-start.sh | 9 +++++++++ .claude/settings.json | 10 ++++++++++ 4 files changed, 26 insertions(+), 7 deletions(-) create mode 100755 .claude/hooks/session-start.sh diff --git a/.blue/docs/rfcs/0051-portable-hook-binary-resolution.draft.md b/.blue/docs/rfcs/0051-portable-hook-binary-resolution.draft.md index f3519db..7888051 100644 --- a/.blue/docs/rfcs/0051-portable-hook-binary-resolution.draft.md +++ b/.blue/docs/rfcs/0051-portable-hook-binary-resolution.draft.md @@ -125,11 +125,11 @@ blue guard --path="$FILE_PATH" ## Recommendation -**Option A** (project-relative binary) is recommended because: -1. It's documented by Claude Code -2. It's portable across machines -3. It doesn't require additional hooks -4. It works with the existing build workflow +**Option B** (SessionStart PATH injection) is recommended because: +1. Cleaner hook scripts - just use `blue` by name +2. Works for any hook that needs blue +3. Consistent with existing SessionStart hooks pattern +4. PATH set once, used everywhere ## Implementation Plan diff --git a/.claude/hooks/guard-write.sh b/.claude/hooks/guard-write.sh index 2f66a9f..9545cc2 100755 --- a/.claude/hooks/guard-write.sh +++ b/.claude/hooks/guard-write.sh @@ -10,5 +10,5 @@ if [ -z "$FILE_PATH" ]; then fi # Call blue guard with the extracted path -# Note: Full path required - PATH lookup hangs in Claude Code hook environment -/Users/ericg/letemcook/blue/target/release/blue guard --path="$FILE_PATH" +# RFC 0051: PATH is set by SessionStart hook +blue guard --path="$FILE_PATH" diff --git a/.claude/hooks/session-start.sh b/.claude/hooks/session-start.sh new file mode 100755 index 0000000..4c8d31b --- /dev/null +++ b/.claude/hooks/session-start.sh @@ -0,0 +1,9 @@ +#!/bin/bash +# SessionStart hook - sets up PATH for blue CLI +# RFC 0051: Portable hook binary resolution + +if [ -n "$CLAUDE_ENV_FILE" ] && [ -n "$CLAUDE_PROJECT_DIR" ]; then + echo "export PATH=\"\$CLAUDE_PROJECT_DIR/target/release:\$PATH\"" >> "$CLAUDE_ENV_FILE" +fi + +exit 0 diff --git a/.claude/settings.json b/.claude/settings.json index 453969e..c5ba832 100644 --- a/.claude/settings.json +++ b/.claude/settings.json @@ -1,5 +1,15 @@ { "hooks": { + "SessionStart": [ + { + "hooks": [ + { + "type": "command", + "command": ".claude/hooks/session-start.sh" + } + ] + } + ], "PreToolUse": [ { "matcher": "Write|Edit|MultiEdit",