Debugging a configuration
Find out why a call was refused or let through, with config check, explain and the debug log.
You'll: find out why the hook refused a call you expected to pass, or let through one it should have refused. Three tools show what the hook did and why; the sections below are organised by what you want to know.
Before you start
- harness-kit is installed and the hook entries are in
.claude/settings.json(quick start). - For a real session you can restart Claude Code with an environment variable set.
config checkandexplainchange nothing, so they are safe to run anywhere.
Does the configuration load?
Rule this out first: a configuration that does not load refuses almost every tool call.
npx harness-kit config checkIt loads the configuration exactly as a hook does, asks every adapter what it can do and who it is signed in as, and checks the hook entries in .claude/settings.json. Each problem comes with its fix.
settings check checks only the hook entries; CI runs it so the configuration and the settings never drift apart.
What does one call get?
harness-kit explain takes a hook payload on standard input and shows every configured Policy that runs for it with its Decision and time, those that do not run, and the hook's answer with its exit code:
npx harness-kit explain < payload.jsonPreToolUse of Bash in session try
- kubectl denies (20.9 ms): `kubectl delete pod web-1` is refused: `delete` is on the deny list of the kubectl command table.
Fix: Do not run it; if it is needed, ask the developer to run it by hand.
- package-managers allows (69.9 ms)
- self-protection allows (45.6 ms)
- hook-bypass allows (47.7 ms)
The hook exits with 2 and writes to standard error:
`kubectl delete pod web-1` is refused: `delete` is on the deny list of the kubectl command table.
Fix: Do not run it; if it is needed, ask the developer to run it by hand.A payload is the JSON Claude Code sends: at least session_id, transcript_path, cwd and hook_event_name, and for a tool call tool_name and tool_input. The quick start shows a one-line way to write one.
explain changes nothing: it records no session state, the tracker refuses every write, and the Policies that act after the answer, such as format-on-edit, do not run. The kit's internal touches Policy runs too but is not listed.
What happened in a real session?
Start Claude Code with HARNESS_KIT_DEBUG=1 (or true, yes, on) to turn the debug log on. Every hook call then writes its log lines, each Policy's Decision and timing among them, to a file of the session's state, .git/harness-kit/<session id>/debug/<time>-<event>-<n>.log:
timestamp=2026-12-01T10:17:05.617Z level=DEBUG fiber=#10 message=policy_decided decision=Deny duration_ms=11.44887 policy=kubectl
timestamp=2026-12-01T10:17:05.624Z level=DEBUG fiber=#13 message=policy_decided decision=Allow duration_ms=17.506628 policy=self-protectionThe log never reaches the agent, and a log that cannot be written is dropped without changing the answer.
Why did it behave this way?
- A call went through that should not have, and you see
policy_failed_openon standard error. The Policy failed or ran out of time, and its fail mode let the call through. The line names the Policy and the problem. Fix the cause, or raise the entry'stimeoutMillis. - A Policy you did not configure refused a call. It is
self-protectionorhook-bypass, which every configuration runs. See Protection. - Claude Code asks you about a harmless command. A path Policy could not resolve a write. The question names what it could not resolve; see how the path Policies read a shell command.
- A stop check let the agent stop despite an objection. It blocks once for each state, so a second stop with nothing changed goes through. See Sessions and stop checks.
Troubleshooting lists more.
Related
- Testing a configuration: turn what you found into a test.
- Command line reference.