CCAR-F Study Guide

Domain 5 — Context Management & Reliability (15%)

Smallest domain by weight, but its concepts appear inside questions from every other domain. Reliability is what separates a demo from a production system, and this exam is about production systems.

5.1 What fills a context window

In Claude Code, a great deal loads before you type: system prompt, auto memory index, environment info, MCP tool listings, CLAUDE.md files and unconditional rules, the skill index. Then your prompt, then every file read, every tool result, every hook's additional context.

The right response to context pressure is not a bigger window. Attention dilutes across long contexts; adding room lets the problem grow. The architectural moves are:

  • Delegate to subagents so voluminous intermediate work happens in a separate window and only the conclusion returns.
  • Clear stale tool results that no longer inform anything.
  • Offload to storage — files, a memory tool — and read back on demand.
  • Trim what loads at startup: keep CLAUDE.md under 200 lines, move situational instructions into path-scoped rules or skills that load only when needed.

5.2 Context editing (API side)

context_management={
  "edits": [{
    "type": "clear_tool_uses_20250919",
    "trigger":        {"type": "input_tokens", "value": 30000},
    "keep":           {"type": "tool_uses",    "value": 3},
    "clear_at_least": {"type": "input_tokens", "value": 5000},
    "exclude_tools":  ["web_search"],
  }]
}
ParameterDefaultMeaning
trigger100,000 input tokensWhen clearing activates
keep3 tool usesMost recent tool use/result pairs preserved
clear_at_leastnoneMinimum cleared per activation — makes the cache invalidation worth paying for
exclude_toolsnoneTools whose results are never cleared
clear_tool_inputsfalseAlso clear the tool's arguments, not just its result

Clearing is applied server-side; your client keeps the full history locally. It invalidates cached prefixes at the point of the edit, which is exactly why clear_at_least exists. Pair it with a memory tool so anything important is written down before it is cleared. clear_thinking_20251015 does the same for thinking blocks and must be listed first when combined.

5.3 Compaction in Claude Code

/compact replaces the conversation with a structured summary. What survives is specific, and the exam has asked about it:

Survives / reloads — System prompt, project CLAUDE.md (re-read from disk), auto memory, MCP tools, up to five most recently modified files re-read with their matching rules, and the body of each skill you invoked (capped ~5,000 tokens each).

Practical consequence: if a constraint matters across a long session, it belongs in CLAUDE.md, not in a message you typed an hour ago. Use /clear when starting genuinely new work — it is cheaper and cleaner than compacting a conversation you no longer need.

5.4 Prompt caching

BreakpointsMax 4, marked with cache_control
Ordertools → system → messages
TTL5 min default; 1 h at 2× write cost
Write cost1.25× base (5 min), 2× base (1 h)
Read cost0.1× base
MinimumModel-dependent (512–4,096 tokens); shorter prefixes are not cached

Put static content first and mark the last block that stays identical across requests. Changing tool definitions invalidates tools, system and messages; changing tool_choice or adding an image invalidates messages only. Verify with cache_read_input_tokens and cache_creation_input_tokens in the response — and remember that input_tokens counts only what follows your last breakpoint.

5.5 Choosing the right API surface

NeedUseWhy
Interactive, user is waitingStandard Messages API, streamingLatency is the constraint
Long single request (>10 min)Streaming, or BatchesAvoids connection timeouts (504)
Bulk, tolerant of delayMessage Batches API50% discount; up to 100,000 requests or 256 MB; most finish within 1 h, hard limit 24 h

Batch statuses are in_progress → canceling → ended; per-request results are succeeded, errored, canceled, or expired (the last three are not billed). Results can return in any order — match on custom_id. Streaming is not supported inside a batch.

The cost trap — "Route all workloads through the Batches API to cut costs 50%" is a canonical wrong answer. Batch processing is asynchronous; applying it to a latency-sensitive path trades a working product for a discount.

5.6 Errors and retry policy

CodeTypeRetry?
400invalid_request_errorNo — fix the request
401 / 403authentication_error / permission_errorNo
404not_found_errorNo
413request_too_largeNo — split the payload (32 MB Messages, 256 MB Batch, 500 MB Files)
429rate_limit_errorYes — honour retry-after
500api_errorYes — exponential backoff
504timeout_errorYes, but prefer streaming or Batches
529overloaded_errorYes — backoff

Every response carries a request_id; log it. SDKs retry transient failures twice by default with exponential backoff. Catch typed exceptions rather than string-matching error messages — a habit the exam rewards in its own way, since the deterministic-signal principle applies here too.

5.7 Session continuity

For multi-day work, sessions are resumed by ID (--resume <session-id>, or resume: in the SDK), and subagents can be resumed by agentId within a resumed session. The durable record of decisions, though, is CLAUDE.md and committed artefacts — a plan file, an issue, a design doc. Relying on a conversation transcript as the system of record is fragile; compaction and session boundaries will eventually eat it.

← Previous: Domain 4 — Prompt Engineering & Structured Output  |  Next: The 14 anti-patterns →

Architect CCAR-F Real Exam Questions

Ready to Pass Your CCAR-F Certification?

Practice with authentic exam questions, verified explanations, and timed test simulation to guarantee your success.

Starting from $49.00
Take Practice Exam →