Skip to content
CCAR-F Prep

Task Statement 3.5·Domain 3 — 20% of exam

Iterative Refinement Techniques

Apply iterative refinement techniques for progressive improvement

Jump to practice →

Official Exam Guide Objectives

The objectives below are quoted from Anthropic's Claude Certified Architect – Foundations exam guide, v1.1. Read the exam guide summary for the full blueprint.

Knowledge of

  • Concrete input/output examples as the most effective way to communicate expected transformations when prose descriptions are interpreted inconsistently
  • Test-driven iteration: writing test suites first, then iterating by sharing test failures to guide progressive improvement
  • The interview pattern: having Claude ask questions to surface considerations the developer may not have anticipated before implementing
  • When to provide all issues in a single message (interacting problems) versus fixing them sequentially (independent problems)

Skills in

  • Providing 2-3 concrete input/output examples to clarify transformation requirements when natural language descriptions produce inconsistent results
  • Writing test suites covering expected behavior, edge cases, and performance requirements before implementation, then iterating by sharing test failures
  • Using the interview pattern to surface design considerations (e.g., cache invalidation strategies, failure modes) before implementing solutions in unfamiliar domains
  • Providing specific test cases with example input and expected output to fix edge case handling (e.g., null values in migration scripts)
  • Addressing multiple interacting issues in a single detailed message when fixes interact, versus sequential iteration for independent issues

What You Need to Know

Nobody gets the output they wanted on the first attempt, and the exam is less interested in that fact than in what you do next. There are named techniques for steering Claude Code, they suit different failure modes, and the testable skill is picking the right one rather than trying all of them.

The Technique Hierarchy

They are not interchangeable. Each answers a different symptom, and an exam item gives you the symptom and asks for the technique, so learn them by symptom rather than by name:

1. Concrete input/output examples (most effective for inconsistent interpretation)

Where a transformation described in prose comes back done differently each time, the instinct is to describe it more carefully. That does not work, because the problem is not that the description was unclear — it is that any description leaves room to interpret.

Show two or three transformations instead, input beside output:

Input:
  getUserData(userId: string): Promise<UserData>

Expected output:
  getUserData(userId: string): Promise<Result<UserData, ApiError>>
Input:
  fetchOrders(customerId: string): Promise<Order[]>

Expected output:
  fetchOrders(customerId: string): Promise<Result<Order[], ApiError>>

A pattern demonstrated twice generalises more reliably than a pattern described at any length, because there is nothing left to infer about intent. Two or three cases are enough to establish it. This is where to start whenever the complaint is inconsistency.

Same prompt, three shapes — examples make it one A prose instruction to wrap a function's return type in a Result type is run three times and comes back three different shapes: Result of T and Error, Result of T and string, and a plain object with ok, data and error fields — the description left room to interpret. Two concrete input/output examples are shown instead: getUserData returning Promise of UserData becomes Promise of Result of UserData and ApiError, and fetchOrders returning Promise of Order array becomes Promise of Result of Order array and ApiError. Applied to a new case, deleteAccount, the same Result of T and ApiError shape comes back on every run. A pattern demonstrated twice generalises more reliably than a pattern described at any length, because there is nothing left to infer about intent. Prose, run three times wrap the return type in a Result type same prompt — three different shapes Result<T, Error> Result<T, string> {ok, data, error} ✕ inconsistent — something left to interpret Examples, run three times Input: getUserData(userId: string): Promise<UserData> → Promise<Result<UserData, ApiError>> Input: fetchOrders(customerId: string): Promise<Order[]> → Promise<Result<Order[], ApiError>> Now: deleteAccount(accountId: string): Promise<void> same pattern, new case Result<T, ApiError> Result<T, ApiError> Result<T, ApiError> ✓ demonstrated twice beats any amount of prose
1 / 6Swipe diagram ↔

Same prompt, three shapes — examples make it one, step 1: A prose instruction is run three times

Choosing which examples to show

The two or three pairs should not be variations of one case. Each should carry a different decision, and the useful rule for picking them is: show the cases where a reasonable implementer would guess wrong. A single pair gives the model an instance to copy, not a rule to infer; pairs of identical shape leave it unclear which features matter.

Take the instruction "normalise the customer records: clean up the names and standardise the phone numbers". Three pairs settle what that sentence never raised:

