🎓 Claude Certification Prep

Home › CCAR-P › M02

Claude Models, Prompting, and Context Engineering

Domain 2 13% of exam 48 practice questions ~18 min read

Selecting the model tier that satisfies every latency, cost, and quality constraint; diagnosing system prompts; selecting prompting techniques; token economics and prompt caching; cache breakpoints and Skill packaging; reasoning effort and the context lifecycle (context editing, compaction, memory tool).

Skills measured in this domain:
  • Model Tier Selection: binding latency, cost, and quality constraints
  • System Prompt Diagnosis and Revision: underspecified system prompts
  • Prompting Technique Selection: zero-shot, few-shot, prompted reasoning vs native thinking, structured output
  • Context Composition and Token Economics: context composition and caching against a token budget
  • Cache Breakpoints and Reusable Packaging: modular or Skill-based packaging
  • Reasoning Effort and Context Lifecycle: context editing, memory tool, compaction

Domain overview

Domain 2 accounts for 13% of the CCAR-P exam, about 8 of the 60 scored items. Items usually present a workload with figures (call volume, prompt length, SLA, budget) and ask which configuration meets every constraint without wasting tokens.

Skill Key question
Model tier selection What is the cheapest tier that meets every constraint? Which constraint does each rejected option violate?
System prompt diagnosis What is the prompt missing, and what does it have too much of?
Prompting technique Which technique fixes the observed failure at the lowest cost?
Context & token economics Where are the tokens going, and which ones can be dropped?
Cache breakpoints & packaging Does the stable content come before the changing content?
Effort & context lifecycle What keeps quality up over a long session?

Model tier selection

Model lineup in the sources

Model ID Input / Output ($/MTok) Notes
Claude Fable 5.1 claude-fable-5-1 $10 / $50 Most capable of the broadly released models; thinking always on; requires 30-day retention, does not run under ZDR unless Anthropic approves
Claude Opus 5.5 claude-opus-5-5 $4 / $20 Default model; default effort medium; thinking cannot be disabled
Claude Sonnet 5.5 claude-sonnet-5-5 $2 / $10 Default effort high
Claude Haiku 5.5 claude-haiku-5-5 $0.10 / $0.50 Applies to prompts ≤ 100K; above that threshold, $0.50 / $2.50
Claude Haiku 4.5 claude-haiku-4-5 $1 / $5 200K context (5.x models: 1M)

The cost documentation also mentions Claude Fable 5.2 ($8 / $40). The Claude Platform 101 course still uses Haiku 4.5 as its example. In the exam, use exactly the model names the item gives.

Selection process

  1. Eval first. Take 20–30 representative examples from the real workload, run them from Haiku upward, and stop at the cheapest model whose output you would be confident shipping.
  2. Compare by cost per completed task, not price per token. The same passage takes about 30% more tokens on Claude 4.7 and later. More capable models often finish hard work in fewer turns.
  3. By situation:
    • High-volume work with verifiable output: try Claude Haiku 5.5 first.
    • High cost but acceptable quality: lower effort on the current model.
    • Quality still short of the bar: restore effort, then try the next tier up at default effort.
  4. Route by type of work within the same endpoint: Haiku for classification, Sonnet for drafting, Opus for complex cases.

More capable models are far stronger on ambiguous problems and long tasks, where one wrong step drags down every step after it. Smaller models are faster and suit narrow, well-defined tasks.

Exam trap

When an item asks why an option is rejected, identify the specific constraint it violates:

  • A frontier tier exceeds the cost ceiling, or cannot be used under ZDR.
  • Haiku misses the quality threshold on the hard tail.
  • Batch violates latency because it can take up to 24 hours.

Choosing "the most capable model to be safe" is almost always wrong.

Scenario example

A system classifies 2 million emails per day. Constraints: p95 under 2 seconds, accuracy ≥ 97% on the labeled set, low budget.

Reasoning: try Claude Haiku 5.5 first; classification does not need thinking. If it reaches 97%, stop there. If it fails only on the ambiguous emails, route just that group to a higher tier instead of upgrading the whole flow.

(Sources: Anthropic Academy: Claude Platform 101 — Choosing the right model; Anthropic Academy tutorial: Choosing a Claude model for knowledge workers; Claude Docs: Optimizing for cost and intelligence; Anthropic Skills: claude-api)

System prompt diagnosis and revision

Underspecification

The tutorial Write a prompt your app can ship suggests a test: give the prompt to a colleague who has never seen the app. Any question they would ask back is something Claude would also have to guess. Each question falls into one of three parts:

