6 new issues for Claude Code hook improvements: - 012: Test output filtering (reduce noise, show failures only) - 013: Stop verification (verify work complete before stopping) - 014: Auto-test on edit (async tests after code changes) - 015: Session context injection (git/issues/CI on startup) - 016: Silent auto-formatting (suppress formatter output) - 017: Expose/hide policy (define what to show vs suppress) Based on Claude Code hooks documentation: - PostToolUse with suppressOutput for noise reduction - Stop hooks with agent verification - Async hooks for background testing - SessionStart for context injection - additionalContext for exposing important info Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2 KiB
2 KiB
feat(hooks): Stop hook to verify work is complete
Summary
Add a Stop hook that verifies Claude has actually completed the task before stopping, preventing premature "I'm done" responses.
Problem
Claude sometimes stops too early:
- "I've updated the file" (but didn't run tests)
- "The fix is complete" (but there are lint errors)
- "Done" (but left debug statements)
Solution
A Stop hook (type: "agent") that spawns a verification subagent to check:
- Were tests run? Did they pass?
- Are there uncommitted changes that should be committed?
- Are there debug statements left in code?
- Does the output match what was requested?
Hook Configuration
{
"hooks": {
"Stop": [
{
"hooks": [
{
"type": "agent",
"prompt": "Verify the work is complete. Check: 1) Tests passed if code was changed, 2) No debug statements (dd, dump, fmt.Println), 3) Code is formatted. Context: $ARGUMENTS",
"timeout": 60
}
]
}
]
}
}
Alternative: Command-based
For faster verification without subagent overhead:
{
"hooks": {
"Stop": [
{
"hooks": [
{
"type": "command",
"command": "core ai verify-complete"
}
]
}
]
}
}
Verification Checks
core ai verify-complete should check:
-
If code was modified:
- Run
core go testorcore php test - Check for debug statements
- Verify formatting
- Run
-
If commit was requested:
- Check git status for uncommitted changes
-
Return decision:
{ "decision": "block", "reason": "Tests have not been run. Please run: core go test" }
Guard Against Loops
Check stop_hook_active to prevent infinite loops:
#!/bin/bash
INPUT=$(cat)
STOP_ACTIVE=$(echo "$INPUT" | jq -r '.stop_hook_active')
if [ "$STOP_ACTIVE" = "true" ]; then
# Already continued once, allow stop
exit 0
fi
# Run verification...