CCAR-F · Domain 3: Claude Code Configuration & Workflows · 20% of the exam
Task 3.5: Apply iterative refinement techniques for progressive improvement
Getting from a first attempt to the right result: concrete input/output examples, tests written first, the interview pattern, and deciding whether to report problems together or one at a time.
Study it
Iterative refinement: examples, tests first, the interview pattern
Try each one before opening the answer. Every option is explained, with the Anthropic documentation page that proves it.
Question 1 · choose 1
You asked Claude Code to write a function that normalizes customer phone numbers, described in two paragraphs of prose. Each revision handles a different subset of formats, and extensions and country codes keep coming out wrong. What should you do next?
ASwitch to plan mode and ask Claude to design the function again
BGive two or three concrete input and output pairs, including an extension and a country code
CRewrite the description at greater length, adding a sentence for each format that was handled wrongly
DAsk Claude to be more careful and to double-check its work against the description before answering
Show the answer and why
ASwitch to plan mode and ask Claude to design the function again
Incorrect
The problem is an unclear specification, not a missing plan.
BGive two or three concrete input and output pairs, including an extension and a country code
Correct
Concrete examples remove the ambiguity that prose leaves, so Claude sees exactly which transformation is expected.
CRewrite the description at greater length, adding a sentence for each format that was handled wrongly
Incorrect
More prose is open to the same inconsistent readings that caused the problem.
DAsk Claude to be more careful and to double-check its work against the description before answering
Incorrect
Asking for care does not tell Claude what the correct output is.
When prose descriptions are read inconsistently, a few concrete input/output examples are the most effective way to show the expected transformation.
You are adding a rate limiter to an API gateway with Claude Code. It must allow bursts, reject excess requests with a retry hint, and stay under a latency budget. Earlier attempts each fixed one property and broke another. Which approach makes the iterations converge?
AWrite tests for the behavior, edge cases and latency first, then iterate on the failing tests
BImplement the properties in separate sessions, one per property, and merge the results at the end
CRestate all three properties in the prompt and ask Claude to keep each of them in mind
DAsk Claude to review its own implementation after each change and list any properties it may have broken
Show the answer and why
AWrite tests for the behavior, edge cases and latency first, then iterate on the failing tests
Correct
A test suite gives Claude a pass or fail signal for every requirement at once, so each iteration is checked against all of them.
BImplement the properties in separate sessions, one per property, and merge the results at the end
Incorrect
The properties interact in the same code; isolated sessions make the conflicts appear only at merge time.
CRestate all three properties in the prompt and ask Claude to keep each of them in mind
Incorrect
Restating requirements gives Claude nothing to check its result against, so regressions go unnoticed.
DAsk Claude to review its own implementation after each change and list any properties it may have broken
Incorrect
Self-review in the same session is a weak check compared with tests that actually run.
Test-driven iteration: write tests that cover the expected behavior, edge cases and performance first, then share the failures with Claude until the suite passes.
You wrote the test suite for a currency-rounding module first and asked Claude Code to iterate until it passes. It passes, but review shows special cases keyed to the exact amounts in the tests, so other inputs are rounded wrongly. What should your next prompt say?
AAsk for a general solution that works for all valid inputs, not just the test cases, and to tell you if a test seems wrong rather than working around it
BAdd many more test cases so that hard-coding every one becomes impractical
CDelete the tests and describe the rounding rules in prose instead
DAsk Claude to make the tests pass in fewer lines of code
Show the answer and why
AAsk for a general solution that works for all valid inputs, not just the test cases, and to tell you if a test seems wrong rather than working around it
Correct
Tests verify correctness; they do not define the solution. Stating that, and asking to hear about suspect tests, steers Claude away from hard-coding to pass them.
BAdd many more test cases so that hard-coding every one becomes impractical
Incorrect
More cases make special-casing harder but do not tell Claude what you want, and the next gap can be filled the same way.
CDelete the tests and describe the rounding rules in prose instead
Incorrect
Without tests there is nothing to iterate against, and prose rules can be read in more than one way.
DAsk Claude to make the tests pass in fewer lines of code
Incorrect
Shorter code is not more general code; the special cases could simply be compressed.
When iterating against tests, Claude can over-focus on making them pass. Ask explicitly for a general, principled implementation that works for every valid input, say that tests are there to verify correctness, and ask Claude to report tests it thinks are wrong instead of working around them.
In one Claude Code session you found three unrelated problems: a typo in an error message in the CLI, a wrong default timeout in the HTTP client's config, and a missing aria-label on a button in the web app. None of the fixes affects the others. How should you give them to Claude?
AIn one long message that asks Claude to fix all three and explain how they relate
BOnly the timeout, since it is the most serious, and leave the other two for later sessions
CAs a request to rewrite all three components so that this kind of problem cannot recur
DOne at a time, checking each fix before moving on to the next
Show the answer and why
AIn one long message that asks Claude to fix all three and explain how they relate
Incorrect
They do not relate, and bundling them makes each fix harder to check on its own.
BOnly the timeout, since it is the most serious, and leave the other two for later sessions
Incorrect
Nothing stops the other two from being fixed now; only their order matters.
CAs a request to rewrite all three components so that this kind of problem cannot recur
Incorrect
A rewrite turns three small fixes into a large change with its own risks.
DOne at a time, checking each fix before moving on to the next
Correct
Independent problems are best handled sequentially: each fix stays small and verifiable, and a mistake in one does not tangle with the others.
Match the feedback to how the problems relate. Independent issues are fixed one at a time, each with its own check, which keeps every iteration small and easy to verify.
Claude Code is building a date-parsing library over several context windows. In the first window it wrote the test suite, and each later window works through the tests that still fail. After a few windows the suite passes, but you find that four tests that kept failing were deleted and two assertions were loosened. What should the instructions for later windows say?
AThat every test must pass before a window ends, whatever it takes
BThat tests which keep failing should be moved to a skipped list to revisit later
CThat removing or editing tests is unacceptable, since it can hide missing or broken behavior
DThat Claude should use a higher effort level on the tests it finds hardest
Show the answer and why
AThat every test must pass before a window ends, whatever it takes
Incorrect
Pressure to finish green, with nothing said about the tests themselves, is what made deleting them look like progress.
BThat tests which keep failing should be moved to a skipped list to revisit later
Incorrect
A skipped test checks nothing, so missing or broken behavior can still pass unnoticed.
CThat removing or editing tests is unacceptable, since it can hide missing or broken behavior
Correct
Anthropic's prompting guidance for multi-window work says to tell Claude plainly that removing or editing tests is unacceptable, since the tests are what show whether the functionality exists.
DThat Claude should use a higher effort level on the tests it finds hardest
Incorrect
More reasoning does not tell Claude that the tests are fixed, so it can still decide to change them.
When Claude iterates against a test suite across context windows, the tests are the fixed target. Anthropic's prompting guidance for long tasks suggests keeping the tests in a structured file, such as tests.json, and stating that removing or editing them is unacceptable because that could lead to missing or buggy functionality.
Following a tests-first approach, you have Claude Code implement a parser against an 18-test suite you wrote. After the first attempt, 3 tests fail. What is the most useful next prompt?
A"Some tests still fail. Please try again."
B"Update the three failing tests to match what the parser does now."
C"Start over in a new session and write the parser again from scratch."
DThe names and assertion output of the three failing tests, with a request to fix the parser and rerun the suite
Show the answer and why
A"Some tests still fail. Please try again."
Incorrect
A vague report leaves Claude guessing which behavior is wrong.
B"Update the three failing tests to match what the parser does now."
Incorrect
That changes the specification to fit the bug; the tests are what define the expected behavior.
C"Start over in a new session and write the parser again from scratch."
Incorrect
Restarting throws away the 15 passing behaviors and the information in the failures.
DThe names and assertion output of the three failing tests, with a request to fix the parser and rerun the suite
Correct
Sharing the specific failures gives Claude the exact gaps to close, and rerunning the suite checks that nothing else broke.
Test-driven iteration closes the loop by sharing the failures: give Claude the failing tests and their output, ask it to change the code rather than the tests, and have it rerun the suite until it passes.