Part Tells Claude Symptom when missing
Context Where the output is used, who reads it, whether anyone reviews it first Generic content, sensitive details exposed on the lock screen
Output format Length, whether to use Markdown ** shows up verbatim in an SMS
Constraints What it must stick to or avoid Gives advice outside its remit, leaves [phone number] unfilled

The rule: write context as facts; write format and constraints as instructions, adding the reason for any instruction whose purpose Claude cannot infer on its own. In addition:

  • Open with a clear action verb.
  • Always include output guidelines.
  • Add process steps only for complex problems.
  • Use descriptive XML tags (<sales_records>, <docs>) to separate data from instructions.

In the course, rewriting the first sentence for clarity raised the eval score from 2.32 to 3.92. Adding specific guidelines raised it further to 7.86.

Over-constraining

Prompts written for older models are often over-specified for newer models.

Anti-pattern Example Consequence
Verification ritual "verify twice" Duplicate lookups, wasted money
Emphasis booster "Be maximally thorough", "CRITICAL: YOU MUST ALWAYS…" Verbose output, dozens of extra searches
Scratchpad, mandatory procedure "think step by step in a scratchpad" Stacks on top of native reasoning, lowers accuracy
Outdated few-shot Examples tuned to an older model's mistakes The model reasons at length on simple requests
Conflicting rules "always refund within policy" and "never refund before escalating" Newer models follow the letter, so results get worse
Old configuration budget_tokens on Opus 5 400 error

Instructions that get over-followed cost money. Contradictions, scratchpads, and removed settings cost accuracy. When migrating from Opus 4.8 to Opus 5.5, /claude-api prompt-audit cut cost by a further 9% and raised accuracy by about 2 points.

Exam trap

When output is inconsistent, "add CRITICAL/ALWAYS and require verifying twice" is a distractor. The correct fix is to supply the missing information and remove contradictions. Constrain only what needs to be consistent, such as format and scope. Don't lock down legitimate variation such as phrasing.

(Sources: Anthropic Academy tutorial: Write a prompt your app can ship; Anthropic Academy: Building with the Claude API — Being clear and direct, Being specific, Structure with XML tags; Claude Blog: Reducing cost and improving performance with Claude Platform)

Prompting technique selection

Technique Use when Cost, traps
Clear zero-shot Default, try first Cheapest
Few-shot Corner cases (e.g., sarcasm), complex formats, tone of voice Adds tokens to every request. Wrap examples in <sample_input>/<ideal_output>, explain why the example is ideal, take examples from the highest-scoring outputs in evals
Native thinking (adaptive + effort) Math, multi-step logic, debugging, regulatory analysis, trade-off comparisons Costs tokens and latency. Skip it for classification, extraction, boilerplate
Prompted reasoning (scratchpad) Older models without native thinking On current models, conflicts with native thinking
Structured output Output feeds into code output_config.format, strict: true on tools. Prefill is removed from the 4.6 models onward

A few more rules:

  • Run evals without thinking first. Enable it only when the prompt is already optimized and accuracy still falls short.
  • Opus 5.5 cannot disable thinking: {type: "disabled"} and budget_tokens both return 400. To reduce it, use effort low.
  • Forced tool_choice (any, tool) returns 400 on Fable 5.1, Opus 5.5, and Sonnet 5.5. Use auto with strict: true instead, or structured outputs.
  • Asking for short answers also saves money: a one-line version uses 39% fewer output tokens and is 13% cheaper, while a memo version costs 2.8 times as much.
client.messages.create(
    model="claude-opus-5-5", max_tokens=64000,
    thinking={"type": "adaptive", "display": "summarized"},
    output_config={"effort": "low",
                   "format": {"type": "json_schema", "schema": SCHEMA}},
    messages=msgs,
)

Exam tip

  • Corner cases, complex formats → few-shot.
  • Multi-step reasoning → native thinking or higher effort, not an added scratchpad.
  • JSON parse errors → structured outputs.
  • Verbosity → ask for brevity or lower effort.

(Sources: Anthropic Academy: Building with the Claude API — Structured data, Providing examples, Extended thinking; Anthropic Academy: Claude Platform 101 — What is thinking?; Anthropic Skills: claude-api)

Context composition and token economics

Context consists of the system prompt, the history, tool definitions and results, files, Skills, and thinking blocks. Every agent turn resends the entire conversation. A 40-turn task sends the first turn 40 times, so cost grows roughly with the square of the number of turns. Without caching, measured cost was 3.3× (Opus 5.5) to 7.3× (a triage agent) higher.

