(1) Audit log
PostToolUse에서 tool·args·결과를 JSONL로 한 줄씩 적는다.
def on_post_tool_use(tool, args, result):
append_jsonl("~/.claude/audit.jsonl",
{"ts": now(), "tool": tool,
"args": redact(args),
"ok": result.get("ok")})
(2) 임계 기반 알림
로그만 쌓고 안 보면 의미 없다. 임계가 로그 위에 얹혀야 진짜 Detect다.
· 세션 비용 임계 — 폭주 감지
· 분당 tool call 임계 — 루프 감지
사고가 나면 가장 먼저 여는 파일이 audit log. "어디서 망가졌지?"를 5분 안에 답할 수 있어야 한다.