in : {"name": "  john  SMITH ",      "phone": "(415) 555-0134"}
out: {"name": "John Smith",          "phone": "+14155550134"}

in : {"name": "o'brien, MARY-JANE",  "phone": "415.555.0199 x22"}
out: {"name": "Mary-Jane O'Brien",   "phone": "+14155550199;ext=22"}

in : {"name": "ACME LOGISTICS LTD",  "phone": "+44 20 7946 0958"}
out: {"name": "ACME Logistics Ltd",  "phone": "+442079460958"}
Question the prose left openPair that answers it
Stray whitespace, mixed case, national number formatFirst
Comma-inverted names, hyphens and apostrophes, phone extensionsSecond
International numbers; company names are not title-cased like personal namesThird

This is the same mechanism as few-shot prompting (Task Statement 4.2), applied in a Claude Code conversation rather than in an API prompt.

2. Test-driven iteration (most effective for complex transformations)

Write the tests before the change and let them state the requirement:

  • The ordinary case, transformed the way you actually want it
  • The awkward ones — nulls, empty collections, values sitting exactly on a boundary
  • The error cases — invalid input or missing data, and what should happen instead (a specific error, a default value)
  • Anything with a timing or throughput requirement attached

Then hand over the failures. A failing assertion is feedback with no interpretive surface at all — it names what was expected and what arrived, and nothing about that can be read two ways.

FAIL: preservesNullsThroughMigration
  Expected: {"middleName": null}
  Actual:   {"middleName": ""}

Nothing needs adding to that. The gap is stated in the output.

A failing test leaves nothing to interpret Prose feedback such as "that doesn't look right, can you fix the null handling?" can be read several ways — add a null check, change the type, trim empty strings — and still leaves something to interpret. A failing assertion carries no such ambiguity: FAIL preservesNullsThroughMigration, Expected middleName null, Actual middleName an empty string. Nothing needs adding to that — the gap between what was expected and what arrived is stated directly in the output, with exactly one path to the fix. Prose feedback "that doesn't look right — can you fix the null handling?" ? add a null check? change the type? trim empty strings? still something to interpret Test failure FAIL: preservesNullsThroughMigration Expected: {"middleName": null} Actual: {"middleName": ""} ✓ one path — no interpretation expected X, got Y — nothing about that can be read two ways
1 / 6Swipe diagram ↔

A failing test leaves nothing to interpret, step 1: Prose feedback — can you fix the null handling

The loop is: write the suite first, have Claude implement against it, run it, paste the failures back, and repeat until everything passes. Set against a requirement written in prose, the suite wins on every count:

Prose requirementTest suite
AmbiguityHighNone: a test passes or it does not
Who judges the outputYou, by reading itThe suite
Protection against regressionsNoneBuilt in: a fix that breaks an earlier case fails visibly
Edge casesEasily forgottenListed before any code exists

Paste the failure, do not describe it

"The null handling still isn't right" gives Claude nothing new, so the next attempt is a guess. The raw output does the work:

FAILED tests/test_migrate.py::test_null_middle_name
  assert result["full_name"] == "Ada Lovelace"
  AssertionError: assert 'Ada None Lovelace' == 'Ada Lovelace'
FAILED tests/test_migrate.py::test_missing_phone
  KeyError: 'phone'  at migrate.py:64

Failure text carries four facts: the exact input, the expected value, the actual value and the location. A summary in your own words loses all four. (Structured tool errors in Task Statement 2.2 rest on the same principle.) Paste the failures only; handing back the whole test file each round adds bulk without adding signal, because the passing tests say nothing about the gap.

One failing case for one mishandled edge case

The exam guide names a narrower use of the same idea: "specific test cases with example input and expected output to fix edge case handling (e.g., null values in migration scripts)". When a stem says the script mishandles nulls, the answer is a concrete case showing the null input and the output you expect, not an instruction to "handle nulls carefully". Tests written after the implementation are weaker for the same reason they are easier: the code already written frames what gets tested, so the edge cases it never considered stay unexplored.

3. Interview pattern (most effective for unfamiliar domains)

When the domain is unfamiliar, the risk is not that Claude will misunderstand you — it is that you will forget to ask for something you did not know mattered. Inverting who asks the questions surfaces it.

Instead of prescribing a solution:

"Add a caching layer in front of the orders API"

