claude-code - 💡(How to fix) Fix [BUG] Tool instructions should tell the LLM how to read error codes [1 comments, 2 participants]

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…
GitHub stats
anthropics/claude-code#48505Fetched 2026-04-16 06:58:19
View on GitHub
Comments
1
Participants
2
Timeline
5
Reactions
0
Author
Timeline (top)
labeled ×4commented ×1

Error Message

Error Messages/Logs

RAW_BUFFERClick to expand / collapse

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • I am using the latest version of Claude Code

What's Wrong?

claude regularly fails to notice and react to the result codes of command lines, and it struggles to recover them, wasting time, bloating context, costing tokens (and this hurts especially now, since the subscriptions were shrinkflated), and wasting developer time.

What Should Happen?

The Bash() and all command-line tools need to inform the LLM that they will send it a result code on failure, and to interpret the lack of a result code as the tool returning 0, which is almost always success. In addition to the tool instruction changes, the tools should also send it text when the result code is 0. Finally, the Bash() tool should also tell the LLM that piping output through a program like tail hides the result code (or it should set the relevant bash string mode options).

Watching the claude CLI TUI fail to use even basic system tools correctly like this is, frankly, embarrassing and frustrating, adding lag and cost for no reason. A billion dollar company really should have a best-in-breed TUI and integrate well with the non-webby ecosystem.

Error Messages/Logs

Steps to Reproduce

Tell it to use make test and what it flail.

Claude Model

None

Is this a regression?

Yes, this worked in a previous version

Last Working Version

No response

Claude Code Version

2.1.109 (Claude Code)

Platform

Anthropic API

Operating System

Ubuntu/Debian Linux

Terminal/Shell

Windows Terminal

Additional Information

No response

extent analysis

TL;DR

The claude tool needs to be modified to correctly interpret result codes from command-line tools and handle cases where the result code is not explicitly sent.

Guidance

  • The Bash() tool should be updated to inform the LLM that it will send a result code on failure and that the lack of a result code indicates success (return code 0).
  • The tools should send text output when the result code is 0 to provide feedback to the LLM.
  • The Bash() tool should handle cases where output is piped through programs like tail, which can hide the result code, by setting relevant bash string mode options or providing alternative instructions to the LLM.
  • Investigate the regression by comparing the current version (2.1.109) with the previous working version to identify the changes that caused the issue.

Example

No code snippet is provided as the issue does not contain sufficient technical details to create a specific example.

Notes

The issue lacks information about the previous working version, which could help in identifying the root cause of the regression. Additionally, the claude tool's internal implementation and the Anthropic API's behavior are not well-documented in the issue, making it challenging to provide a comprehensive solution.

Recommendation

Apply workaround: Modify the Bash() tool to handle result codes and provide feedback to the LLM as described in the guidance section, as the root cause of the issue seems to be related to the tool's behavior rather than a version-specific bug that could be fixed by upgrading.

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