[BUG] PreToolUse hook crashes with JS error when setting run_in_background via updatedInput

Resolved 💬 2 comments Opened Feb 3, 2026 by jamisonbryant Closed Mar 5, 2026
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

  1. 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
``

  1. 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
``

  1. Start Claude Code from this directory:

``bash
claude
``

  1. 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:

  1. Edit .claude/settings.local.json to use control-bash.sh instead of repro-bash.sh
  2. Start a new Claude session
  3. Run echo hello
  4. 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.

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