KeiSeiKit-1.0/settings-snippet.json
Parfii-bot 4afc85ca30 fix(hooks): post-audit hook chain hardening + 4 new defensive hooks
Hook chain repairs (Group A):
- alignment-check.sh: read .prompt (was .user_prompt) — hook was dead
- block-dangerous.sh: jq instead of inline interpreter (RULE 0.2 + fail-open fix)
- destructive-guard.sh: explicit INPUT=cat + jq guard + exit 0 — was silent no-op
- numeric-claims-guard.sh: exit 1 -> exit 2 (Claude Code spec — was non-blocking)
                          comments updated 0.17 -> 0.18 (env var name kept)
- no-downgrade.sh: removed (?i) PCRE syntax — POSIX ERE matched literal text
- task-timer.sh: jq -nc instead of bare printf — JSON injection on quotes/backslashes
                 in description was corrupting RULE 0.18 evidence journal
- check-error-patterns.sh: replaced with no-op stub — had hardcoded /Users/denis/...
                            PATH LEAK in public kit, plus inline interpreter use
- post-commit-audit.sh: added trailing exit 0 — grep return code was hook exit code
- citation-verify.sh: ALLOW_REGEX accepts HOOK-BYPASS marker — bypass was documented
                       but never matched
- settings-snippet.json: agent-stub-scan moved PreToolUse:Agent -> PostToolUse:Agent
                          (RULE 0.16 enforcement was firing before transcript existed)
- check-error-patterns hook removed from settings-snippet.json

New defensive hooks (Group H):
- no-github-push.sh: PreToolUse:Bash hard deny on github.com push/create/sync/remote-add
                      (RULE 0.1 — patent IP protection; was missing from public kit)
- secrets-pre-guard.sh: PreToolUse:Edit|Write — token-pattern scan with allowlist (RULE 0.8)
- chat-numeric-prewarn.sh: UserPromptSubmit reminder when prompt mentions time/cost
                            (RULE 0.18 chat extension)
- chat-numeric-postflag.sh: Stop event scans last assistant message for naked numerics
                             without REAL/FROM-JOURNAL/ESTIMATE-HTC markers

Source: full Sonnet test-retest audit 2026-05-02 (3 parallel waves of 6 agents each)
identified hook chain bugs as HIGH severity in all 3 runs independently.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-02 21:38:47 +08:00

246 lines
7.6 KiB
JSON

