The Stop hook used "type": "prompt" with an empty matcher, which caused an infinite loop: Claude responds to evaluate the condition → that triggers Stop again → hook fires again → repeat forever. Changes: - Stop hook: changed to "type": "command" that checks git diff for actual wiki/ file changes before outputting anything. Silent exit = no loop. - SessionStart: added matcher "startup|resume" so it only fires on relevant events, plus a command hook to cat hot.md directly. - Added PostCompact hook to re-inject hot cache after context compaction. - Added PostToolUse hook to auto-commit wiki changes on Write/Edit. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
53 lines
1.9 KiB
JSON
53 lines
1.9 KiB
JSON
{
|
|
"hooks": {
|
|
"SessionStart": [
|
|
{
|
|
"matcher": "startup|resume",
|
|
"hooks": [
|
|
{
|
|
"type": "command",
|
|
"command": "[ -f wiki/hot.md ] && cat wiki/hot.md || true"
|
|
},
|
|
{
|
|
"type": "prompt",
|
|
"prompt": "If a vault is configured for this session (check CLAUDE.md for VAULT_PATH or a wiki/ folder in the current directory), silently read wiki/hot.md to restore recent context. If wiki/hot.md does not exist, do nothing. This is a non-vault session. Do not announce this. Do not report what you read. Just have the context available."
|
|
}
|
|
]
|
|
}
|
|
],
|
|
"PostCompact": [
|
|
{
|
|
"matcher": "",
|
|
"hooks": [
|
|
{
|
|
"type": "prompt",
|
|
"prompt": "Hook-injected context does not survive context compaction. If wiki/hot.md exists in the current directory, silently re-read it now to restore the hot cache. Do not announce this."
|
|
}
|
|
]
|
|
}
|
|
],
|
|
"PostToolUse": [
|
|
{
|
|
"matcher": "Write|Edit",
|
|
"hooks": [
|
|
{
|
|
"type": "command",
|
|
"command": "[ -d .git ] && git add wiki/ .raw/ 2>/dev/null && (git diff --cached --quiet || git commit -m \"wiki: auto-commit $(date '+%Y-%m-%d %H:%M')\" 2>/dev/null) || true"
|
|
}
|
|
]
|
|
}
|
|
],
|
|
"Stop": [
|
|
{
|
|
"matcher": "",
|
|
"hooks": [
|
|
{
|
|
"type": "command",
|
|
"command": "cd \"$PWD\" && [ -d wiki ] && [ -d .git ] && git diff --name-only HEAD 2>/dev/null | grep -q '^wiki/' && echo 'WIKI_CHANGED: Wiki pages were modified this session. Please update wiki/hot.md with a brief summary of what changed (under 500 words). Use the hot cache format: Last Updated, Key Recent Facts, Recent Changes, Active Threads. Keep it factual. Overwrite the file completely. It is a cache, not a journal.' || true"
|
|
}
|
|
]
|
|
}
|
|
]
|
|
}
|
|
}
|