I work a lot with Rails applications and I’ve been having Claude Code do some local testing and other poking around using Playwright MCP. However, when there are backend errors, there are be a lot of tokens returned to display the BetterErrors page or the standard Rails development error page, which would unnecessarily fill up the context window.
So… I worked with Claude Code to build a new gem (PlainErrors) that is a Rack Middleware that gives streamlined error reports for LLMs.
In practice, this should let the agent do more debugging and iterating without filling up the context.
In my test with a real Rails application, PlainErrors achieves significant token reductions over both BetterErrors and the standard Rails development error page (as calculated by OpenAI’s tiktoken library):
In my test with a real Rails application, PlainErrors achieves significant
token reductions over both BetterErrors and the standard Rails development
error page (as calculated by OpenAI’s
tiktoken library):
| Metric | PlainErrors | Rails Default | BetterErrors |
|---|---|---|---|
| Bytes | 755 | 8,854 | 113,544 |
| Tokens | 217 | 2,975 (13.7x more) | 25,055 (115.5x more) |
There’s a little (mostly optional) configuration, and potentially some local tweaks to get your agent sending over the right headers or other info. (And you can also direct the agent to the gem README to install or to direct it using the query params if that’s easier than digging through Claude Code’s config files.)
As seems to be typical recently, I basically wrote no code for this, was just guiding the LLM and having it test it in an application that I was using. And cleaning up some documentation that was a bit overly verbose.
Open to any feedback if you use this on your application, think it’s cool, or have issues or missing features!