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 <noreply@anthropic.com>
This commit is contained in:
Eric Garcia 2026-02-01 18:44:13 -05:00
parent fb869cf12d
commit 50318ab802
4 changed files with 26 additions and 7 deletions

View file

@ -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

View file

@ -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"

9
.claude/hooks/session-start.sh Executable file
View file

@ -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

View file

@ -1,5 +1,15 @@
{
"hooks": {
"SessionStart": [
{
"hooks": [
{
"type": "command",
"command": ".claude/hooks/session-start.sh"
}
]
}
],
"PreToolUse": [
{
"matcher": "Write|Edit|MultiEdit",