Cost optimization · 2026 · Official blog · Follow-upSheet GP-COST-02 · Three commands

Reduce API costs with
three Claude Code commands

prompt-audit checks legacy prompts, cost-optimize audits API spending, and hillclimb tests configurations. In Anthropic's customer-support experiment, hillclimb moved from Opus 4.8 to Sonnet 5 and revised the prompt using failed tickets. The final configuration improved test accuracy at about one fifth the original cost.

Sourceclaude.com/blog, "Reducing cost and improving performance with Claude Platform" AuthorLance Martin · Anthropic · 2026-09-08 FollowsCost per task, not per token (2026-08-21) CoverageCommand roles · Migration tests · Configuration search · Caching
claude-api skill anthropics/skills · loaded by Claude Code prompt-audit remove anti-patterns after migration cost-optimize trace spending rank savings hillclimb split train / test search configs evaluation (eval) no eval needed dashed = effort and model tradeoffs only with an eval · solid = cannot run without one

GenAI Playbook · Official blog analysis · All benchmark results reported by Anthropic

Division of work

Audit prompts, trace spending, test configurations

Claude Code can inspect legacy prompts, audit API spending and search for lower-cost configurations. prompt-audit removes instructions that no longer suit the model; cost-optimize finds opportunities to cut API costs; hillclimb uses evaluation results to refine a configuration.

The commands are part of claude-api, a set of instructions and scripts for Claude Code in Anthropic's open anthropics/skills repository. Lance Martin, an Anthropic engineer working on Claude Platform and this skill, described their use and benchmark results in a September 8, 2026 blog post. Our earlier article, Cost per task, not per token (August 21, 2026), covers the underlying caching, prompting and effort mechanisms.

The commands differ in whether they need an evaluation, or an eval: a set of tasks for comparing accuracy and cost across configurations.

no eval needed
After a model upgrade
/claude-api prompt-audit

Checks prompts, skills and tool descriptions for instructions that no longer suit the model. Covers Claude API application code and Claude Code configuration, including CLAUDE.md and skills.

eval optional
Audit API costs
/claude-api cost-optimize

Traces token spending, then checks caching, request size, output limits and batching. Includes prompt-audit. With an eval, it also compares models and effort levels for cost and performance.

eval required
Refine a configuration
/claude-api hillclimb

Splits an eval into training and test sets. Uses failed training examples to guide changes, then scores the final configuration on the unseen test set.

Anthropic presents these as different starting points: check prompts after a model upgrade, audit costs for an API application, or use an eval to search for a better configuration. Prompt auditing and the initial cost audit can begin before an eval is available.

First lever · legacy prompts

Prompt auditing: lower cost, higher accuracy

A model upgrade can leave old instructions in place. Written to compensate for an earlier model's weaknesses, they may make a newer model repeat work or follow conflicting rules more literally. Anthropic groups these prompting anti-patterns into six categories.

Anti-patternExampleEffect on a frontier model
Verification ritualsdouble-check your work, verify twice before respondingOften taken literally; duplicated work and tokens
Thoroughness and emphasis boostersBe maximally thorough, CRITICAL: YOU MUST ALWAYS…Can produce verbosity and extra tool calls
Mandatory procedures and scratchpad scaffoldsthink step by step in a scratchpadCan duplicate the model's native reasoning
Stale examplesFew-shot examples tuned to an older model's failure modesMay imitate long reasoning chains on requests that do not need them
Contradictory rulesalways refund within policy vs never issue refunds without escalationMay be followed more literally, degrading performance
Dated configurationManual thinking budgets written for an older generationMay be rejected by the Claude Platform after an upgrade

Anthropic tested prompt-audit on a customer support benchmark during a migration from Opus 4.8 to Opus 5. Starting with a clean prompt, the team planted one anti-pattern at a time: a retired thinking setting, a pair of contradictory refund rules, a manual scratchpad, verify twice, be maximally thorough and a mandatory six-step procedure. This produced six legacy prompts.