Model Input 5m write 1h write Cache read Output
Claude Opus 5.5 $4 $5 $8 $0.20 $20
Claude Sonnet 5.5 $2 $2.50 $4 $0.10 $10
Claude Haiku 5.5 (≤100K) $0.10 $0.125 $0.20 $0.01 $0.50
Claude Haiku 5.5 (>100K) $0.50 $0.625 $1 $0.05 $2.50

Key point

Multipliers relative to the input price: 5m write 1.25×, 1h write 2×, read 0.1× by default. Opus 5.5 and Sonnet 5.5 read at 0.05×; Fable 5.x at 0.025×. For Haiku 5.5, cached tokens still count toward prompt length for the 100K threshold.

Stable 50,000-token prefix, 1,000 calls within the TTL, Claude Opus 5.5:
No cache:    1,000 × 50,000 × $4/MTok                                    = $200
With cache:  50,000 × $5/MTok + 999 × 50,000 × $0.20/MTok ≈ $0.25 + $9.99 ≈ $10.24
Lever Figures in the sources
Tool search, defer_loading All 502 tools loaded: cost rises from $0.55 to $1.02; with tool search it stays around $0.56
Data files via code execution ~91K-token CSV pasted into the prompt: 7/25 correct, $5.01. Through the Files API and code execution: 25/25, $0.40
Programmatic tool calling 24% fewer input tokens
Batch API 50% cheaper, results within at most 24 hours

Reading usage: input_tokens counts only the tokens after the last breakpoint. Total input equals cache_creation_input_tokens + cache_read_input_tokens + input_tokens. Real-world agent loops read a median of 84% of their input from cache. Below about 80%, look for whatever is breaking the cache.

Exam trap

A small input_tokens does not mean the prompt is small. Pasting a whole large data file into the prompt is both more expensive and less accurate than letting Claude read it through code execution.

(Sources: Claude Docs: Prompt caching; Claude Docs: Optimizing for cost and intelligence; Anthropic Academy: Claude Platform 101 — Context management)

Cache breakpoints and reusable packaging

Rules

  • Prefix order is tools → system → messages, matched byte-exact.
  • At most 4 breakpoints. Each breakpoint looks back at most 20 blocks.
  • The cache is written only at breakpoints. Place the breakpoint on the last block that is identical across requests, not on a block that contains a timestamp.
  • Minimum cacheable length: 512 tokens for current 5.x models, 1,024 for Sonnet 5 and Opus 4.8, 4,096 for Haiku 4.5. Below the minimum there is no error; both cache fields are simply 0.
  • A cache entry becomes usable only after the first response starts, so wait for the first request before fanning out.
  • Automatic caching (top-level cache_control) takes one of the 4 slots. Legacy Bedrock integrations return 400 with this approach.
  • Cache hits do not count against rate limits.
Change Cache invalidated
Tool definitions Everything
System prompt; toggling web search or citations; speed System and messages
tool_choice, images, top-level thinking/effort parameters Messages
Output format (structured outputs) That conversation's cache

TTL

The default is 5 minutes, refreshed at no cost on each use, measured from when the request starts. The 1-hour TTL costs 2× to write.

  • Choose 1 hour when about 1 in 20 turns arrives after a 5–60 minute pause (break-even is about 1 in 30).
  • Choose 5 minutes when turns are seconds apart, or when pauses usually exceed 1 hour.
  • An alternative is a max_tokens: 0 request every 4 minutes. This is rejected when the request uses thinking.type: "enabled", structured outputs, or forced tool choice; in that case, buy the 1-hour TTL.

Lessons from Claude Code

  • Layout: static system prompt and tools → CLAUDE.md → session context → messages.
  • Mid-session updates are sent as messages (<system-reminder>). Editing the system prompt costs 25–50 times more than sending the same content as a system message mid-conversation.
  • Don't add or remove tools mid-session. Plan Mode is implemented as a tool; rarely used tools are sent as defer_loading: true stubs.
  • Don't switch models mid-session, because the cache is tied to each model. To use a different model, hand off through a subagent.
  • Compaction uses cache-safe forking: keep the system prompt, tools, and history unchanged and only append the summarization prompt.

Modular and Skill packaging

Skills load through progressive disclosure: only the metadata sits in context up front, while SKILL.md and bundled files load when needed, so the prefix stays small and stable. Packaging shared processes as Skills or as fixed prompt modules placed before the dynamic content lets many flows share one prefix. Sharing scope: the cache is isolated per workspace (Claude API, Claude Platform on AWS, Foundry) or per organization (Bedrock, Google-managed).

system=[{"type": "text", "text": POLICY_AND_SKILL_INDEX},
        {"type": "text", "text": TENANT_GUIDE, "cache_control": {"type": "ephemeral"}}]
