[BUG] hooks don't run in headless mode
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?
I have setup a hook that is executed after each Read. It looks like this, and sits in my project's .claude/settings.local.json
{
"hooks": {
"PostToolUse": [
{
"matcher": "Read",
"hooks": [
{
"type": "command",
"command": "<COMMAND_HERE>"
}
]
}
]
}
}
However, when I run Claude Code in "headless" mode (i.e., no user-facing terminal) or by emulating that with echo "Read a file from the repo and summarize it" | claude --dangerously-skip-permissions | cat, the hook is never executed.
What Should Happen?
When I run Claude Code in a regular terminal (e.g. echo "Read a file from the repo and summarize it" | claude --dangerously-skip-permissions), the GUI pops up and the hook is executed correctly, even showing up on both the GUI and the conversation logs.
I could not find any documentation about this, so I am not sure if this is expected or unexpected behavior. At the very least, to be able to make use of hooks in fully automated scenarios, there should be an option for enabling hooks in headless mode.
Error Messages/Logs
Steps to Reproduce
- Add a hook like the one above
echo "Read a file from the repo and summarize it" | claude --dangerously-skip-permissionsecho "Read a file from the repo and summarize it" | claude --dangerously-skip-permissions | cat- Check log files for any
hook_progressmessage
Claude Model
None
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.1.15
Platform
AWS Bedrock
Operating System
Other Linux
Terminal/Shell
Non-interactive/CI environment
Additional Information
_No response_
This issue has 5 comments on GitHub. Read the full discussion on GitHub ↗