Each prompt was evaluated in three configurations: Opus 4.8, Opus 5 with only the model ID changed, and Opus 5 after /claude-api prompt-audit had been run once on that prompt. Figure 3 averages the six prompts. In the text, the audit decreased cost by 14.6% and increased accuracy by 5.3% on average. The figure shows Opus 4.8 legacy at 2.52¢ and 89.4%, Opus 5 unaudited at 3.43¢ and 91.7%, and Opus 5 audited at 2.93¢ and 97.0%. It annotates the audit step as +5.3 pts and −0.49¢.

2.0¢2.5¢3.0¢3.5¢4.0¢ 859095100 cost per ticket (cents) accuracy (%) model ID changed only one prompt-audit pass: +5.3 pts, −0.49¢ Opus 4.8 · legacy 2.52¢ · 89.4% Opus 5 · unaudited 3.43¢ · 91.7% Opus 5 · audited 2.93¢ · 97.0%
Figure 3 · customer support benchmark, average across six legacy prompts · redrawn from the blog's Figure 3

The blog attributes the cost drop to the removal of extra tool calls and duplicated reasoning. On Opus 5, verify twice duplicated the order lookup on every refund. The instruction be maximally thorough triggered dozens of unneeded knowledge-base searches.

Three specific failures explain the accuracy improvement in the blog's account:

  • A retired thinking setting caused the API to reject every routing request.
  • Conflicting refund rules led Opus 5 to withhold four refunds it owed while asking the customer to confirm.
  • A manual scratchpad interfered with Opus 5's built-in thinking. On three tickets, the model wrote a tool call inside its reasoning but never executed it.
Related: prompt-induced waste

Prompt-induced waste covers user prompt wording that assigns an agent extra work; here, instructions written for an older model are being followed literally by a newer one.

The 14.6% cost reduction and 5.3% accuracy increase were measured using an evaluation. Without one, the anti-patterns can still be removed, but their effect on task performance cannot be measured. The same applies to the effort tradeoff.

Second lever · effort

What does higher effort buy?

effort controls how much work Claude puts into a task, from low through medium, high and xhigh to max. Lower settings generally produce conclusions faster; higher settings allow more deliberation, verification and exploration of alternatives. The three comparisons below show how the returns vary by task and model.

On FrontierCode, Cognition's coding benchmark, Fable 5 completed the Diamond subset of the 50 hardest tasks with a score of 11.5% at low, costing $5.35 per task. At max, it reached 30.9% at $19.00 per task. Raising effort therefore produced about 2.7x the score (+19 points) for about 3.5x the cost. Figure 4 annotates the difference as +19.4 pts; it does not label the intermediate levels with point values.

$5$10$20 0102030 mean cost per task (USD, log scale) score (%) lowmedhighxhighmax 11.5% · $5.35 / task 30.9% · $19.00 / task +19.4 low to max, at about 3.5× the cost
Figure 4 · Fable 5 · FrontierCode Diamond (hardest 50 tasks) · the three middle points keep the source shape without values · redrawn from the blog's Figure 4

The final effort increase delivered less on Humanity's Last Exam, the 2,500-question expert-level benchmark from the Center for AI Safety and Scale AI. In Anthropic's test without tools, Fable 5.1 scored about 53% at low for about $0.30 per question and about 61% at max for about $2.23. The last step to max added about half a point for 46% more cost. The blog places that gain within normal run-to-run variation and concludes that the extra spending bought no measurable improvement.

A newer model can also change the tradeoff. On CursorBench 3.2, Cursor's agentic coding benchmark built from real Cursor sessions, Fable 5.1 at low matches Fable 5 at high at a third of the cost. The blog attributes the difference to less work per task at low effort and cheaper prompt-cache reads: $0.25 per million tokens for Fable 5.1, compared with $1.00 for Fable 5. Even at Fable 5's prices, Fable 5.1 at low effort would cost about 40% less. Figure 5 shows the curves' relative positions without numeric point labels.

