perf(hooks): improve hook efficiency with early exits and cooldowns
Sprint 8 - Hook Efficiency Quick Wins (v5.5.0) - Remove viz-platform SessionStart hook (zero value, just echoed "loaded") - Add early git check to git-flow branch-check.sh (skip JSON parsing for non-git commands) - Add early git check to git-flow commit-msg-check.sh (skip Python spawn for non-commit commands) - Add 60-second cooldown to project-hygiene cleanup.sh (reduce find operations) Closes #321, #322, #323, #324 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -6,6 +6,11 @@
|
||||
# Read tool input from stdin (JSON format)
|
||||
INPUT=$(cat)
|
||||
|
||||
# Quick check - exit immediately if not a git command
|
||||
if ! echo "$INPUT" | grep -q '"command".*git'; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Extract command from JSON input
|
||||
# The Bash tool sends {"command": "..."} format
|
||||
COMMAND=$(echo "$INPUT" | grep -o '"command"[[:space:]]*:[[:space:]]*"[^"]*"' | head -1 | sed 's/.*"command"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/')
|
||||
|
||||
@@ -6,6 +6,12 @@
|
||||
# Read tool input from stdin
|
||||
INPUT=$(cat)
|
||||
|
||||
# Quick check - exit immediately if not a git commit command
|
||||
# This avoids spawning Python for 99% of Bash commands
|
||||
if ! echo "$INPUT" | grep -q '"command".*git.*commit'; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Use Python to properly parse JSON and extract the command
|
||||
COMMAND=$(echo "$INPUT" | python3 -c "import sys,json; d=json.load(sys.stdin); print(d.get('command',''))" 2>/dev/null)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user