Which Claude Code Changes Cut Cost per Accepted Fix?
Use Claude Code OpenTelemetry or Agent SDK result data to price eight changes against the same acceptance checks. Compare dollars per accepted fix and require the candidate to match the baseline pass count.
Test four ways to spend fewer tokens per attempt
Replay a set of comparable tickets from the same starting commits, changing one thing per trial. First, give Claude Code the failing test and likely paths to narrow the initial search. Second, replace full logs with the first failing assertion and a bounded excerpt, keeping the complete log available on request. Third, specify the deliverable and skip a second narrative when the diff and test result already show the work. Fourth, try a lower-priced model on mechanical fixes while holding the acceptance suite constant. Record the final outcome and spend for every ticket, including failures and any escalation. In an illustrative ten-ticket replay, a $6 candidate with six passes costs $1.00 per accepted fix, versus $0.90 for a $9 baseline with ten passes. Claude Code’s OpenTelemetry export provides one place to collect usage across developers.
Manage costs effectively - Claude Code DocsTest four ways to stop buying the same context
Fifth, keep shared instructions and tool definitions in the same order across comparable runs. Sixth, feed changing ticket data after the stable portion; when you control the Messages API request, put an explicit cache breakpoint at the boundary and check the resulting usage counters. Seventh, group independent runs that use the same prefix into a short burst and compare their measured cache reads and writes against spaced-out runs. Eighth, reuse a validated diagnosis and only the relevant evidence when restarting after a failed edit, then check whether the shorter restart preserves acceptance. Price each intervention using fresh input, cache reads, cache writes, and output separately. Rising write tokens with little corresponding read volume signal that the new workflow is paying to create entries it rarely reuses. Keep each model and cache lifetime on its own ledger row.
Prompt caching - Claude Platform DocsMeasure accepted work before changing settings
Start with a small set of representative tasks, such as a mechanical rename, a test repair, and a change that crosses module boundaries. Run each with your existing Claude Code configuration and API authentication. Read the Session block in /usage and record the model, token usage, number of attempts, and acceptance result for each task. Apply the same review and test criteria to every run.
Choose the first intervention from the baseline. If input dominates on unrelated tasks, try fresh sessions with a focused file list, a shorter project brief, and only the integrations the task needs. If a mechanical task costs more than expected, try a lower-priced model on that same class. Keep the change when spend per accepted result falls and the review criteria still pass.
Manage costs effectively - Claude Code DocsPreserve the context that earns cache hits
A shorter prompt helps when the material would otherwise be processed as fresh input. For related turns that reuse the same instructions and tool definitions, test whether preserving that stable prefix produces more cache reads. Anthropic's API caching works on prompt prefixes. In a Claude Code trial, compare the usage you observe across related turns with the usage after starting a fresh session for each turn.
Keep a conversation together while its earlier context is still useful, then start a clean session at the next unrelated task. If cache reads stay low, check whether common material changed before the repeated portion or whether the relevant prefix meets the minimum length for the exact model. A useful change lowers total input-related cost after accounting for writes as well as reads.
Prompt caching - Claude Platform DocsPrice the rerun before routing the task
In an illustrative Haiku 4.5 trial, suppose a baseline fix uses 80,000 fresh input tokens and 10,000 output tokens. At Anthropic's listed rates of $1 and $5 per million tokens respectively, it costs $0.13. A focused run on the same model with 30,000 fresh input tokens and 6,000 output tokens costs $0.06. This example assumes zero cache charges and separate tool fees.
Two attempts at $0.06 cost $0.12, and three cost $0.18. A small first-attempt saving can disappear when the cheaper workflow needs more corrections. Before projecting monthly spend, confirm the exact model and provider rates, including cache read and write rates, and count every attempt required to meet the same acceptance criteria.
Plans & pricing | Claude by AnthropicSeparate batchable work from interactive fixes
Look for expensive subtasks that can run independently, such as classifying a fixed set of test failures from saved logs. Anthropic's Message Batches API processes requests asynchronously. Evaluate it as a separate API workflow for work that can wait. Keep an interactive Claude Code session for fixes where the next step depends on inspecting a file, making an edit, or seeing a fresh test result.
Run the same sample through the current workflow and the proposed batch process. Keep task identifiers with the results so you can count missing outputs and identify items that need a rerun. Choose batching when the accepted outputs arrive before your deadline and total spend per accepted item drops, including any follow-up needed to finish unusable items.
Batch processing - Claude Platform Docs