Add config file support for hook backend URL

Hooks now read backend URL from ~/.claude/monitor_url config file,
making it easier to configure for remote/VM deployments without
relying on environment variables.

Priority order:
1. Config file (~/.claude/monitor_url)
2. Environment variable (CLAUDE_MONITOR_URL)
3. Default (http://localhost:8000)

This fixes the issue where Claude Code doesn't see environment
variables when not started from a configured shell.

Usage:
  echo "http://your-vm:8000" > ~/.claude/monitor_url
  cp .claude/hooks/*.sh ~/.claude/hooks/
  chmod +x ~/.claude/hooks/*.sh

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
felix.zoesch
2025-12-16 08:06:14 +01:00
parent 8b35d95e9b
commit 4582ead572
8 changed files with 107 additions and 22 deletions

View File

@@ -24,8 +24,12 @@ PAYLOAD=$(jq -n \
}')
# Send to backend API (asynchronous, non-blocking)
# Use CLAUDE_MONITOR_URL environment variable or default to localhost
MONITOR_URL="${CLAUDE_MONITOR_URL:-http://localhost:8000}"
# Priority: 1) Config file, 2) Environment variable, 3) Default localhost
if [ -f ~/.claude/monitor_url ]; then
MONITOR_URL=$(cat ~/.claude/monitor_url)
else
MONITOR_URL="${CLAUDE_MONITOR_URL:-http://localhost:8000}"
fi
curl -X POST \
-H "Content-Type: application/json" \