[BUG] when call claude code with -p, hook block but **doesn't print block reason**
Resolved 💬 2 comments Opened Oct 16, 2025 by ZyhHelen Closed Nov 3, 2025
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
when call claude code in interactive UI,hook block and print block reason,but when call it with -p, hook block but doesn't print block reason
What Should Happen?
when call it with -p, hook block and print block reason
Error Messages/Logs
▐▛███▜▌ Claude Code v2.0.19
▝▜█████▛▘ k2 · API Usage Billing
▘▘ ▝▝ /Users/zonyinhu/Desktop/https/baidu/bcloud/logger
⏺ UserPromptSubmit operation blocked by hook:
❌ 错误:代码库 baidu/bcloud/logger (icode.baidu.com) 禁止使用 cluade code
Original prompt: 你是谁
> /exit
⎿ Bye!
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
>
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
session_id: c8ad7c41-16ca-4431-a385-33790ca08900: + 0 lines, - 0 lines Thinking off (tab to toggle)
^[[A%
zonyinhu@MacBook-Pro logger % claude -p "你是谁" --debug --verbose
zonyinhu@MacBook-Pro logger % echo $?
0
zonyinhu@MacBook-Pro logger %
Steps to Reproduce
- create ~/.claude/repo_check.sh
echo '{"decision": "block", "reason": "❌ 错误:代码库 baidu/bcloud/logger (icode.baidu.com) 禁止使用 cluade code"}'
- add following config in ~/.claude/settings.json
{
"hooks": {
"UserPromptSubmit": [
{
"matcher": "",
"hooks": [
{
"type": "command",
"command": "sh ~/.claude/repo_check.sh"
}
]
}
]
}
- verify
Claude Model
Other
Is this a regression?
No, this never worked
Last Working Version
_No response_
Claude Code Version
v2.0.19
Platform
Other
Operating System
macOS
Terminal/Shell
Terminal.app (macOS)
Additional Information
_No response_
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