[BUG] Tool instructions should tell the LLM how to read error codes
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?
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_
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