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:
parent
fb869cf12d
commit
50318ab802
4 changed files with 26 additions and 7 deletions
|
|
@ -125,11 +125,11 @@ blue guard --path="$FILE_PATH"
|
||||||
|
|
||||||
## Recommendation
|
## Recommendation
|
||||||
|
|
||||||
**Option A** (project-relative binary) is recommended because:
|
**Option B** (SessionStart PATH injection) is recommended because:
|
||||||
1. It's documented by Claude Code
|
1. Cleaner hook scripts - just use `blue` by name
|
||||||
2. It's portable across machines
|
2. Works for any hook that needs blue
|
||||||
3. It doesn't require additional hooks
|
3. Consistent with existing SessionStart hooks pattern
|
||||||
4. It works with the existing build workflow
|
4. PATH set once, used everywhere
|
||||||
|
|
||||||
## Implementation Plan
|
## Implementation Plan
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,5 +10,5 @@ if [ -z "$FILE_PATH" ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Call blue guard with the extracted path
|
# Call blue guard with the extracted path
|
||||||
# Note: Full path required - PATH lookup hangs in Claude Code hook environment
|
# RFC 0051: PATH is set by SessionStart hook
|
||||||
/Users/ericg/letemcook/blue/target/release/blue guard --path="$FILE_PATH"
|
blue guard --path="$FILE_PATH"
|
||||||
|
|
|
||||||
9
.claude/hooks/session-start.sh
Executable file
9
.claude/hooks/session-start.sh
Executable 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
|
||||||
|
|
@ -1,5 +1,15 @@
|
||||||
{
|
{
|
||||||
"hooks": {
|
"hooks": {
|
||||||
|
"SessionStart": [
|
||||||
|
{
|
||||||
|
"hooks": [
|
||||||
|
{
|
||||||
|
"type": "command",
|
||||||
|
"command": ".claude/hooks/session-start.sh"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
"PreToolUse": [
|
"PreToolUse": [
|
||||||
{
|
{
|
||||||
"matcher": "Write|Edit|MultiEdit",
|
"matcher": "Write|Edit|MultiEdit",
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue