Clone
1
Change-V5.5.0:-Hook-Efficiency-Quick-Wins-(Sprint-8-Implementation)
Leo Miranda edited this page 2026-01-30 18:21:50 +00:00

Change V5.5.0: Hook Efficiency Quick Wins

Sprint: 8
Status: Implemented
Date: 2026-01-30
Origin: RFC-Hook-Efficiency-Improvements


Scope

This sprint implements Phase 1: Quick Wins from the RFC, focusing on low-effort, high-impact optimizations.

In Scope

Change Plugin Impact
Remove SessionStart hook viz-platform Eliminates pointless echo
Add early git check git-flow Skips 90%+ of Bash invocations
Add cooldown project-hygiene Reduces find operations

Explicitly Out of Scope

  • SessionStart dispatcher consolidation (rejected - fights plugin architecture)
  • Shared hook library (rejected - creates coupling)
  • clarity-assist opt-in (deferred - requires user discussion)
  • Path filtering for PostToolUse hooks (deferred - case-by-case)

Implementation Details

1. Remove viz-platform SessionStart Hook

File: plugins/viz-platform/hooks/hooks.json

Before:

{
  "hooks": [
    {
      "event": "SessionStart",
      "type": "command",
      "command": "echo 'viz-platform plugin loaded'",
      "timeout": 5000
    }
  ]
}

After:

{
  "hooks": []
}

2. Add Early Git Check to git-flow Hooks

Problem: commit-msg-check.sh spawns Python to parse JSON even for non-git commands.

Solution: Add early check before JSON parsing:

# Quick check - exit immediately if not a git command
if ! echo "$INPUT" | grep -q '"command".*git'; then
    exit 0
fi

Files:

  • plugins/git-flow/hooks/branch-check.sh
  • plugins/git-flow/hooks/commit-msg-check.sh

3. Add Cooldown to project-hygiene

Problem: Runs find across entire project on every file edit.

Solution: Add session-based cooldown (skip if ran recently):

LAST_RUN_FILE="/tmp/project-hygiene-${PPID}-last-run"
if [[ -f "$LAST_RUN_FILE" ]]; then
    LAST_RUN=$(cat "$LAST_RUN_FILE")
    NOW=$(date +%s)
    if (( NOW - LAST_RUN < 60 )); then
        exit 0  # Skip if ran in last 60 seconds
    fi
fi
date +%s > "$LAST_RUN_FILE"

Verification

All implemented and tested:

  1. New session starts without viz-platform echo
  2. Non-git bash commands skip hook processing
  3. Git branch validation still works
  4. Git commit message validation still works
  5. Cleanup runs once per minute max, not every edit

Results

Issue Status PR
#321 - Remove viz-platform hook Closed #334
#322 - Early git check (branch) Closed #334
#323 - Early git check (commit-msg) Closed #334
#324 - Cooldown (cleanup) Closed #334

Lessons Learned


References