In a recent LinkedIn post, Yonathan Cohen shared insights from his hands-on testing of Spotify’s optimization strategy for Claude Code, a large language model for code. Cohen detailed his experimental setup and findings regarding cost savings and performance implications when implementing a similar approach.
Cohen’s investigation focused on a technique where a less expensive model handles initial processing and boilerplate code, coupled with a mechanism to prevent Claude from opening files exceeding 350 lines. He meticulously documented his tests, comparing the performance and cost of using this setup against the standard Claude Code implementation.
“Their trick: a cheap model does the reading and the boilerplate, and a hook blocks Claude from opening any file over 350 lines.”
The journalist’s experimental results indicated that the proposed blocking mechanism did not function as expected in his tests. Cohen reported that across four real-world tasks on a substantial codebase, the block never triggered.
Analysis of the Optimization Strategy
Cohen’s findings suggest that the intended file size limitation was ineffective in his setup. He observed that Claude Code, even with the optimization attempt, continued to read large files in their entirety in certain scenarios, rather than being restricted to specific sections.
- In 2 out of 4 tasks, Claude read large files in full without the setup.
- With the setup installed, Claude searched and read sections instead of blocking.
- The block never fired in any of the 4 tasks.
The Role of the ‘Cheap Reader’ Model
A key component of the optimization strategy involved a ‘cheap reader’ model designed to handle initial data intake. However, Cohen’s tests revealed that Claude Code did not utilize this auxiliary model, instead opting for its own methods to find what it perceived as cheaper paths.
“Claude never called it. it always found a cheaper path on its own.”
This observation implies that the model’s internal cost-optimization heuristics might supersede the explicit use of an external, cheaper reader in certain contexts, negating the intended benefit of that specific component.
Cost and Performance Implications of the ‘Cheap Writer’
The testing also extended to the ‘cheap writer’ component, which was intended to reduce costs associated with generating code, such as writing type files. Cohen reported some success in this area, noting a reduction in cost for specific tasks.
“writing a type file from a 1,184-line module: $0.82 down to $0.59, Haiku included.”
Furthermore, the quality of the output from the optimized approach showed improvement in one instance, with 51 out of 57 functions covered compared to 42 without the setup. However, Cohen cautioned that this came at a significant cost in terms of speed and, in one specific test-writing task, overall expense and quality.
“the catch: 3x slower, and on a test-writing task it cost more and did worse.”
Cohen’s detailed breakdown highlights the complex trade-offs involved in optimizing LLM usage for code. While cost reductions are possible, they may be accompanied by substantial increases in processing time and potential degradation in performance for certain types of tasks. He has made the setup available for others to try.
📝 About This Content
This article is based on insights shared by Yonathan Cohen on LinkedIn.
📅 Originally posted on September 14, 2026 | View original post on LinkedIn →