[BUG] PreToolUse hook crashes with JS error when setting run_in_background via updatedInput
Note: This is my first bug submission to this project. If I've made any procedural blunders, I apologize — please let me know if any changes are required!
Describe the bug
When a PreToolUse hook returns updatedInput with run_in_background: true to automatically background Bash commands, Claude Code crashes with a JavaScript error instead of applying the parameter modification.
Minimal reproduction repo: https://github.com/jamisonbryant/claude-code-hook-bug-repro
To reproduce
- Clone the repro repo:
``bash``
git clone https://github.com/jamisonbryant/claude-code-hook-bug-repro.git /tmp/hook-repro-test
cd /tmp/hook-repro-test
- Create project-local settings:
``bash``
mkdir -p .claude
cat > .claude/settings.local.json << 'SETTINGS'
{
"hooks": {
"PreToolUse": [
{
"matcher": "Bash",
"hooks": [
{
"type": "command",
"command": "/tmp/hook-repro-test/repro-bash.sh"
}
]
}
]
}
}
SETTINGS
- Start Claude Code from this directory:
``bash``
claude
- Run any Bash command:
````
> echo hello
Expected behavior
The run_in_background parameter should be set to true and the command should execute in the background, similar to how updatedInput works for the command parameter.
Actual behavior
Claude Code crashes with:
undefined is not an object (evaluating 'T.includes')
Control test
To verify the issue is specific to run_in_background:
- Edit
.claude/settings.local.jsonto usecontrol-bash.shinstead ofrepro-bash.sh - Start a new Claude session
- Run
echo hello - Result: Works correctly — outputs "hook modified this command"
This proves that updatedInput works for the command parameter but fails for run_in_background.
Why this should work
According to the Hooks reference documentation, run_in_background is a documented Bash tool parameter:
| Field | Type | Description |
|:--------------------|:--------|:-----------------------------------------|
| command | string | The shell command to execute |
| description | string | Optional description |
| timeout | number | Optional timeout in milliseconds |
| run_in_background | boolean | Whether to run the command in background |
And updatedInput is documented as being able to "modify the tool's input parameters before execution."
Hook output verification
Both hooks output valid JSON (tested with jq):
repro-bash.sh outputs:
{
"hookSpecificOutput": {
"hookEventName": "PreToolUse",
"permissionDecision": "allow",
"updatedInput": {
"run_in_background": true
}
}
}
control-bash.sh outputs:
{
"hookSpecificOutput": {
"hookEventName": "PreToolUse",
"permissionDecision": "allow",
"updatedInput": {
"command": "echo 'hook modified this command'"
}
}
}
Environment
- Claude Code version: 2.1.25
- OS: macOS (Darwin 25.2.0)
- Tested with both Bash and Python hooks (same error)
Additional context
The JS error undefined is not an object (evaluating 'T.includes') suggests validation code is calling .includes() on an undefined value, possibly when checking if run_in_background is in an allowlist of modifiable parameters.
Use case: Automatically backgrounding expensive commands (test suites, linters, static analysis) via hooks to prevent blocking and allow output capture for later review.
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