[BUG] sonnet 4 thinks fedex should be fedx

Resolved 💬 3 comments Opened Aug 21, 2025 by bradleyjames Closed Jan 7, 2026

Environment

  • Platform (select one):
  • [X] Anthropic API
  • [ ] AWS Bedrock
  • [ ] Google Vertex AI
  • [ ] Other: <!-- specify -->
  • Claude CLI version: 1.0.86 (Claude Code)
  • Operating System: macOS 15.6
  • Terminal: Terminal.app

Bug Description

This is a bit of a loaded issue but is very specific. We have a project that interacts with services provided by fedex. This is a java project and in the package names (and thus file paths) we use 'fedex'. The problem is that CC keeps trying to use 'fedx' rather than 'fedex' no matter what context we provide in CLAUDE.md. I'm using sonnet 4.

Here's one series of failures:

⏺ Read(service/src/test/java/com/fedx/service/ClusterManagementServiceTest.java)
  ⎿  Error reading file

⏺ Read(service/src/test/java/com/fedx/service/ClusterManagementServiceTest.java)
  ⎿  Error reading file

⏺ Read(service/src/test/java/com/fedx/service/ClusterManagementServiceTest.java)
  ⎿  Error reading file

⏺ Read(service/src/test/java/com/fedex/service/ClusterManagementServiceTest.java)
  ⎿  Read 20 lines (ctrl+r to expand)

⏺ I can see there's still a when() call on line 343 that needs to be updated. Let me fix it:

⏺ Update(service/src/test/java/com/fedx/service/ClusterManagementServiceTest.java)
  ⎿  Error editing file

⏺ Update(service/src/test/java/com/fedx/service/ClusterManagementServiceTest.java)
  ⎿  Error editing file

⏺ Update(service/src/test/java/com/fedx/service/ClusterManagementServiceTest.java)
  ⎿  Error editing file
  ⎿  Interrupted by user

As you can see above, it will at times figure out the correct path but it's grinding development nearly to a standstill. With a new session this doesn't happen initially, it works fine. But over time the frequency grows and makes the session nearly unusable. So we have to lose our context and start over.

So I tried to be clever and create a PreToolUse hook. Here's the script executed by the hook:

echo "running fedx-path-validation.sh" >> ~/tmp/fedx-path-validation.log

# Read JSON from stdin
json_input=$(cat)

# Extract the file_path from tool_input using jq
file_path=$(echo "$json_input" | jq -r '.tool_input.file_path // empty')

echo "file_path=$file_path" >> ~/tmp/fedx-path-validation.log

# Check if file_path exists and contains "/fedx/"
if [[ -n "$file_path" && "$file_path" == *"/fedx/"* ]]; then
    # Replace /fedx/ with /fedex/ to create the corrected path
    corrected_path="${file_path//\/fedx\//\/fedex\/}"
    
    # Output error message to stderr and exit with status 2 to block the tool
    echo "The file path $file_path is invalid. It should be $corrected_path." >&2
    exit 2
fi

# If no issues found, allow the tool to proceed
exit 0

And here's some of the output of the log file:

...
running fedx-path-validation.sh
file_path=./service/src/test/java/com/fedex/service/ClusterManagementServiceTest.java
running fedx-path-validation.sh
file_path=./service/src/test/java/com/fedex/service/ClusterManagementServiceTest.java

The hook executes successfully but only executes when the path is valid so it's apparently running after path validation. That's understandable but I'm left without a solution to the problem and our project suffers.

The line provided in CLAUDE.md is:

- **YOU MUST** use 'fedex' and never 'fedx'. this applies everywhere, especially in file paths and package names for java classes.

I'm open to any ideas as this is a significant and unexpected problem for us.

View original on GitHub ↗

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