SessionStart: query OpenBrain for recent activity + project context, inject into Claude's context window on every new session. Stop: async save session context to OpenBrain when git changes exist. PreCompact: save working state to OpenBrain before context compaction. API key read from ~/.claude/brain.key or CORE_BRAIN_KEY env var. Co-Authored-By: Virgil <virgil@lethean.io>
97 lines
2.6 KiB
JSON
97 lines
2.6 KiB
JSON
{
|
|
"$schema": "https://claude.ai/schemas/hooks.json",
|
|
"hooks": {
|
|
"PreToolUse": [
|
|
{
|
|
"matcher": "Bash",
|
|
"hooks": [
|
|
{
|
|
"type": "command",
|
|
"command": "${CLAUDE_PLUGIN_ROOT}/hooks/prefer-core.sh"
|
|
}
|
|
],
|
|
"description": "Block destructive commands (rm -rf, sed -i, xargs rm) and enforce core CLI"
|
|
},
|
|
],
|
|
"PostToolUse": [
|
|
{
|
|
"matcher": "tool == \"Edit\" && tool_input.file_path matches \"\\.go$\"",
|
|
"hooks": [
|
|
{
|
|
"type": "command",
|
|
"command": "${CLAUDE_PLUGIN_ROOT}/scripts/go-format.sh"
|
|
}
|
|
],
|
|
"description": "Auto-format Go files after edits"
|
|
},
|
|
{
|
|
"matcher": "tool == \"Edit\" && tool_input.file_path matches \"\\.php$\"",
|
|
"hooks": [
|
|
{
|
|
"type": "command",
|
|
"command": "${CLAUDE_PLUGIN_ROOT}/scripts/php-format.sh"
|
|
}
|
|
],
|
|
"description": "Auto-format PHP files after edits"
|
|
},
|
|
{
|
|
"matcher": "tool == \"Edit\"",
|
|
"hooks": [
|
|
{
|
|
"type": "command",
|
|
"command": "${CLAUDE_PLUGIN_ROOT}/scripts/check-debug.sh"
|
|
}
|
|
],
|
|
"description": "Warn about debug statements (dd, dump, fmt.Println)"
|
|
},
|
|
{
|
|
"matcher": "tool == \"Bash\" && tool_input.command matches \"^git commit\"",
|
|
"hooks": [
|
|
{
|
|
"type": "command",
|
|
"command": "${CLAUDE_PLUGIN_ROOT}/scripts/post-commit-check.sh"
|
|
}
|
|
],
|
|
"description": "Warn about uncommitted work after git commit"
|
|
}
|
|
],
|
|
"Stop": [
|
|
{
|
|
"matcher": "*",
|
|
"hooks": [
|
|
{
|
|
"type": "command",
|
|
"command": "${CLAUDE_PLUGIN_ROOT}/scripts/session-save.sh",
|
|
"async": true,
|
|
"timeout": 10
|
|
}
|
|
],
|
|
"description": "Save session context to OpenBrain (async, only when git changes exist)"
|
|
}
|
|
],
|
|
"PreCompact": [
|
|
{
|
|
"matcher": "*",
|
|
"hooks": [
|
|
{
|
|
"type": "command",
|
|
"command": "${CLAUDE_PLUGIN_ROOT}/scripts/pre-compact.sh"
|
|
}
|
|
],
|
|
"description": "Save state before auto-compact to prevent amnesia"
|
|
}
|
|
],
|
|
"SessionStart": [
|
|
{
|
|
"matcher": "*",
|
|
"hooks": [
|
|
{
|
|
"type": "command",
|
|
"command": "${CLAUDE_PLUGIN_ROOT}/scripts/session-start.sh"
|
|
}
|
|
],
|
|
"description": "Restore recent session context on startup"
|
|
}
|
|
]
|
|
}
|
|
}
|