messages=[..., {"role": "user", "content": f"{question}\n\nQueue position: {pos}"}]

Scenario example

A support agent puts a "queue position: N" line at the start of the system prompt, which drives cache reads to nearly 0%. In Anthropic's testing, a 25-token status line like this made every request rewrite the entire conversation to the cache. Moving it to the end of the latest user turn, after the last breakpoint, restores cache reads.

Key point

A broken cache raises no error; it just silently drives up cost. Monitor cache hit rate the way you monitor uptime. On the Claude API, cache diagnostics show where the prefix diverges.

(Sources: Claude Docs: Prompt caching; Claude Blog: Lessons from building Claude Code: Prompt caching is everything)

Reasoning effort and context lifecycle

Effort

The levels low, medium, high, xhigh, and max are set in output_config. The default is high on most models and medium on Opus 5.5 and Haiku 5.5. Sweep 2–3 levels on real traffic, with a separate session for each level.

Opus 5.5, SWE-bench Pro Solved Cost/task
low 87.4% $0.11
medium (default) 92.8% $0.21
high 95.3% $0.29
xhigh 96.7% $0.74
low, rerunning failed tasks at high ~97% ~$0.17

Rerunning failed tasks requires a checkable failure signal (tests, a verifier) and makes the failed tasks take longer.

  • With effort too high, the model overthinks. With effort too low, the model stops before it has enough evidence.
  • Set max_tokens to 64,000 for agentic work and treat stop_reason: "max_tokens" as a failure.

Context lifecycle

Strategy Mechanism Notes
Just-in-time Load only what is needed right now; tools pull in the rest A design pattern, not a parameter
Context editing Clears old tool results Beta. Each clearing costs a cache write, so clear in a few large batches. Short sessions: cost up 73%
Compaction (server-side) Summarizes older turns when a threshold is exceeded Beta, compact_20260112; default threshold 150,000; saves 32% on long sessions
Memory tool memory_20250818; Claude reads/writes a memory directory that you store Knowledge that persists across sessions
Pruning in code Replaces long tool results with short excerpts Saves 39% but do not use it on Fable 5.x, Opus 5.5, Sonnet 5.5, Haiku 5.5

On models with preserved thinking, editing old tool results invalidates the thinking blocks that follow and can cause a 400 error during prefix validation. Use compaction instead.

For Haiku 5.5, set the compaction threshold below 100,000. In testing, a 90,000 threshold was 70% cheaper per request than the default. For tasks spanning many context windows, compaction is not enough: you also need a progress file, a feature list, and git. Managed Agents enables caching and compaction by default.

Exam trap

"Trim old tool results to save tokens" on Opus 5.5 breaks preserved thinking. The correct answer is server-side compaction. "Enable context editing for every session" is also wrong, because short sessions can become more expensive.

Key point

Optimization order according to the sources:

  1. Caching and trimming unnecessary tokens.
  2. Lower effort.
  3. Change tier.
  4. Multimodel.

Change the model or effort on the first request after compaction, because the cache is already broken at that point.

(Sources: Claude Docs: Optimizing for cost and intelligence; Anthropic Academy: Claude Platform 101 — What is thinking?, Context management; Anthropic Engineering: Effective harnesses for long-running agents)

Quick summary

  • Choose a tier with an eval of 20–30 real examples: the cheapest tier whose output you would ship, compared by cost per completed task.
  • If cost is high but quality is fine, lower effort first, then change tier.
  • Opus 5.5: $4/$20, default effort medium, thinking cannot be disabled. Haiku 5.5: $0.10/$0.50, 5× the price when the prompt exceeds 100K.
  • An underspecified prompt needs context (facts), format, and constraints (with reasons). An over-constrained prompt needs its rituals, emphasis, scratchpads, outdated examples, and conflicting rules removed.
  • Few-shot for corner cases. Native thinking for multi-step reasoning. Structured outputs instead of prefill.
  • Prefix: tools → system → messages, byte-exact. At most 4 breakpoints, 20-block lookback, breakpoint on the last stable block.
  • 5m write = 1.25×, 1h = 2×, read = 0.1× (0.05× for Opus 5.5 and Sonnet 5.5). Below the minimum length, nothing is cached and no error is raised.
  • Changing tools breaks the entire cache; changing thinking/effort breaks the messages cache. Send mid-session updates as messages.
  • Don't switch models or add/remove tools mid-session; use subagents and defer_loading.
  • 1-hour TTL when about 1 in 20 turns arrives after a 5–60 minute pause.
  • Compaction for long sessions, the memory tool for knowledge across sessions. Don't prune on models with preserved thinking.