Skip to content

CCAR-P · Domain 4: Evaluation, Testing, and Optimization · 17% of the exam

Task 4.6: Cost and Latency Optimization

Reading cost and latency data, cache hit rates included, to see where spend or delay piles up, and choosing the change that cuts it while quality stays above its floor.

Study it

  • Cost and latency telemetry, cache hit rates and the quality floor

    Partly covered by: The KV Cache

Sample questions

Try each one before opening the answer. Every option is explained, with the Anthropic documentation page that proves it.

Question 1 · choose 1

A company's 300 developers use Claude Code through Amazon Bedrock, and monthly spend has doubled. Finance can see the total on the AWS bill but needs to know which developers and which activities the spend is concentrated in, so that it can target savings without cutting the work that needs the strongest model. Which telemetry source gives that breakdown?

  1. AThe Claude Code Analytics API, called with an Admin API key from the company's Claude Console organization
  2. BOpenTelemetry metrics exported from each developer's Claude Code to the company's observability stack
  3. CThe Claude Code analytics dashboard, which shows sessions and spend for every member of the organization
  4. DThe /usage command, run by each developer at the end of every session and collected in a shared spreadsheet
Show the answer and why
  • AThe Claude Code Analytics API, called with an Admin API key from the company's Claude Console organization

    Incorrect

    Claude Code doesn't send metrics from the cloud provider back to Anthropic, so that API doesn't cover Bedrock usage.

  • BOpenTelemetry metrics exported from each developer's Claude Code to the company's observability stack

    Correct

    OpenTelemetry export gives per-user token counts, costs and tool activity regardless of the provider.

  • CThe Claude Code analytics dashboard, which shows sessions and spend for every member of the organization

    Incorrect

    The analytics dashboards don't cover usage billed through a cloud provider such as Bedrock.

  • DThe /usage command, run by each developer at the end of every session and collected in a shared spreadsheet

    Incorrect

    /usage reports one person's session; it isn't an organization-wide telemetry stream for per-user attribution.

On Amazon Bedrock, Google Cloud's Agent Platform and Microsoft Foundry, Claude Code is billed per token to the cloud account, and Claude Code does not send metrics from the cloud back to Anthropic, so the analytics dashboards and the Claude Code Analytics API don't cover that usage. For per-user cost attribution, export OpenTelemetry metrics from each machine, or route traffic through a gateway that attributes usage per user.

Question 2 · choose 2

A platform team reviews a month of Claude Code token telemetry for its TypeScript monorepo. About a third of input tokens come from Claude reading full test and build logs of thousands of lines to find a few errors, and about a quarter come from exploring unfamiliar code with grep followed by reading many candidate files. Architecture work must stay on the current model. Which TWO optimizations reduce the spend without lowering that quality floor? (Choose TWO.)

  1. ASwitch every session to a lower-cost model, including the architecture sessions, so that each token in both patterns costs less
  2. BAdd a hook that filters test and build output down to the error lines before Claude reads it
  3. CMove the guidance on reading logs into the project's CLAUDE.md, so that it loads once at the start of each session instead of on demand
  4. DInstall a code intelligence plugin for TypeScript, so that Claude jumps to definitions
  5. EAdd custom compaction instructions that keep the full log text in every summary, so that Claude never has to read a log twice
Show the answer and why
  • ASwitch every session to a lower-cost model, including the architecture sessions, so that each token in both patterns costs less

    Incorrect

    The stem keeps architecture work on the current model; the guidance reserves the stronger model for complex architectural decisions.

  • BAdd a hook that filters test and build output down to the error lines before Claude reads it

    Correct

    A hook can preprocess data, such as returning only matching error lines, cutting context from tens of thousands of tokens to hundreds.

  • CMove the guidance on reading logs into the project's CLAUDE.md, so that it loads once at the start of each session instead of on demand

    Incorrect

    CLAUDE.md loads into every session; it adds context rather than removing the log text Claude reads.

  • DInstall a code intelligence plugin for TypeScript, so that Claude jumps to definitions

    Correct

    One go-to-definition call replaces a grep followed by reading several candidate files.

  • EAdd custom compaction instructions that keep the full log text in every summary, so that Claude never has to read a log twice

    Incorrect

    Token costs scale with context size; carrying full logs through each compaction keeps the costly text in context.

Claude Code's cost guidance lists ways to keep context small: hooks can preprocess data before Claude sees it, such as grepping a long log for errors; code intelligence plugins give precise symbol navigation instead of text search and multiple file reads; and token costs scale with how much context Claude processes. Model choice is a lever too, but here the quality floor keeps architecture work on the stronger model.

Question 3 · choose 1

A developer reads the Prompt cache (main) line of Claude Code's /usage and sees "2 misses" and "1 expected rebuild". The team wants to know which of these points to something worth fixing. What does the documentation say an expected rebuild is?

  1. AA miss caused by a tool definition change that the developer made on purpose
  2. BA request that hit the cache after a long idle period and refreshed the cached prefix's lifetime for later turns of the session
  3. CA miss that follows Claude Code's own rewrite of the conversation, by compaction or by clearing old tool results
  4. DA rebuild of the cache that Claude Code schedules every hour to keep it warm
Show the answer and why
  • AA miss caused by a tool definition change that the developer made on purpose

    Incorrect

    The documentation lists tool definition changes among causes of misses.

  • BA request that hit the cache after a long idle period and refreshed the cached prefix's lifetime for later turns of the session

    Incorrect

    That would be a cache read, not a rebuild.

  • CA miss that follows Claude Code's own rewrite of the conversation, by compaction or by clearing old tool results

    Correct

    Claude Code counts that kind of miss as an expected rebuild instead of a miss.

  • DA rebuild of the cache that Claude Code schedules every hour to keep it warm

    Incorrect

    The documentation describes no scheduled rebuild.

The Prompt cache (main) line in /usage summarizes the session's cache use. Misses are requests that re-processed content the cache already held, often with a likely cause such as changed tool definitions. When Claude Code itself has just rewritten the conversation, by compaction or by clearing old tool results, it counts that miss as an expected rebuild instead.

Practice domain 4 →Practice all domains →