claude-code - 💡(How to fix) Fix Read tool: suggest alternatives when rejecting binary files

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Error Message

Minor UX improvement. Users hit this when they forget the tool's limitations and have to figure out the alternative path themselves. One extra sentence in the error saves a round-trip.

RAW_BUFFERClick to expand / collapse

Problem

When the Read tool encounters a binary file (e.g., .xlsx, .docx), it returns:

This tool cannot read binary files. The file appears to be a binary .xlsx file.

The message is accurate but unhelpful — the user needs to know what to do instead.

Suggested Fix

Append guidance based on file type:

  • .xlsx → "Use a Python script with openpyxl or pandas to read Excel files"
  • .docx → "Use a Python script with python-docx to read Word files"
  • .pptx → "Use the pptx skill or python-pptx to read PowerPoint files"
  • .pdf → "The Read tool supports PDF files — try reading it directly" (if applicable)
  • Other binary → "Use a Python script or appropriate CLI tool to process this file"

Impact

Minor UX improvement. Users hit this when they forget the tool's limitations and have to figure out the alternative path themselves. One extra sentence in the error saves a round-trip.

Environment

  • Claude Code CLI on Windows 11

extent analysis

TL;DR

Modify the error message to include guidance on alternative tools or methods for reading binary files based on their type.

Guidance

  • Identify the file type and append the corresponding guidance to the error message, such as suggesting the use of openpyxl or pandas for .xlsx files.
  • Consider adding a generic message for unsupported binary file types, directing users to find an appropriate CLI tool or Python script.
  • Review the list of supported file types to ensure accuracy and completeness of the guidance provided.
  • Test the updated error messages with various binary file types to verify the guidance is helpful and accurate.

Example

error_messages = {
    '.xlsx': 'Use a Python script with openpyxl or pandas to read Excel files',
    '.docx': 'Use a Python script with python-docx to read Word files',
    # Add more file types as needed
}

def get_error_message(file_type):
    return error_messages.get(file_type, 'Use a Python script or appropriate CLI tool to process this file')

Notes

The solution assumes that the file type can be accurately determined and that the suggested tools or methods are available and suitable for the user's environment.

Recommendation

Apply workaround: Modify the error message to include guidance on alternative tools or methods, as this provides a better user experience and helps users find an alternative solution without requiring significant changes to the existing tool.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING