Task Statement 3.5·Domain 3 — 20% of exam
Iterative Refinement Techniques
Apply iterative refinement techniques for progressive improvement
Official Exam Guide Objectives
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 three.
The Technique Hierarchy
They are not equivalent, and there is an order to reach for them in:
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.
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
- 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.
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, what TTL suits the data, how much staleness is tolerable, what happens when the cache is unavailable.
Batch vs Sequential Feedback
Delivery matters as much as content, and the deciding question is whether the fixes touch each other.
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 fieldSequential 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"Example-Based Communication in Practice
Moving from prose to examples follows a repeatable sequence:
- Observe inconsistency: the same instruction produces a different result on each run.
- Switch to examples: supply two or three before/after pairs that pin the transformation exactly.
- Verify generalisation: try a case the examples did not cover, to confirm the pattern transferred rather than the instances being copied.
- 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
| Situation | Technique |
|---|---|
| Prose description interpreted differently each time | Concrete input/output examples |
| Complex transformation with many edge cases | Test-driven iteration |
| Working in an unfamiliar domain | Interview pattern |
| Multiple issues that affect each other | Batch feedback (one message) |
| Multiple independent issues | Sequential feedback |
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.
Sources: https://code.claude.com/docs/en/sessions (/compact [instructions]) · https://code.claude.com/docs/en/best-practices (using it mid-session) (fetched 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, and checkpointing does not track changes made by Bash commands, only edits made through Claude's own file-editing tools.
Sourcecode.claude.com › checkpointingfetched 2026-07-30
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
| Situation | Technique |
|---|---|
| Prose interpreted differently each run | Concrete input/output examples (2-3 pairs) |
| Complex transformation, many edge cases | Test-driven iteration — share test failures |
| Unfamiliar domain, might miss considerations | Interview pattern — let Claude ask questions first |
| Fixes interact with each other | Batch feedback in a single message |
| Fixes are independent | Sequential feedback, one at a time |
| 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 opinion | Writer/Reviewer pattern — fresh session reviews, no shared reasoning context |
| Scaffold for the whole cycle | Explore → Plan → Implement → Commit |
Exam Traps
Practice Scenario
A developer describes a code transformation in prose. Claude Code interprets it differently each time, producing inconsistent results. What technique should the developer try first?
Build Exercise
Practice Iterative Refinement Techniques
Difficulty: Beginner (1/4)
30 minutes
- Describe a code transformation in prose and run it three times, noting how interpretation varies across runs
Why: This demonstrates the core problem that concrete examples solve. Prose descriptions rely on interpretation, and interpretation varies across runs. Observing this inconsistency firsthand makes the case for switching to examples.
You should see: Three different outputs from the same prose description. The variations may be subtle (different naming choices, different edge case handling) or significant (different structural approaches). This proves that prose alone produces inconsistent results.
- Provide 2-3 concrete input/output examples of the same transformation and run it three times — compare the consistency
Why: Concrete examples are the documented first-line technique for inconsistent interpretation. The model generalises from examples more reliably than from prose. This step proves the effectiveness difference experimentally.
You should see: Three outputs that are consistent with each other and match the pattern established by the examples. The variation observed in the prose-only step is eliminated or drastically reduced.
- Write a test suite for a function with happy path, edge cases, and error cases, then iterate by sharing test failures with Claude Code
Why: Test-driven iteration is the most effective technique for complex transformations. Test failures provide unambiguous feedback — "Expected X, got Y" leaves no room for interpretation. This technique complements examples for more complex scenarios.
You should see: After sharing test failures, Claude Code makes targeted fixes that address the specific failing assertions. Each iteration reduces the number of failing tests. The feedback loop is faster and more precise than prose-based corrections.
- Use the interview pattern for a task outside your expertise — ask Claude to pose questions before implementing and note what considerations surface
Why: The interview pattern is for unfamiliar domains where you might miss important requirements. It surfaces considerations an expert would know to address. The exam tests whether you can distinguish this from the examples technique — they solve different problems.
You should see: Claude asks 5-10 targeted questions about requirements, edge cases, and constraints you had not considered. The questions reveal considerations like cache invalidation strategies, consistency requirements, failure modes, or security implications that would have been missed.
- Practice batching: give Claude three interdependent issues in one message and observe whether the fix is coherent across all three
Why: When issues interact, batching them in one message lets the model see all constraints simultaneously. Sequential fixing of interdependent issues causes the model to fix one issue in a way that conflicts with the others. The exam tests this distinction.
You should see: A single coherent fix that addresses all three interdependent issues consistently. The error response shape, the logging format, and the type definitions all align with each other. Compare this to fixing them sequentially, where each fix might conflict with the next.
Sources
- Claude Code Iterative Development Documentation — Anthropic
- Claude Code Sessions Documentation (forking and branching) — Anthropic
- Claude Code Checkpointing Documentation (/rewind) — Anthropic
- Claude Certified Architect Foundations Exam Guide — Task Statement 3.5 — Anthropic
Appendix A — Build Exercise Step Hints
Progressive hints revealed by the "Stuck? Get a nudge" control on each step.
Step 1. Describe a code transformation in prose and run it three times, noting how interpretation varies across runs
Why: This demonstrates the core problem that concrete examples solve. Prose descriptions rely on interpretation, and interpretation varies across runs. Observing this inconsistency firsthand makes the case for switching to examples.
You should see: Three different outputs from the same prose description. The variations may be subtle (different naming choices, different edge case handling) or significant (different structural approaches). This proves that prose alone produces inconsistent results.
Stuck? Get a nudge
Step 2. Provide 2-3 concrete input/output examples of the same transformation and run it three times — compare the consistency
Why: Concrete examples are the documented first-line technique for inconsistent interpretation. The model generalises from examples more reliably than from prose. This step proves the effectiveness difference experimentally.
You should see: Three outputs that are consistent with each other and match the pattern established by the examples. The variation observed in the prose-only step is eliminated or drastically reduced.
Stuck? Get a nudge
Step 3. Write a test suite for a function with happy path, edge cases, and error cases, then iterate by sharing test failures with Claude Code
Why: Test-driven iteration is the most effective technique for complex transformations. Test failures provide unambiguous feedback — "Expected X, got Y" leaves no room for interpretation. This technique complements examples for more complex scenarios.
You should see: After sharing test failures, Claude Code makes targeted fixes that address the specific failing assertions. Each iteration reduces the number of failing tests. The feedback loop is faster and more precise than prose-based corrections.
Stuck? Get a nudge
Step 4. Use the interview pattern for a task outside your expertise — ask Claude to pose questions before implementing and note what considerations surface
Why: The interview pattern is for unfamiliar domains where you might miss important requirements. It surfaces considerations an expert would know to address. The exam tests whether you can distinguish this from the examples technique — they solve different problems.
You should see: Claude asks 5-10 targeted questions about requirements, edge cases, and constraints you had not considered. The questions reveal considerations like cache invalidation strategies, consistency requirements, failure modes, or security implications that would have been missed.
Stuck? Get a nudge
Step 5. Practice batching: give Claude three interdependent issues in one message and observe whether the fix is coherent across all three
Why: When issues interact, batching them in one message lets the model see all constraints simultaneously. Sequential fixing of interdependent issues causes the model to fix one issue in a way that conflicts with the others. The exam tests this distinction.
You should see: A single coherent fix that addresses all three interdependent issues consistently. The error response shape, the logging format, and the type definitions all align with each other. Compare this to fixing them sequentially, where each fix might conflict with the next.
Stuck? Get a nudge
Appendix B — Interactive Study Prompts
Two prompts to paste into Claude. B1 drills the judgement the exam actually measures; B3 reviews the work you produced for the Build Exercise above. The exam simulator between them is the interactive quiz on this page.
B1. Concept Check — Discrimination Drill
You are examining me for the Claude Certified Architect – Foundations (CCAR-F) exam, Domain 3: Claude Code Configuration & Workflows (20% of the exam), Task Statement 3.5: Iterative Refinement Techniques. Use British English throughout.
What this exam actually measures. Not one item on the official exam asks what something is. Every item drops you into a production system that is already misbehaving, offers four defensible engineering responses, and asks which is best. The skill being tested is proportionality: fix the root cause with the cheapest instrument that gives the guarantee the situation demands. So do not quiz me on definitions. Make me choose between options that are both defensible, then attack whatever I chose.
How to run this session.
- One question at a time. Stop and wait. Never answer your own question, and never move on until I have committed.
- Never reveal which option is right before I commit to one.
- Do not praise me. A correct answer earns "Yes" and the next question. If I am right for the wrong reason, say so — that is the failure that costs marks on exam day.
- When I am wrong, quote the exact phrase in my answer that gave it away, correct it in one sentence, and move on. One correction at a time.
- If I write something fluent but empty, name it: "That is a restatement, not a reason."
- Set every scenario inside one of the exam's production contexts: Code Generation with Claude Code (a team leaning on custom slash commands, CLAUDE.md configuration, and plan mode versus direct execution), Claude Code for Continuous Integration (automated review, test generation and PR feedback in a pipeline that has to keep false positives down), or Developer Productivity with Claude (an agent over an unfamiliar codebase using the built-in
Read,Write,Bash,Grep,Globtools).
Session plan — about twelve questions.
Round 1 — Anchor (1 question). One concrete question to check I have actually read the material. If I cannot answer it, stop the session and tell me to read the lesson before continuing.
Round 2 — Discrimination (5 questions). Each one: describe a symptom in one of the contexts above, with a number or a concrete observation in it — how many runs of the same prompt produced different shapes, which assertion is failing and what it got instead, how many of the reported issues touch the same data structure. Offer exactly two responses, both defensible. Ask me to pick one and justify it in a single sentence. Then argue the case for the option I rejected as strongly as you can, and ask whether I am holding or changing my answer. Only after I answer that, tell me which is right and why the other one is the more tempting trap.
Round 3 — Proportionality (2 questions). Take one symptom and run it twice with different stakes: once where the cost of the wrong technique is one more round of iteration on a scratch branch, once where the transformation is being applied unattended across a migration script that touches production data. The right answer must change between the two. If I answer the same way both times without noticing the stakes moved, that is the finding — tell me.
Round 4 — Code review (3 questions). Present a colleague's confident proposal containing one of the trap errors listed below, written the way a teammate would write it in a pull request. Ask me what is wrong with it. Do not signal that anything is wrong.
Round 5 — Verdict. Rate me green, amber or red on each concept below. Name the single weakness most likely to cost me marks, and give me one specific next action: a section of this lesson to re-read, or a step of the Build Exercise to redo. If I am not ready for this task statement, say so plainly.
Concepts in scope
- Concrete input/output examples — the first-line technique when a prose description is interpreted differently on each run. Two or three exact before-and-after pairs set the pattern, and the model generalises from them far more reliably than from any amount of extra prose.
- Test-driven iteration — write the suite first, covering the happy path, edge cases and any performance requirement, then hand back the failures. "Expected X, got Y" leaves nothing to interpret, which is why it beats a prose correction on a complex transformation.
- The interview pattern — in a domain you do not know, ask Claude to question you before it implements anything, so considerations you would never have thought to specify surface first.
- Interview versus examples — two different problems. The interview pattern covers missing domain knowledge; examples cover a transformation you can state exactly but the model keeps reading differently. Applying either to the other's problem wastes the round.
- Batch versus sequential feedback — fixes that interact go in one message so the model sees all the constraints at once and produces something coherent; independent issues go one at a time, because batching them muddles which correction applies where.
Trap errors to plant in Round 4
- Rewriting the prose description more precisely when the model keeps interpreting it differently, instead of replacing it with examples.
- Batching independent issues into one message, or drip-feeding interacting ones one at a time so each fix undoes the last.
- Reaching for the interview pattern when the transformation is already known exactly and only the interpretation is unstable.
Stay inside the material above. If I raise something outside it, tell me it is out of scope for this task statement and return to the drill. Begin with Round 1.
B2. Exam Simulator
Exam simulator
Question 1 of 10
Scenario · Code Generation with Claude Code
You have asked Claude three times to convert your service functions to a Result-returning signature, describing the change in prose each time. Each run produces a slightly different shape: one wraps the error type, one changes the return only on failure paths. What's the most effective first step?
B3. Build Coach — Prompt Review
The Build Exercise and its hint ladder are already on this page. This prompt is for the one thing the page cannot do: review the work you actually produced.
You are a staff engineer reviewing my implementation of a build exercise for the Claude Certified Architect – Foundations exam, Domain 3, Task Statement 3.5: Iterative Refinement Techniques. Use British English throughout.
I am building a controlled experiment that puts the refinement techniques against each other: the same transformation described in prose and run three times, then re-run from a small set of concrete input/output pairs; a test suite written before the implementation and iterated by feeding the failures back; the interview pattern used on a domain I do not know; and one message carrying three fixes that interact with each other.
It has to satisfy all of the following:
- Three outputs from the identical prose prompt, with the variation between them recorded specifically rather than asserted in general terms.
- The same transformation re-run from two or three concrete before-and-after pairs, with the earlier variation visibly reduced and the pattern generalised to a case the pairs did not cover.
- A test suite spanning the happy path, edge cases and error cases, and a record of failures being handed back with the failing count dropping each round.
- An interview-pattern run in an unfamiliar domain that surfaces considerations I had not specified — invalidation strategy, consistency requirements, behaviour on failure.
- One message carrying three interacting fixes, and a result in which all three agree with each other rather than one having been solved at the expense of another.
How to review.
- Ask me to paste the prompts I used and the outputs I got back at each stage. If I have not pasted them, ask for that and nothing else. Do not write the prompts for me, do not offer a reference version, and do not fill in a step I have skipped.
- Work through the criteria above in order. For each one, quote the line of my transcript that satisfies it, or say plainly that nothing does.
- Then hunt for the failure modes below. Each is a real refinement failure, not a style preference.
- Rank everything you find: (1) the experiment does not actually demonstrate what it claims, (2) would lose marks on the exam, (3) style. Give me the first item under (1) and then stop — wait for my fix before giving me the next one.
- If my work satisfies everything, do not congratulate me. Change the requirements — of the three issues in the batch, one now turns out to be independent of the other two — and make me say how the delivery changes.
- If I ask you to just write it for me, refuse once and give me the smallest nudge that would unblock me instead.
Failure modes to probe
- Prose polished into a more precise description rather than replaced by examples, which leaves interpretation in the loop and reproduces the original problem.
- Example pairs that all show the same shape, so there is nothing to generalise from and the model copies the examples instead of inferring the rule.
- Test failures paraphrased instead of pasted, throwing away the exact expected-versus-actual wording that makes the technique unambiguous.
- The interview pattern used as a warm-up on a transformation I could already state exactly, which spends a round confirming what I already knew.
- Independent issues batched, or interacting ones split across turns, so a later fix silently contradicts the constraint an earlier one satisfied.
Start by asking me for the prompts I used and the outputs I got back.