[BUG] PreToolUse hooks not triggered for @file reference reads
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?
@-referencing a file (e.g., @/tmp/some-file.txt) loads the file content
into conversation context without triggering any PreToolUse hooks. The
system-reminder shows "Called the Read tool" but the hook never fires — no log
entry, no chance to block.
This affects any PreToolUse hook with a Read or * matcher. Any hook that
needs to intercept file reads — logging, access control, auditing — is
completely bypassed by @ file references.
A previous report of this issue (#9407) was auto-closed after 60 days without
human triage and is now locked.
What Should Happen?
Either:
@file reads should trigger PreToolUse hooks like any other Read tool call, or- A new hook event (e.g.,
PreFileAttach) should be provided so hooks/plugins
can intercept file attachments before they enter the conversation context.
While @ references are user-initiated, hook authors should have the option
to enforce policies uniformly across all file-reading pathways.
Error Messages/Logs
Using the logging hook from the repro steps below, hook-log.txt shows the
gap — no entry for the @ read, but a direct Read is logged:
# After @-referencing a file: no entry appears in hook-log.txt
# After asking Claude to "read /tmp/some-file.txt" directly:
$ cat hook-log.txt
Sun Mar 15 10:42:01 PDT 2026 tool=Read
Steps to Reproduce
- Create a PreToolUse hook that logs all invocations to a file:
``json``
{
"hooks": {
"PreToolUse": [{
"matcher": "*",
"hooks": [{
"type": "command",
"command": "echo \"$(date) tool=$TOOL_NAME\" >> hook-log.txt && cat"
}]
}]
}
}
- Start a new Claude Code session
- Type
@path-to-file(any file outside the project directory) in the prompt - Observe: file content appears in conversation context, but
hook-log.txt
has no entry for a Read tool call
- Compare: ask Claude to "read that same path" — the hook fires, an entry
appears in the log, and the hook can block the operation
Claude Model
Not sure / Multiple models
Is this a regression?
Yes, this worked in a previous version
Last Working Version
Unknown — the change likely occurred around v2.1.20 which changed @ references
to "show as removable attachments instead of inserting text"
Claude Code Version
2.1.50
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Terminal.app (macOS)
Additional Information
- Prior issue: #9407 (auto-closed by inactivity bot, locked, never triaged by a human)
- The
@file reference appears in system-reminder tags as "Called the Read tool"
suggesting it uses the Read tool internally, but the PreToolUse hook pipeline
is not invoked for this code path
- This affects hooks configured in both
.claude/settings.jsonand pluginhooks.json
This issue has 7 comments on GitHub. Read the full discussion on GitHub ↗