$2$3$5$10$20 60657075 cost per task (USD, log scale) score (%) lowmediumhighxhighmax lowmediumhighxhighmax Claude Fable 5 Claude Fable 5.1 source figure has no numeric labels; relative position only
Figure 5 · Fable 5 vs Fable 5.1 · CursorBench 3.2 · the source figure has no numeric labels; relative position only · redrawn from the blog's Figure 5
Model · benchmarklowmaxBlog reading
Fable 5 · FrontierCode Diamond (hardest 50 tasks)11.5% · $5.35 / task30.9% · $19.00 / taskAbout 2.7x the score (+19 points) for about 3.5x the cost; Figure 4 annotates +19.4 pts
Fable 5.1 · Humanity's Last Exam (without tools)about 53% · about $0.30 / questionabout 61% · about $2.23 / questionThe last step to max adds about half a point for 46% more cost, within run-to-run noise
Fable 5.1 vs Fable 5 · CursorBench 3.2Fable 5.1 at low matches Fable 5 at high at a third of the costno numeric labels on Figure 5Cache reads $0.25 vs $1.00 per million tokens; about 40% less even at Fable 5's prices

Effort can be set too high or too low, the blog cautions. At high effort, Claude may deliberate longer than a task warrants, adding cost and latency and potentially reducing answer quality. At low effort, it may stop before gathering enough evidence. As the source puts it, "it may answer from the first search result instead of the third." It may also skip checks it would otherwise perform, leaving an apparently complete answer based on partial information.

To calibrate effort, Anthropic suggests testing stronger models at lower settings and measuring performance across effort levels. If an eval is not already saturated and the performance-cost curve stays flat, the task may not be limited by thinking compute. Increasing effort would then offer no benefit. hillclimb automates this search across models and effort levels.

Configuration search · hillclimb

Hillclimb: switch models, then learn from failed tickets

hillclimb splits an eval into training and test sets. It proposes configuration changes, tests them on the training set and reads failed examples to guide further changes. The held-out test set remains unseen until the final configuration is scored. The run, again on a customer support benchmark, measures decision accuracy.

Start: Opus 4.8 at the default high effort setting

Figure 6 gives this starting configuration a train-split accuracy of 74.4%. Its cost is not labelled on the figure.

Move to Opus 5 at low and apply prompt-audit

The audit removed mandatory tool-call rituals, scratchpad steps, and contradictory rules. Train accuracy rose to 98.9%, while cost fell to 2.6 cents per ticket.

Drop to Sonnet 5 at low

Cost fell again, to 1 cent per ticket, but train accuracy dropped to 88.9%.

Refine the prompt using failed tickets

Claude added routing rules and a refund-cap cross-reference to the prompt. Those additions brought Sonnet 5 back to 98.9% at the same cost.

60708090100 cost per ticket (cents, log scale) decision accuracy (%, train split) starting accuracy, 74.4% 1 · Opus 4.8 · high baseline (cost unlabelled in source) 2 · Opus 5 · low higher tier + audited prompt · 2.6¢ 3 · Sonnet 5 · low drop to Sonnet 5 · 1¢ 4 · Sonnet 5 · low routing rules + refund cap · 1¢ search path · training-set results
Figure 6 · the adopted hillclimb path; the y-axis is the train-split reading · redrawn from the blog's Figure 6
90.5%
Final configuration on the 14 held-out tickets
78.6%
Original configuration on the same held-out tickets
≈ 1/5
Cost of the final configuration relative to the original

On the 14 held-out tickets, the final configuration reached 90.5% decision accuracy, compared with 78.6% for the original, at about one fifth the cost. These are test-set results, separate from the training-set comparison of 98.9% against the 74.4% baseline. Switching to Sonnet 5 initially reduced training accuracy. Reading the failed tickets and adding prompt rules restored it without increasing cost. The search changed the model, effort and prompt, then tested the resulting configuration on tickets it had not seen.

Cost auditing · cost-optimize

Four benchmarks, different sources of savings

cost-optimize starts by tracing API spending. It first looks for organization usage and cost reports through a Claude Admin API key. If the application logs the usage object from each response, it can use those records instead. If neither is available, it estimates costs from the code that constructs requests.

