Claude Code hooks provide automated enforcement of protocols and recovery from context compaction.
Configuration Location
Hooks are configured in: /.corsys/claude/settings.local.json
Hook Types
| Event | Trigger | Use Case |
|---|---|---|
| SessionStart | startup, resume, compact | Load protocols after recovery |
| Stop | After Claude response | Enforce session agenda updates |
| PreToolUse | Before tool calls | Block/approve tools |
| PostToolUse | After tool completes | Validation, logging |
Current Hooks
SessionStart Hook
Location: /opt/mcp-servers/shared/hooks/session_start_hook.py
Triggers on: startup|resume|compact
Purpose: - Outputs recovery reminder after auto-compact - Sets environment variables for session context - Forces Claude to read workflow.init
Stop Hook
Location: /opt/mcp-servers/shared/hooks/stop_hook.py
Purpose: - Runs after every Claude response - Future: Check if session agenda was updated - Future: Verify voice was used for responses - Can block stopping if protocols not followed
Hook Output Format
Hooks communicate via JSON:
{
"decision": "approve" | "block",
"reason": "Explanation",
"continue": false,
"systemMessage": "Warning to show"
}
block+reason= Claude must continuestop_hook_active: truein input = prevent infinite loops
Settings Configuration
{
"hooks": {
"SessionStart": [
{
"matcher": "startup|resume|compact",
"hooks": [
{
"type": "command",
"command": "python3 /opt/mcp-servers/shared/hooks/session_start_hook.py",
"timeout": 10
}
]
}
],
"Stop": [
{
"hooks": [
{
"type": "command",
"command": "python3 /opt/mcp-servers/shared/hooks/stop_hook.py",
"timeout": 5
}
]
}
]
}
}
Related Links
- Settings file:
/.corsys/claude/settings.local.json - Hook scripts:
/opt/mcp-servers/shared/hooks/