DEV Community

Cover image for Claude Code wastes 26k more tokens than OpenCode per prompt
ironbyte-rgb for crescevo

Posted on • Originally published at ai.crescevo.com

Claude Code wastes 26k more tokens than OpenCode per prompt

TL;DR

  • Claude Code sends 33,000 tokens before reading the prompt, while OpenCode sends 7,000 tokens.
  • Claude Code is far more cache inefficient than OpenCode, rewriting tens of thousands of prompt-cache tokens mid-session.
  • A small task that cost 121,000 tokens done directly cost 513,000 tokens when fanned out to two subagents.
  • Claude Code's whole-task total came out lower than OpenCode's on a multi-step task, but this advantage did not hold on a newer model.

Claude Code and OpenCode were tested on the same model, machine, and tasks to examine their token usage. The results show that Claude Code sends significantly more tokens before reading the prompt than OpenCode. This has significant implications for the efficiency and cost of using these systems.

What the data shows

The data shows that Claude Code uses roughly 33,000 tokens of system prompt, tool schemas, and injected scaffolding before the prompt even arrives, while OpenCode uses about 7,000. Additionally, Claude Code re-writes tens of thousands of prompt-cache tokens mid-session, run after run, and on the same task writes up to 54x more cache tokens than OpenCode. This cache inefficiency results in higher costs, as cache writes are billed at a premium.

What this means for ai readers

The high token usage of Claude Code has significant implications for AI readers. For example, a production repository's 72KB instruction file adds another 20,000 tokens to every single request. Five modest MCP servers add 5,000 to 7,000 more tokens. By the time a real working setup sends its first request, it is 75,000 to 85,000 tokens deep before the user has typed a word. This can result in higher costs and reduced efficiency.

What to do right now

To minimize token usage and reduce costs, it is essential to optimize the system prompt and tool schemas. This can be achieved by caching the payload once per session and reading it back for pennies, as OpenCode does. Additionally, using a more efficient system like OpenCode can help reduce token usage and costs. It is also crucial to consider the impact of subagents on token usage, as fanning out tasks to multiple subagents can multiply the number of full baselines in flight.

Bottom line

The results of the test show that Claude Code sends significantly more tokens before reading the prompt than OpenCode, resulting in higher costs and reduced efficiency. While Claude Code's whole-task total came out lower than OpenCode's on a multi-step task, this advantage did not hold on a newer model. To minimize token usage and reduce costs, it is essential to optimize the system prompt and tool schemas and consider using a more efficient system like OpenCode.

Frequently asked questions

Q: How many tokens does Claude Code send before reading the prompt?

Claude Code sends roughly 33,000 tokens before reading the prompt.

Q: How does OpenCode's token usage compare to Claude Code's?

OpenCode sends about 7,000 tokens before reading the prompt, significantly less than Claude Code's 33,000 tokens.

Q: What is the impact of subagents on token usage?

Fanning out tasks to multiple subagents can multiply the number of full baselines in flight, resulting in higher token usage and costs. For example, a small task that cost 121,000 tokens done directly cost 513,000 tokens when fanned out to two subagents.

Q: Can Claude Code's whole-task total be lower than OpenCode's on certain tasks?

Yes, Claude Code's whole-task total came out lower than OpenCode's on a multi-step task, but this advantage did not hold on a newer model.

Sources

Related reading


Originally published on AI at Crescevo — subscribe free for more.

Top comments (0)