Settings Hooks
Source:
settings-hooks.json
PreToolUse
Write
- Matcher:
Write
PostToolUse
Bash
- Matcher:
Bash
Stop
Hook
Raw Definition
39 lines
json
{
"hooks": {
"PreToolUse": [
{
"matcher": "Write",
"hooks": [
{
"type": "command",
"description": "Enforce lead orchestrator write scope restriction",
"command": "if echo \"$CLAUDE_TOOL_INPUT\" | grep -q '\"file_path\"' && ! echo \"$CLAUDE_TOOL_INPUT\" | grep -q '.sniper/'; then echo 'BLOCK: Lead orchestrator can only write to .sniper/ directory' >&2; exit 2; fi"
}
]
}
],
"PostToolUse": [
{
"matcher": "Bash",
"hooks": [
{
"type": "command",
"description": "Self-healing CI: detect test/lint failures and instruct agent to fix",
"command": "if echo \"$CLAUDE_TOOL_OUTPUT\" | grep -qiE '(FAIL|FAILED|ERROR|AssertionError|SyntaxError|TypeError|ReferenceError|lint.*error|eslint.*error|tsc.*error)'; then echo 'WARN: Test or lint failure detected. Fix the failing test/lint issue before proceeding to the next task.'; fi"
}
]
}
],
"Stop": [
{
"hooks": [
{
"type": "command",
"description": "Run gate reviewer at phase boundaries",
"command": "if [ -f .sniper/pending-gate.yaml ]; then echo 'Gate review pending — spawning gate-reviewer agent'; fi"
}
]
}
]
}
}