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.
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.
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.
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.
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.
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-pattern | Example | Effect on a frontier model |
|---|---|---|
| Verification rituals | double-check your work, verify twice before responding | Often taken literally; duplicated work and tokens |
| Thoroughness and emphasis boosters | Be maximally thorough, CRITICAL: YOU MUST ALWAYS… | Can produce verbosity and extra tool calls |
| Mandatory procedures and scratchpad scaffolds | think step by step in a scratchpad | Can duplicate the model's native reasoning |
| Stale examples | Few-shot examples tuned to an older model's failure modes | May imitate long reasoning chains on requests that do not need them |
| Contradictory rules | always refund within policy vs never issue refunds without escalation | May be followed more literally, degrading performance |
| Dated configuration | Manual thinking budgets written for an older generation | May 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¢.
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.
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.
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.
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.
| Model · benchmark | low | max | Blog reading |
|---|---|---|---|
| Fable 5 · FrontierCode Diamond (hardest 50 tasks) | 11.5% · $5.35 / task | 30.9% · $19.00 / task | About 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 / question | about 61% · about $2.23 / question | The 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.2 | Fable 5.1 at low matches Fable 5 at high at a third of the cost | no numeric labels on Figure 5 | Cache 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.
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.
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.
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.
| Benchmark | Lever | Cost change | Cost | Score change and 95% CI |
|---|---|---|---|---|
| tau2-bench retail | caching with explicit breakpoints | −72.7% | $25.88 → $7.05 | +1.3pp (−4.6 to +7.2) |
| LegalBench | shared-prefix caching + low + Batch API | −57.6% | $13.67 → $5.79 | −0.3pp (−0.8 to +0.3) |
| OfficeQA Pro | batching + document caching | −52.4% | $136.20 → $64.87 | +4.5pp (−2.1 to +11.1) |
| SWE-bench Verified | medium + 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.
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.
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.
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.
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.
| Item | Note |
|---|---|
| One difference from the documentation page | In 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 baselines | In 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 points | The 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 side | For 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 price | The 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 blog | customer 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 identity | Lance 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. |