Use the interview pattern:

"I want to put a caching layer in front of the orders API. Before you write anything, ask me what you need to know — requirements, edge cases, constraints I may not have thought about."

What comes back tends to be the things experience would have prompted: how invalidation works (TTL, write-through or event-driven), what TTL suits the data, how much staleness is tolerable per endpoint, whether the cache is shared or per user (and whether tenants must be kept apart), what consistency readers need, whether cached values are personalised and could be served to the wrong person, whether a cold key needs protection against a stampede of simultaneous requests, and whether an unavailable cache should fail open (serve from the origin) or fail closed. You had thought about "add a cache"; half of those answers change the design.

Two additions make the prompt sharper: ask Claude to concentrate on decisions that would be expensive to change later, and tell it not to propose an implementation until you have answered.

When to interview, and when not to

Use it when the domain is unfamiliar, when an early wrong decision would be costly, or when you cannot state the requirement precisely. Do not use it when the requirement is already clear: the questions then only add delay, and you end up answering "whatever you think" to things that do not matter.

Interview pattern or plan mode?

Both come before implementation, and they point in different directions. Plan mode (Task Statement 3.4) has Claude read the codebase and propose an approach. The interview draws requirements out of the developer.

What is unknownReach for
The codePlan mode
The requirementsInterview pattern
BothInterview first, then plan
Two different gaps, two different fixes Examples repair a transmission gap: you know exactly what you want, but prose keeps arriving as something slightly different each time. The interview pattern repairs a knowledge gap: Claude asks questions before implementing, surfacing considerations such as invalidation strategy, TTL, and behaviour on failure that you did not know to specify. These are easy to swap by mistake — the interview pattern covers what you did not know to ask for, while examples cover a specification you hold precisely but cannot transmit in prose. Running the interview pattern on a transformation you can already state exactly wastes the round, because there is nothing to discover. Examples transmission gap You Claude you know exactly what you want ✕ prose lands differently each time Interview pattern knowledge gap You Claude invalidation? TTL? on failure? questions first ✓ ✓ ✓ two different gaps — swapping them wastes the round interview pattern on a known transformation ✕ wasted — nothing to discover here
1 / 6Swipe diagram ↔

Two different gaps, two different fixes, step 1: Examples — a transmission gap

Batch vs Sequential Feedback

Delivery matters as much as content, and the deciding question is whether the fixes touch each other. The working test: does fixing A change what the right fix for B is? If yes, they interact. For independent issues the mirror test is whether they could ship in separate pull requests.

Single message (batch) when fixes interact with each other:

Where changing the error handling also changes the logging format and the response shape, all three belong in one message. Sent separately, each fix is made without sight of the others, so the second contradicts the first and the third has to undo both.

Three changes needed (they interact with each other):
1. Error responses must include an error code field
2. Logging must include the error code in structured format
3. The client SDK type definitions must reflect the new error code field

Sequential iteration when issues are independent:

Where the naming convention and the indentation have nothing to do with each other, send them one at a time. Bundled, they compete for attention and it becomes ambiguous which instruction governs which part of the file.

First message:  "Rename the exported functions to camelCase"
[let it finish]
Second message: "Now switch indentation to two spaces"
Batch what interacts, sequence what doesn't Three interacting fixes — an error code field, a logging format, and client SDK types — sent one message at a time each land blind to the others and contradict the fix before it. Sent together in a single message, all three agree on the same error-code shape. Two independent issues — a camelCase rename and a two-space indent change — behave the opposite way: batched into one message they compete for attention and it becomes ambiguous which instruction governs which part of the file, while sent sequentially, one at a time, each applies cleanly. The test is whether the fixes touch each other, not how many there are. Interacting issues sequential — one at a time error code field ✕ logging format ✕ client SDK types ✕ each fix made blind to the others batched — one message error code field + logging format + client SDK types ✓ all three agree on the same error-code shape Independent issues batched — one message rename to camelCase + switch to 2-space indent ✕ ambiguous which instruction governs which part sequential — one at a time rename to camelCase then → switch to 2-space indent ✓ applied cleanly, one at a time the test is whether the fixes touch each other — not how many there are
1 / 6Swipe diagram ↔

Batch what interacts, sequence what doesn't, step 1: Interacting issues, sent one at a time

