Hooks don't receive tool input for Read/Glob; permission patterns don't match tilde paths
Summary
PreToolUse hooks for Read/Glob tools do not receive tool input parameters as environment variables, making it impossible to validate or intercept file paths before execution. Additionally, permission patterns containing tilde (~) do not match agent-generated tilde paths.
Environment
- Claude Code v2.1.5
- Windows 11 (Git Bash / MINGW64)
- Model: Opus 4.5
Problem 1: Hooks don't receive tool input for Read/Glob
Expected Behavior
PreToolUse hooks should receive tool input parameters as environment variables, similar to how Bash hooks receive CLAUDE_TOOL_INPUT_COMMAND.
For Read: CLAUDE_TOOL_INPUT_FILE_PATH
For Glob: CLAUDE_TOOL_INPUT_PATH and CLAUDE_TOOL_INPUT_PATTERN
Actual Behavior
Hooks only receive:
CLAUDE_PROJECT_DIRCLAUDE_CODE_ENTRYPOINT
No tool-specific input variables are provided. This was verified by dumping all environment variables from within the hook.
Impact
Cannot create hooks to validate/fix file paths before tool execution. This is critical for Windows environments where path format issues cause permission prompts.
Problem 2: Permission patterns don't match tilde paths
Setup
User-level ~/.claude/settings.local.json contains:
{
"permissions": {
"allow": [
"Read(~\Projects\**)",
"Read(~/Projects/**)",
"Glob(~\Projects\**)"
]
}
}
Expected Behavior
These patterns should match paths like ~\Projects\Aletheia-310\src\file.py
Actual Behavior
Permission prompt appears:
Read(~\Projects\Aletheia-310\src\lambda_function.py)
Do you want to proceed?
The pattern Read(~\Projects\**) does not match ~\Projects\Aletheia-310\...
Problem 3: Model generates tilde paths despite explicit instructions
Even with explicit prompt instructions like:
PATH FORMATS (MANDATORY):
- Read/Write/Edit/Glob: C:\Users\mcwiz\Projects\Aletheia\path\to\file
- NEVER use ~ or ~\ - these are FORBIDDEN
And CLAUDE.md containing:
THE TILDE CHARACTER (~) DOES NOT EXIST. NEVER USE IT.
Opus still generates:
Read(~\Projects\Aletheia-310\src\etymologist.py)
Note: The Claude Code banner itself displays ~\Projects\Aletheia which may be where the model picks up this format.
Reproduction Steps
- On Windows, create a worktree in a subdirectory
- Configure a PreToolUse hook for Read that logs all environment variables
- Have the model attempt to Read a file in the worktree
- Observe: hook receives no file path information
- Observe: permission prompt appears despite matching patterns in settings
Requested Fixes
- Expose tool input to hooks - Provide
CLAUDE_TOOL_INPUT_*environment variables for all tools, not just Bash - Fix tilde pattern matching - Ensure
Read(~\Projects\**)matches~\Projects\...paths - Consider normalizing paths - Before permission check, normalize tilde paths to absolute paths
Workaround Attempted
Added Read(**) and Glob(**) to allow any path - testing pending.
This issue has 13 comments on GitHub. Read the full discussion on GitHub ↗