Claude Code cost test finds prompt-cache writes dominated one Java task
A Juejin article reported six Claude Code configurations, each run once on the same Java order-amount bug-fixing task and validated with 10 hidden tests. At list prices, reported costs ranged from $0.021 for Haiku 5.5 with medium effort to $0.694 for Opus 5.5 with medium effort. Prompt-cache writes accounted for 71% of the default run’s cost. The report says the single-run, small-task results indicate approximate magnitude rather than precise multipliers or general model performance; the safe-mode run also did less work by adding no supplemental tests.
The test provides practical evidence that model choice, effort, context configuration and cache duration were associated with materially different Claude Code token costs while all six configurations passed the same hidden tests. The safe-mode run’s lower cost cannot be attributed to configuration alone because it performed less work.
导读:最近掘金上有篇"AI 编程工具一年烧掉两台 MacBook"挺火,知乎"如何降低 Claude Code 的使用费用"也有 20 万浏览。省钱的建议网上很多,但很少有人拿同一个任务把几种设置的花费摆在一起比。我在本机用一个 Java 订单金额计算的修 bug 任务,跑了 6 种设置,每次都用 10 个隐藏用例验收,再按官方价格表把花费拆开。结论有点反直觉:这种小任务里,钱大半花在"写缓存"上,不在模型输出。
一、先说清楚:Claude Code 的钱花在哪
Claude Code 每发一次请求,都要把系统提示词、工具定义、你的 CLAUDE.md、整段对话历史一起发给模型。模型本身不记事,所以每一轮都是"从头再读一遍"。为了不重复收全价,API 有个提示词缓存:第一次读到的内容写进缓存(贵一点),之后再读同样的开头就按缓存价收(便宜很多)。
所以一次任务的账单分四块:
#Claude Code#Anthropic#Claude Opus 5.5#Claude Sonnet 5.5#Claude Haiku 5.5