The command ranks prompt caching first, followed by trimming what each request carries, including running prompt-audit. It then bounds output and moves unattended work to the Batch API. Only when an evaluation is available does cost-optimize calculate cost and performance across effort levels and model choices.

Anthropic ran the command on four public benchmarks, each beginning with Sonnet 5.

On LegalBench, a legal-classification benchmark, it proposed caching a shared prefix, using low effort, and sending tasks through the Batch API. Thinking tokens fell from 102,779 to 8,284, the pass rate remained within noise, and cost was ~58% lower.

On tau2-bench retail, the retail scenario of a customer-service agent benchmark, explicit prompt-cache breakpoint placement reduced cost by 73% while keeping the pass rate flat.

On OfficeQA Pro, a document question-answering benchmark, batch processing and document caching reduced cost from $136.20 to $64.87, a reduction of ~52%.

On SWE-bench Verified, an agentic coding benchmark, the default configuration already cached correctly. Savings came from setting effort to medium and restricting the agent's output to a few concise sentences. Median steps per task fell from 29 to 17, while prompt tokens fell from 75.2M to 33.7M, producing ~55% lower cost.

cost per run, as a share of baseline score change (percentage points) -12-8-40+4+8+12 0%25%50%75%100% tau2-bench retail customer-service agents −72.7% $25.88 → $7.05 +1.3pp 95% CI −4.6 to +7.2 LegalBench legal classification −57.6% $13.67 → $5.79 −0.3pp 95% CI −0.8 to +0.3 OfficeQA Pro document Q&A −52.4% $136.20 → $64.87 +4.5pp 95% CI −2.1 to +11.1 SWE-bench Verified agentic coding −55.1% $39.74 → $17.86 −3.3pp 95% CI −9.6 to +3.1 share of baseline cost score change (pp) with 95% CI baseline Sonnet 5 throughout · all four confidence intervals span zero · redrawn from the blog's Figure 7
Figure 7 · cost and score change across four public benchmarks after cost-optimize · redrawn from the blog's Figure 7
BenchmarkLeverCost changeCostScore change and 95% CI
tau2-bench retailcaching with explicit breakpoints−72.7%$25.88 → $7.05+1.3pp (−4.6 to +7.2)
LegalBenchshared-prefix caching + low + Batch API−57.6%$13.67 → $5.79−0.3pp (−0.8 to +0.3)
OfficeQA Probatching + document caching−52.4%$136.20 → $64.87+4.5pp (−2.1 to +11.1)
SWE-bench Verifiedmedium + bounded output−55.1%$39.74 → $17.86−3.3pp (−9.6 to +3.1)

Cost and score changes from Figure 7; the lever column from the prose. Baseline is Sonnet 5 throughout. pp = percentage points; 95% CI = confidence interval of the score change.

All four score-change confidence intervals span zero. The source of the savings differs: caching accounts for the reduction on tau2-bench retail, while SWE-bench Verified already cached correctly and benefited from lower effort and shorter output. cost-optimize starts with the application's spending and chooses the relevant changes.

Third lever · caching

Cache diagnostics, stable prefixes and timing

Claude Console can explain cache misses, and the cache diagnostics API can identify where consecutive requests diverge. Alongside those diagnostics, the blog describes ways to keep prefixes stable and time cache updates. Our earlier article, Building an agent harness from scratch, covers the underlying mechanism.

For stable prefixes, the blog recommends deferring rarely used tools with defer_loading: keep their declarations, but leave them out of the cached prefix until Claude finds them through tool search. System instructions can be updated by appending a message rather than editing the original system prompt. Static content, including tools and system instructions, comes before the growing conversation.