Two further examples of the split. "The pagination is off by one, the sort order flips on the second page, and the total count excludes filtered rows" is three symptoms of one piece of query-building logic: reported one at a time you get three patches that fight each other, where the fix for the second undoes the first and the fix for the third brings the first bug back. "The README has a broken link, the retry backoff should be exponential, and the log timestamps are local instead of UTC" is three unrelated areas: taken one at a time, each change stays small enough to review and can be reverted on its own.

Interacting: one messageIndependent: sequential
Size of the changeLarger, but coherentSmall each time
What goes wrong if you choose the other waySplit up, the fixes thrash and reintroduce each other's bugsBundled, the diff is hard to review and a regression cannot be pinned on one change
How to verifyTest the combined behaviourVerify each before raising the next

Coupling is the only criterion. How long each fix takes, how severe it is and which file it lives in do not decide the grouping: interaction follows the shared data structure, not the file boundary, so an error shape and the client types that mirror it sit in different files and still belong in one message.

Example-Based Communication in Practice

Moving from prose to examples follows a repeatable sequence:

  1. Observe inconsistency: the same instruction produces a different result on each run.
  2. Switch to examples: supply two or three before/after pairs that pin the transformation exactly.
  3. Verify generalisation: try a case the examples did not cover, to confirm the pattern transferred rather than the instances being copied. With the two Result pairs above, deleteAccount(accountId: string): Promise<void> is a good hold-out: it should come back as Promise<Result<void, ApiError>> on every run.
  4. Add edge case examples if needed: where the ordinary case is right and an unusual one is not, demonstrate the unusual one specifically.

Volume adds nothing here. A pair covering the normal case plus one that pins down a genuinely awkward variant is sufficient; beyond that you are mostly re-demonstrating a pattern already established, at the cost of the context it occupies.

When Each Technique Applies

SituationTechnique
Prose description interpreted differently each timeConcrete input/output examples
Complex transformation with many edge cases, or behaviour that must be verifiably correctTest-driven iteration
One edge case mishandled (nulls, empty values, unusual characters such as non-ASCII text)A specific failing case with its expected output
Working in an unfamiliar domain; you do not know what to specifyInterview pattern
The code is unfamiliar, not the requirementPlan mode (Task Statement 3.4)
Multiple issues that affect each otherBatch feedback (one message)
Multiple independent issuesSequential feedback
The behaviour must happen every time, without exceptionA hook, not more iteration

The last row marks the limit of this whole task statement. Refinement improves what Claude produces; it cannot guarantee it. The exam guide separates "hooks for deterministic guarantees" from "prompt instructions for probabilistic compliance" (Task Statement 1.5), and another round of feedback is still a prompt.

Deep Dive

The technique hierarchy above is about what to say when refining Claude Code's output. Claude Code also has session-level mechanics that support the same iterative loop — focusing context, branching to compare approaches, and undoing an iteration that went the wrong way.

/compact with custom instructions to focus an iteration session

/compact [instructions] replaces conversation history with a summary, optionally focused on what you specify. For more control during a long refinement session, run /compact <instructions> — for example, /compact Focus on the API changes — so the summary that survives compaction is the part still relevant to the current iteration, not a generic recap.

Sourcescode.claude.com › sessionscode.claude.com › best-practicesfetched 2026-07-30

Session forking to compare divergent fixes

Branching creates a copy of the conversation so far and switches you into it, leaving the original intact. From the CLI, combine --continue or --resume with --fork-session to create a new session ID rather than reusing the original — useful when you want to try two different fixes for the same interacting-issues batch without losing the baseline conversation.

Sourcecode.claude.com › sessionsfetched 2026-07-30

Checkpoints and /rewind for reverting a bad iteration

Every user prompt creates a new checkpoint automatically. Run /rewind, or press Esc twice on an empty prompt, to open the rewind menu, which offers restoring code and conversation together, conversation only, or code only. This is "local undo" that complements — but doesn't replace — git. Tracking is per file and starts with Claude's own file-editing tools: "Once Claude has edited a file with its file editing tools in your conversation, /rewind undoes changes that Bash commands make to that file afterward. A file that only Bash commands changed isn't tracked and stays as it is." A file created or deleted only by a shell command therefore has to be recovered with git. Snapshots are kept for the 100 most recent checkpoints in a session.