{
"_comment": "Merge these entries into your ~/.claude/settings.json under the matching keys. If you already have PostToolUse/PreToolUse/Stop arrays, append the objects below to them instead of overwriting. install.sh --activate-hooks automates the merge and de-dupes by hooks[].command.",
"hooks": {
"PostToolUse": [
{
"matcher": "Write|Edit",
"hooks": [
{
"type": "command",
"command": "~/.claude/hooks/assemble-agents.sh"
},
{
"type": "command",
"command": "~/.claude/hooks/site-wysiwyd-check.sh",
"statusMessage": "site-wysiwyd drift check..."
},
{
"type": "command",
"command": "~/.claude/hooks/post-write-check.sh",
"statusMessage": "post-write checks..."
}
]
},
{
"matcher": "Bash",
"hooks": [
{
"type": "command",
"command": "~/.claude/hooks/milestone-commit-hook.sh",
"statusMessage": "milestone self-audit check (RULE 0.14)..."
},
{
"type": "command",
"command": "~/.claude/hooks/post-commit-audit.sh",
"statusMessage": "post-commit audit..."
}
]
},
{
"matcher": "Agent",
"hooks": [
{
"type": "command",
"command": "~/.claude/hooks/task-timer.sh",
"statusMessage": "task duration tracker (RULE 0.18)..."
},
{
"type": "command",
"command": "~/.claude/hooks/agent-fork-done.sh",
"statusMessage": "agent-fork-done — close ledger lifecycle..."
},
{
"type": "command",
"command": "~/.claude/hooks/agent-stub-scan.sh",
"statusMessage": "STATUS-TRUTH marker scan (RULE 0.16)..."
}
]
},
{
"matcher": "*",
"hooks": [
{
"type": "command",
"command": "~/.claude/hooks/error-spike-detector.sh",
"statusMessage": "error-spike rolling window (RULE 0.14)..."
},
{
"type": "command",
"command": "~/.claude/hooks/agent-heartbeat-tick.sh"
}
]
}
],
"PreToolUse": [
{
"matcher": "Bash",
"hooks": [
{
"type": "command",
"command": "~/.claude/hooks/assemble-validate.sh"
},
{
"type": "command",
"command": "~/.claude/hooks/agent-capability-check.sh",
"statusMessage": "agent-capability-check (Agent Substrate v1, phase 4)..."
},
{
"type": "command",
"command": "~/.claude/hooks/destructive-guard.sh",
"statusMessage": "destructive-op guard..."
},
{
"type": "command",
"command": "~/.claude/hooks/block-dangerous.sh",
"statusMessage": "dangerous-command block..."
},
{
"type": "command",
"command": "~/.claude/hooks/safety-guard.sh",
"statusMessage": "safety-guard..."
},
{
"type": "command",
"command": "~/.claude/hooks/disk-headroom-check.sh",
"statusMessage": "disk headroom (RULE 0.17)..."
},
{
"type": "command",
"command": "~/.claude/hooks/no-python-without-approval.sh",
"statusMessage": "rust-first python gate (RULE 0.2)..."
},
{
"type": "command",
"command": "~/.claude/hooks/no-github-push.sh",
"statusMessage": "no-github-push guard (RULE 0.1)..."
}
]
},
{
"matcher": "Edit|Write",
"hooks": [
{
"type": "command",
"command": "~/.claude/hooks/no-hand-edit-agents.sh"
},
{
"type": "command",
"command": "~/.claude/hooks/agent-capability-check.sh",
"statusMessage": "agent-capability-check (Agent Substrate v1, phase 4)..."
},
{
"type": "command",
"command": "~/.claude/hooks/numeric-claims-guard.sh",
"statusMessage": "numeric-claims-guard (RULE 0.18)..."
},
{
"type": "command",
"command": "~/.claude/hooks/citation-verify.sh",
"statusMessage": "citation-verify (RULE 0.4)..."
},
{
"type": "command",
"command": "~/.claude/hooks/secrets-pre-guard.sh",
"statusMessage": "secrets-pre-guard (RULE 0.8)..."
}
]
},
{
"matcher": "Read",
"hooks": [
{
"type": "command",
"command": "~/.claude/hooks/tomd-preread.sh",
"statusMessage": "tomd pre-read auto-convert check..."
}
]
},
{
"matcher": "Agent",
"hooks": [
{
"type": "command",
"command": "~/.claude/hooks/agent-fork-logger.sh",
"statusMessage": "agent-fork-logger (RULE 0.12)..."
},
{
"type": "command",
"command": "~/.claude/hooks/orchestrator-dirty-check.sh",
"statusMessage": "orchestrator-dirty-check (RULE 0.13)..."
},
{
"type": "command",
"command": "~/.claude/hooks/orchestrator-branch-check.sh",
"statusMessage": "orchestrator branch ownership (RULE 0.13)..."
},
{
"type": "command",
"command": "~/.claude/hooks/task-timer.sh"
}
]
}
],
"UserPromptSubmit": [
{
"matcher": "*",
"hooks": [
{
"type": "command",
"command": "~/.claude/hooks/recurrence-suggest.sh",
"statusMessage": "recurrence-escalate suggester (RULE 0.10)..."
},
{
"type": "command",
"command": "~/.claude/hooks/rust-first.sh",
"statusMessage": "rust-first reminder (RULE 0.2)..."
},
{
"type": "command",
"command": "~/.claude/hooks/no-downgrade.sh",
"statusMessage": "no-downgrade reminder (RULE -1)..."
},
{
"type": "command",
"command": "~/.claude/hooks/alignment-check.sh"
},
{
"type": "command",
"command": "~/.claude/hooks/chat-numeric-prewarn.sh",
"statusMessage": "chat-numeric-prewarn (RULE 0.18)..."
}
]
}
],
"Stop": [
{
"matcher": "*",
"hooks": [
{
"type": "command",
"command": "~/.claude/hooks/session-end-dump.sh",
"statusMessage": "session-end trace dump (RULE 0.14)..."
},
{
"type": "command",
"command": "~/.claude/hooks/stop-verify.sh",
"statusMessage": "stop-verify (uncommitted/Modal-running warning)..."
},
{
"type": "command",
"command": "~/.claude/hooks/task-timer.sh"
},
{
"type": "command",
"command": "~/.claude/hooks/extract-task-durations.sh",
"statusMessage": "extract-task-durations — pull async durations from notifications..."
},
{
"type": "command",
"command": "~/.claude/hooks/chat-numeric-postflag.sh",
"statusMessage": "chat-numeric-postflag (RULE 0.18)..."
}
]
}
]
}
}