Claude Console cache diagnostics panel: cache read ratio 71.3%, cache read tokens 12.4B, and Claude Opus 5 missed tokens broken down by Messages, System, Tools and Model changed
SourceFigure 1 · Claude Console cache diagnostics: read ratio, read tokens, and missed tokens by reason · [official] claude.com/blog, Figure 1
System instructions globally cached Tools globally cached CLAUDE.md, memory cached per project Session state cached per session Messages grows each turn stable → volatile
Figure 2 · request layout: static context first, the growing conversation behind it · redrawn from the blog's Figure 2

For model or effort changes, the blog recommends making them when the cache will already be rewritten, such as during conversation compaction. As a conversation grows, the cache breakpoint moves with it; automatic caching can place the breakpoint on the last cacheable block.

Pre-warming handles the initial cache write in advance. A request with max_tokens: 0 and an explicit cache breakpoint processes and stores the prompt without generating output. Sent at session start, for example while a user is typing, it lets the first real request read a warm cache.

Time spent waiting for tools counts toward the cache lifetime. The 5-minute TTL starts when the request begins. If a tool or subagent takes longer than 5 minutes, the parent cache may expire before the result returns. The next turn must rewrite it at 1.25× the input price, or 2× for a 1-hour cache. For long waits, the blog suggests considering a 1-hour TTL on the prefix.

Changing effort without invalidating the cache

Because thinking and effort settings are rendered ahead of the prompt content, changing them normally breaks the cache. With Claude Opus 5 and Fable 5.1 specifically, effort can change during a conversation without breaking it. Forked subagents and branches share the parent's cache only when the prefix remains byte-identical and they use the same model at the same effort.

Provenance

Sources and measurement notes

All measured results come from Anthropic, not independent reproductions. The blog does not provide run counts or noise bands. Figure 7 separately reports 95% confidence intervals for score changes on four benchmarks; all span zero. The notes below distinguish the blog's prose, its figures and the earlier documentation page.

ItemNote
One difference from the documentation pageIn Figure 3, the accuracies of Opus 4.8 with the legacy prompt and of Opus 5 unaudited are 89.4% and 91.7%; the documentation page Optimizing for cost and intelligence (the table in the previous article) gives 89.5% and 91.8%, a 0.1-point difference. Both sources give the same costs: 2.52¢ / 3.43¢ / 2.93¢. This piece follows the blog figure and leaves the earlier article unchanged. The figure annotation −0.49¢ and the prose figure of 14.6% are each reported where they appear, without arithmetic conversion.
Training and test baselinesIn the hillclimb run, 74.4% is the train-split starting reading (Figure 6 annotation) and 78.6% is the original configuration's reading on the 14 held-out tickets (prose). 98.9% is train; 90.5% is held-out.
Unlabelled chart pointsThe med / high / xhigh points of Figure 4, every point of Figure 5, and the starting cost in Figure 6 carry no numbers on the figures, and none are supplied here; the redrawn charts keep the shape only.
Prose and figure readings side by sideFor FrontierCode Diamond the prose says "+19 points" and Figure 4 annotates +19.4 pts; for the four benchmarks the prose says ~58% / 73% / ~52% / ~55% and Figure 7 shows −57.6% / −72.7% / −52.4% / −55.1%.
Cache read priceThe blog says only that cache reads are billed "at a fraction of the full input price" and gives no multiplier; 0.1× is the documentation page's figure and is not used here. The $0.25 versus $1.00 per million tokens in the CursorBench comparison are the two models' list prices for cache reads.
Benchmark names as in the blogcustomer support benchmark, FrontierCode Diamond (the hardest 50 tasks), Humanity's Last Exam (without tools), CursorBench 3.2, LegalBench, tau2-bench retail, OfficeQA Pro, SWE-bench Verified. The blog does not say whether the support benchmark used for hillclimb is the same dataset as the one used in the prompt-audit test; "again on a customer support benchmark" refers to the shared name. The provenance of the three benchmarks (Cognition / Cursor / Center for AI Safety and Scale AI) comes from their own sites, not from the blog.
Author identityLance Martin's role is taken from the ai.engineer speaker page (an Anthropic member of technical staff working on Claude Platform and the claude-api skill in Claude Code, previously an early LangChain engineer), not from the blog text.