Sourcecode.claude.com › checkpointingfetched 2026-11-19

Writer/Reviewer pattern as a check on self-correction

A fresh context improves code review because Claude won't be biased toward code it just wrote. The documented Writer/Reviewer pattern has one session implement while a second, independent session reviews the implementation and the first session then addresses that feedback — the same split works for tests, with one Claude writing tests and another writing code to pass them. This is a useful cross-check after several rounds of self-driven iteration, when you want an opinion untainted by the reasoning that produced the current draft.

Sourcecode.claude.com › best-practicesfetched 2026-07-30

The Explore-Plan-Implement-Commit workflow as the iteration scaffold

The recommended four-phase workflow — Explore, Plan, Implement, Commit — gives iterative refinement a shape: explore and plan happen before the first draft, so the early rounds of refinement (examples, tests, the interview pattern) apply during Implement, against a plan that already accounted for edge cases and constraints.

Sourcecode.claude.com › best-practicesfetched 2026-07-30

Quick Reference

SituationTechnique
Prose interpreted differently each runConcrete input/output examples (2-3 pairs)
Complex transformation, many edge casesTest-driven iteration — share test failures
One edge case mishandled (e.g. nulls in a migration)One specific test case: the null input and its expected output
Unfamiliar domain, might miss considerationsInterview pattern — let Claude ask questions first
Unknown code vs unknown requirementsPlan mode vs interview; both unknown → interview, then plan
Fixes interact with each otherBatch feedback in a single message
Fixes are independentSequential feedback, one at a time
Interacting or independent?Does fixing A change the right fix for B? Could they ship in separate PRs?
Behaviour must hold every timeA hook — iteration is still a prompt
A rewind leaves a Bash-only change in placeExpected: such files are not tracked; recover with git
Long session losing focus/compact <instructions> — targeted summary
Comparing two divergent fixes--fork-session (with --continue/--resume) or /branch
An iteration went the wrong way/rewind or Esc-Esc — restore code, conversation, or both
Want an unbiased second opinionWriter/Reviewer pattern — fresh session reviews, no shared reasoning context
Scaffold for the whole cycleExplore → Plan → Implement → Commit

Exam Traps

The remaining wrong answers this task statement dangles are each taken apart where the technique is taught above: describing a failure instead of pasting it, interviewing when the requirement is already clear, writing the tests after the implementation, splitting by file or severity instead of by coupling, and using another round of feedback to enforce a guarantee.

How This Is Tested

Batch versus sequential is the sharpest distinction in this task statement and tends to get an item of its own. The other stems give a symptom and ask for the technique.

Stem signalAnswerWrong-answer pattern beside it
Three attempts at a data-cleaning transformation, three interpretationsTwo or three concrete input/output pairs, each chosen where a reasonable implementer would guess wrongRewrite the prose longer or more emphatically; start an interview
A migration script mishandles nullsOne specific test case with the null input and its expected output"Tell it to handle nulls carefully"; a prose list of every edge case
Fixes keep regressing earlier cases, or the result must be verifiably correctWrite the suite first (behaviour, edge cases, performance), then paste the failuresSummarise the failures; add more prose; write the tests after the code
Adding caching to a system in a domain the developer does not knowInterview pattern firstExamples or a test suite, which need a requirement the developer cannot yet state
The developer knows the requirement but not the codebasePlan mode (Task Statement 3.4)Interview pattern
Four bugs in the same pagination logicOne detailed message with all of themOne message per bug
A documentation typo, a backoff bug and a timezone bugSequentially, verifying eachOne combined message "to save rounds"
A rule must hold on every run, without exceptionA hook (Task Statement 1.5)Another, firmer round of feedback

Practice Scenario

Your migration script's ordinary rows transform correctly now that two before-and-after pairs are in the prompt, but each round of feedback fixes one awkward case and regresses another — nulls, empty collections, rows sitting exactly on the cutoff date. The script also has to finish inside a twenty-minute window. What's the most effective next step?

Practice Questions

Exam simulator

Question 1 of 13

Scenario · Developer Productivity with Claude

You asked Claude, in two paragraphs of prose, to convert print-style log calls to structured logging. Across three runs the field names drift (userId, user_id, uid), and error objects are sometimes stringified and sometimes nested. Your written description has not changed between runs. What change would most effectively make the output consistent?

Sources