[BUG] @FILE NAME syntax fails to auto-include files with spaces in filename

Resolved 💬 5 comments Opened Jul 20, 2025 by MrGreenTea Closed Jan 6, 2026

Environment

  • Platform (select one):
  • [x] Anthropic API (Max Plan)
  • [ ] AWS Bedrock
  • [ ] Google Vertex AI
  • [ ] Other: <!-- specify -->
  • Claude CLI version: 1.0.56 (Claude Code)
  • Operating System: Fedora Silverblue 42 (kernel 6.15.4-200.fc42.x86_64)
  • Terminal: wezterm 20240203-110809-5046fc22 (flatpak)

Bug Description

When using the @FILE NAME syntax to include file content in context, files with spaces in their names are not automatically read and included in the initial prompt. Instead, Claude has to manually use the Read tool to access the file content after the conversation starts.

Steps to Reproduce

  1. Create files with spaces in names (e.g., "my example file.md")
  2. Write a prompt like "Read @my example file.md and @other_file.md and give me feedback"
  3. Press enter to submit the prompt
  4. Observe that only files without spaces (like "other_file.md") are automatically included
  5. Claude then has to manually call the Read tool to access "my example file.md"

Expected Behavior

All files referenced with @FILE NAME syntax should be automatically read and included in the initial context, regardless of whether the filename contains spaces.

Actual Behavior

  • Files without spaces in names are automatically included in context
  • Files with spaces in names are not automatically included
  • Claude must manually use the Read tool to access files with spaces in their names
  • This creates an unnecessary delay and extra tool call in the workflow

Additional Context

The issue appears to be in the parsing logic for the @FILE NAME syntax, where spaces in filenames are not properly handled during the automatic file inclusion process. Files without spaces work correctly, suggesting the parser may be only parsing until the first space.

Additionally, it would be helpful if included files were rendered in a visually distinct way (e.g., with a gray background around the full file name) to make it clear which files have been automatically included in the context. It would make sense to only do this for files that exist/are readable.

<details>
<summary>Debug Log</summary>

[DEBUG] Shell snapshot created successfully (4178 bytes)
[DEBUG] Starting shell snapshot cleanup (max age: 14 days)
[DEBUG] Skipping current session snapshot: snapshot-bash-<SESSION_ID>-<RANDOM_ID>.sh
[DEBUG] No old shell snapshots to clean up
[DEBUG] MCP server "context7": No token data found
[DEBUG] MCP server "context7": No token data found
[DEBUG] MCP server "playwright": Connection attempt completed in 1342ms - status: connected
[DEBUG] MCP server "playwright": Connection attempt completed in 1041ms - status: connected
[DEBUG] MCP server "context7": Connection attempt completed in 1446ms - status: connected
[DEBUG] MCP server "context7": No token data found
[DEBUG] MCP server "context7": Connection attempt completed in 1171ms - status: connected
[DEBUG] Executing hooks for UserPromptSubmit
[DEBUG] Getting matching hook commands for UserPromptSubmit with query: undefined
[DEBUG] Found 0 hook matchers in settings
[DEBUG] Matched 0 unique hooks for query "no match query" (0 before deduplication)
[DEBUG] Found 0 hook commands to execute

> "Read @my example file.md and @other_file.md and give me a summary
  ⎿  Read other_file.md (2 lines)
[DEBUG] Writing to temp file: <HOME>/.claude.json.tmp.<TEMP_ID>.<TIMESTAMP>
[DEBUG] Preserving file permissions: 100644
[DEBUG] Temp file written successfully, size: 132405 bytes
[DEBUG] Applied original permissions to temp file
[DEBUG] Renaming <HOME>/.claude.json.tmp.<TEMP_ID>.<TIMESTAMP> to <HOME>/.claude.json
[DEBUG] File <HOME>/.claude.json written atomically
[DEBUG] Stream started - received first chunk
[DEBUG] executePreToolHooks called for tool: Read
[DEBUG] Executing hooks for PreToolUse:Read
[DEBUG] Getting matching hook commands for PreToolUse with query: Read
[DEBUG] Found 2 hook matchers in settings
[DEBUG] Matched 0 unique hooks for query "Read" (0 before deduplication)
[DEBUG] Found 0 hook commands to execute
[DEBUG] Executing hooks for PostToolUse:Read
[DEBUG] Getting matching hook commands for PostToolUse with query: Read
[DEBUG] Found 0 hook matchers in settings
[DEBUG] Matched 0 unique hooks for query "Read" (0 before deduplication)
[DEBUG] Found 0 hook commands to execute

● Read(my example file.md)
  ⎿  Read 2 lines (ctrl+r to expand)
[DEBUG] Stream started - received first chunk

● Summary:

  - my example file.md: Contains one line stating "This file name has spaces in it."
  - other_file.md: Contains one line stating "This file name has no spaces."

  Both files are minimal examples demonstrating filename conventions with and without spaces.
[DEBUG] Executing hooks for Stop
[DEBUG] Getting matching hook commands for Stop with query: undefined
[DEBUG] Found 1 hook matchers in settings
[DEBUG] Matched 1 unique hooks for query "no match query" (1 before deduplication)
[DEBUG] Found 1 hook commands to execute
[DEBUG] Executing hook command: <PATH_TO_SCRIPTS>/conventional_commit_hook.py with timeout 60000ms
[DEBUG] Hook command completed with status 0: <PATH_TO_SCRIPTS>/conventional_commit_hook.py
[DEBUG] Hook output does not start with {, treating as plain text

</details>

Note in the log: "other_file.md" was automatically read (shown as "⎿ Read other_file.md (2 lines)"), while "my example file.md" required a manual Read tool call (shown as "● Read(my example file.md)").

View original on GitHub ↗

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