Claude Certified Architect – Foundations Practice Question 45: Clear Versus Compact

Claude Certified Architect, Foundations · Test 5 · question 5 of 10

Claude Code Configuration & Workflowsmedium

A developer has used one Claude Code session all day. The morning's work, fixing a CSS bug, is finished. They now start a database migration, a task that is unrelated to the CSS bug, and expect it to need many more turns. Later, partway through the migration, Claude Code warns that the context is getting full, but the migration's current schema decisions and failing test output must be kept. Which approach handles both situations best?

Select one answer
Show answer and explanation

Answer:

  • B. Use /clear when switching to the unrelated migration, and /compact with focus instructions (for example, schema decisions and test output) when the warning appears.

Anthropic's cost guidance recommends /clear to start fresh when switching to unrelated work, since stale context wastes tokens on every later message. Mid-task, when you need continuity, /compact summarizes the conversation, and you can pass instructions such as /compact Focus on code samples and API usage to tell Claude what to preserve. CLAUDE.md can also hold standing "compact instructions".

A is wrong because it is backwards: compacting when switching tasks carries a summary of irrelevant CSS work into the new task, while clearing mid-migration throws away the decisions you need. C is wrong because clearing mid-task forces you to reconstruct state by hand and risks losing detail; compaction with focus instructions exists for this case. D is wrong because carrying the CSS context forward wastes tokens, and compaction is not something to switch off; without it the session would eventually hit the context limit.

Reference: Manage costs effectively (Manage context proactively)

Practice Test 5 ›

Study guides for Claude Certified Architect, Foundations