[BUG] UserPromptSubmit hooks not working when Claude Code is started from subdirectories

Resolved 💬 7 comments Opened Oct 3, 2025 by yamada-so Closed Dec 12, 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?

Summary

UserPromptSubmit hooks defined in ~/.claude/settings.json are not executed when Claude Code is started from
subdirectories, while PreToolUse hooks work correctly in all directories.

Environment

  • Claude Code version: [2.0.5]
  • OS: Linux (WSL2)
  • Settings location: ~/.claude/settings.json

Steps to Reproduce

  1. Configure UserPromptSubmit hooks in ~/.claude/settings.json:{

"hooks": {
"UserPromptSubmit": [
{
"type": "command",
"command": "~/.claude/hooks/critical/enforce_japanese.sh"
}
]
}
}

  1. Start Claude Code from home directory → UserPromptSubmit hooks work ✅
  2. Start Claude Code from any subdirectory → UserPromptSubmit hooks don't work ❌

Expected Behavior

According to https://docs.claude.com/en/docs/claude-code/settings:
"User settings are defined in ~/.claude/settings.json and apply to all projects."

UserPromptSubmit hooks should work regardless of the working directory.

Actual Behavior

  • UserPromptSubmit hooks: Only work when started from home directory
  • PreToolUse hooks: Work correctly from all directories

Additional Context

The hook scripts themselves execute correctly when tested manually:
echo '{"prompt":"test"}' | ~/.claude/hooks/critical/enforce_japanese.sh

Returns expected output

This suggests the issue is in how Claude Code loads/executes UserPromptSubmit hooks based on the working
directory.

What Should Happen?

UserPromptSubmit hooks defined in ~/.claude/settings.json should execute regardless of which directory Claude Code is started from, since the documentation states that "User settings are defined in ~/.claude/settings.json and
apply to all projects."

The hook should:

  1. Execute when the user submits a prompt
  2. Process the prompt content
  3. Return additionalContext that gets injected into the system prompt
  4. Work consistently across all working directories

Error Messages/Logs

Steps to Reproduce

  1. Create a UserPromptSubmit hook script at ~/.claude/hooks/test_hook.sh:

#!/bin/bash
cat << 'EOF'
{
"additionalContext": "Hook is working!"
}
EOF

  1. Make it executable: chmod +x ~/.claude/hooks/test_hook.sh
  2. Add the hook to ~/.claude/settings.json:

{
"hooks": {
"UserPromptSubmit": [
{
"type": "command",
"command": "~/.claude/hooks/test_hook.sh"
}
]
}
}

  1. Start Claude Code from home directory and send a prompt → Hook executes ✅
  2. Start Claude Code from any subdirectory and send a prompt → Hook does not execute ❌

Claude Model

Sonnet (default)

Is this a regression?

No, this never worked

Last Working Version

_No response_

Claude Code Version

2.0.5

Platform

Anthropic API

Operating System

Windows

Terminal/Shell

PowerShell

Additional Information

_No response_

View original on GitHub ↗

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