---
id: 18823
lang: en
title: "A script cut eslint output for Claude Code from 673 KB to 151 bytes, beating the trim-2 model"
published_at: "2026-12-01 12:24:45"
source_name: "Habr AI"
source_url: "https://habr.com/ru/articles/1114514/?utm_campaign=1114514&utm_source=habrahabr&utm_medium=rss"
canonical_url: "https://news.hamidun.com/en/news/18823"
categories: ["llm", "autonomous"]
publisher: "AI News by Jemal Hamidun (news.hamidun.com)"
---

# A script cut eslint output for Claude Code from 673 KB to 151 bytes, beating the trim-2 model

> **Краткая суть (BLUF):** Claude Code carries long eslint, tsc, and test outputs in its context, roughly a third of the total volume. The author tested trim-2, a model that removes extra lines, and decided not to use it: with conservative retries, it came out 10% more expensive. A script that shows only new eslint violations, however, cut the output from 673 KB (2452 lines) to 151 bytes. It is cheaper to remove noise where it is generated than to have the agent guess which lines matter.  • vitest without the --reporter flag prints 9 lines on a green run • smart_max lost the needed line in 12 of 35 changed outputs • Full eslint showed 1375 old violations that nobody is fixing

If you work with Claude Code, your agent almost certainly drags around a lot of junk. It runs eslint (a linter that flags style and code errors), gets 2452 lines of text, and keeps them in context until the end of the session. In a single developer's sessions, context regularly reaches 250 thousand tokens: this happened in 48 of the last 150 sessions, with a peak of about 273 thousand. Tool output (eslint, tsc, vitest, grep, git log) takes up about a third of that volume (median 30%). When Caveman 5.1 shipped with the trim-2 model, which promises to strip everything extra from such output, the author tested it on his own data. It took a working day and about $9. He did not adopt the model, but he found an approach that worked better: the eslint output shrank from 673 KB to 151 bytes, which is a single line.

## What trim-2 is and where it stumbles

trim-2 is a small gradient-boosting model (3.5 MB, embedded in the binary). It takes the tool output and the agent's question as input and returns some of the lines in their original order. It rewrites nothing; in place of what it removes, it leaves a marker such as "… 237 lines …". Lines containing error:, exception:, traceback, panic:, fatal:, and --- FAIL: are never cut. Everything else is selected by lexical match against the question (the BM25 algorithm).

This points to the weak spots. An eslint line of the form "12:5 error ..." does not fall under the protected patterns, even though it answers the question "what broke?" A Russian question against English keywords in logs also performs poorly.

The first test ran on logs from past sessions. The author found 3153 cases where the agent later used a rare line from the output: a path, a hash, a line number. From these he took 53 outputs and ran them through three modes. trim-2 changed 35 outputs. The default mode, smart_max (38% token savings), lost the needed line in 12 of the 35 cases, balanced (21%) in 4, and conservative (19%) in 2.

## What it costs in practice

Next, the author checked whether the agent makes mistakes on truncated output. On 14 real tasks (112 calls, $2.77), the Sonnet model answered questions using three truncated variants and the full output. If the data was insufficient, it had to write NEED_MORE. In a live session, this means a second turn, this time with the full output.

There were no wrong answers on truncated output: the model saw the marker and honestly asked for more data. Two errors occurred with the full output: among 400 lines of git log, it confused two similar hashes. But when the savings were recalculated including the re-requests, the picture was this: smart_max gave -14% input tokens, balanced -3%, and conservative came out 10% more expensive than not trimming at all.

Without the eslint tasks, balanced produced 18 correct answers and 4 NEED_MORE responses, with savings from 16 to 69%. On tsc, the model cuts almost nothing: a cascade of 14 errors from one cause remained untouched, and the cut was under 5%. On vitest, balanced removed 83%, but almost all of the benefit came from outputs larger than 30 thousand characters. Claude Code doesn't put such outputs into context in full anyway: it saves the output to a file and shows a preview of about 2 KB. On a realistic 28 KB output, balanced cut the root error Cannot find module and the summary "Tests 7 failed".

## What worked instead of a proxy

The author asked himself: why guess the needed lines on the agent's side if the tool can simply not print the excess? In a Nuxt project, he did the following.

- **ESLint via baseline.** The lint:baseline script compares violations against a saved list and fails only on new ones. Full eslint printed 2452 lines (673,208 bytes), of which 1375 were old violations that nobody plans to fix. The baseline on a clean tree prints a single 151-byte line. The script was further refined to show the line:column of new violations.
- **Typecheck on the same principle:** only new errors, with their positions.
- **vitest without the --reporter flag.** Version 4.1 detects that it was launched by an agent and prints only the failing tests. On a green run, that's 9 lines (254 bytes) versus 2962 lines and 620,008 bytes with verbose. The verbose and default flags disable this mode, and agents like to add them.
- **Smaller fixes:** nuxt prepare output is now printed only on failure, the obsolete always-auth option was removed from .npmrc, and a paragraph with the correct commands was added to CLAUDE.md.

## Limitations and practical takeaway

The samples are small: 14 and 13 tasks, two runs each. A single model answered, Sonnet without tools, so a live agent might behave differently. In addition, the real benefit of the vitest mode is easy to overstate, because Claude Code already truncates large outputs on its own.

The practical takeaway is simple. First reduce output at the source: baseline scripts, a reporter mode for agents, and explicit instructions in CLAUDE.md. A model like trim-2 is worth trying only if you have third-party CLIs and logs without filters. In that case, start with conservative and be sure to test it on a dozen of your own tasks.

---
- **Первоисточник:** [Habr AI](https://habr.com/ru/articles/1114514/?utm_campaign=1114514&utm_source=habrahabr&utm_medium=rss)
- **Каноническая ссылка:** https://news.hamidun.com/en/news/18823
- **Экосистема автора:** [Бесплатный интенсив по вайбкодингу — предзапись в Нике](https://t.me/vibecodeguidebot?start=agent_intensive_news_md) · [Nomad AI](https://nomadnet.ai) · [Telegram @jemal_hamidun](https://t.me/jemal_hamidun)
