mirror of
https://github.com/trustedsec/hate_crack.git
synced 2026-03-12 21:23:05 -07:00
feat: add PostToolUse hook to auto-trigger readme-documentarian
Adds a Bash PostToolUse hook that detects the prek documentation audit warning and injects additionalContext into Claude's session, prompting it to invoke the readme-documentarian agent automatically. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
23
.claude/hooks/doc-audit-trigger.sh
Executable file
23
.claude/hooks/doc-audit-trigger.sh
Executable file
@@ -0,0 +1,23 @@
|
||||
#!/bin/bash
|
||||
# PostToolUse hook: detects the documentation audit warning from prek post-commit
|
||||
# hooks and injects a prompt for Claude to invoke the readme-documentarian agent.
|
||||
set -euo pipefail
|
||||
|
||||
input=$(cat)
|
||||
|
||||
stdout=$(echo "$input" | python3 -c "
|
||||
import sys, json
|
||||
try:
|
||||
d = json.load(sys.stdin)
|
||||
resp = d.get('tool_response', {})
|
||||
if isinstance(resp, dict):
|
||||
print(resp.get('stdout', ''))
|
||||
else:
|
||||
print(str(resp))
|
||||
except Exception:
|
||||
pass
|
||||
")
|
||||
|
||||
if echo "$stdout" | grep -q '\[Documentation Audit\].*documentation was not updated'; then
|
||||
printf '{"additionalContext": "The post-commit documentation audit flagged that code changed but README.md was not updated. Invoke the readme-documentarian agent now to review the recent changes and update the documentation."}\n'
|
||||
fi
|
||||
15
.claude/settings.json
Normal file
15
.claude/settings.json
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"hooks": {
|
||||
"PostToolUse": [
|
||||
{
|
||||
"matcher": "Bash",
|
||||
"hooks": [
|
||||
{
|
||||
"type": "command",
|
||||
"command": ".claude/hooks/doc-audit-trigger.sh"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user