Skip to content

Guards: send PreToolUse block reason to stderr - #11

Merged
dioptx merged 1 commit into
mainfrom
amp/pretooluse-stderr
Nov 14, 2026
Merged

dioptx merged 1 commit into
mainfrom
amp/pretooluse-stderr

Conversation

@dioptx

@dioptx dioptx commented Nov 14, 2026

Copy link
Copy Markdown
Owner

When a guard blocks a tool call, hooks/weft-pretooluse.sh ran cli.py guard 2>&1, which moved guard_engine's block reason from stderr to stdout. Claude Code shows a PreToolUse hook's stderr on exit 2, so builders saw "No stderr output" instead of why the command was blocked (about 200 times a month in the Mac mini session digest).

This drops the redirect. cli.py guard writes nothing to stdout, so nothing else changes.

tests/test_hooks.py::TestPreToolUseHook::test_block_reason_goes_to_stderr runs the real hook on a guarded git commit and checks for exit 2, the guard message on stderr, and an empty stdout. It fails without the fix (stderr is empty and the reason is on stdout). Full suite passes locally: 2992 passed.

The hook wrapper redirected cli.py guard's stderr to stdout with 2>&1, so
Claude Code reported "No stderr output" instead of the block reason on
exit 2. Drop the redirect and pin the stream in a hook test.

Amp-Thread-ID: https://ampcode.com/threads/T-01a1dac2-199b-7414-af14-4603154d1976
Co-authored-by: Dennis Pettas <[email protected]>
@dioptx
dioptx merged commit f55e755 into main Nov 14, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants