Iterative refinement: examples, tests and interviews
How to steer Claude Code toward the right result over several rounds: concrete input/output examples when prose is misread, test-first iteration without editing or hard-coding to the tests, the interview-then-spec-then-fresh-session pattern, batching interacting issues versus fixing independent ones in turn, and resetting with /clear after repeated failed corrections.
Apply iterative refinement techniques for progressive improvement
~8 min read · 10 practice questions ·
What the exam expects
- Replace an ambiguous prose rule with 2-3 concrete input/output examples when Claude keeps reading it differently, and give a specific test case (sample input, exact expected output) to fix an edge case such as null values.
- Run test-driven iteration: tests for expected behaviour, edge cases and performance first, confirm they fail, then let Claude iterate on the failures without editing the tests or hard-coding to them.
- Use the interview pattern in an unfamiliar domain, then have Claude write a spec and implement it in a fresh session.
- Put interacting issues in one detailed message, and fix independent issues one at a time.
- Recognise when to stop correcting and start a clean session with
/clearand a better prompt.
Key terms: input/output example (a concrete before-and-after pair that shows the transformation); test-driven iteration (tests written before the code act as the fixed target Claude iterates against); interview pattern (Claude asks you questions, via the AskUserQuestion tool, before building); verification criteria (a check Claude can run that returns pass or fail); course correction (redirecting or resetting a session that has gone off track).
Key facts
- Detail
- Examples of the desired output beat abstract instructions
- Detail
- Exam guide: 2-3 I/O pairs; prompting page: 3-5 few-shot examples
- Detail
- Write a failing test that reproduces the issue, then fix it
- Detail
- "Unacceptable to remove or edit tests"
- Detail
- Ask for logic that works for all valid inputs, not just the test cases
- Detail
AskUserQuestion; finish with a complete spec inSPEC.md
- Detail
- Implement the spec in a fresh session
- Detail
- More than two corrections on one issue →
/clearand a better prompt
- Detail
- One detailed message vs sequential iteration
- When do concrete input/output examples beat a better prose description?
- Why should the implementation run in a fresh session after an interview?
- What should a prompt say to stop Claude special-casing test inputs?
- When should you stop correcting Claude and run
/clear?
The questions are free to read. Answers with their sources and self-grading are included with the pack.
Keep reading with the Claude Certified Architect - Foundations pack
- Core concepts
- Exam traps
- Worked scenario
The pack includes:
- All 30 lessons of the Claude Certified Architect - Foundations guide, with reading progress
- Interactive decision walks and step-by-step sequence steppers
- Inline practice questions and one-click topic practice (10 questions for this lesson)
- An official source cited for every claim
- An AI tutor that answers from the guide
- Unlimited timed practice exams
Practice for the Claude Certified Architect - Foundations exam
Certifyforce is an independent study resource and is not affiliated with, endorsed by or sponsored by Anthropic. Claude is a trademark of Anthropic.