📄 Domain 3 · Task Statement 3.5

Apply Iterative Refinement Techniques for Progressive Improvement

📊 Domain Weight: 20% 🎯 Difficulty: Advanced Mastery 🔗 Scenarios: Complex Refactors & Quality Enforcement

Iterative refinement is the cornerstone of building complex, reliable systems with Claude. Instead of expecting a perfect one-shot answer, architects must master the art of the feedback loop—using tests, multi-turn dialogue, and validation signals to progressively converge on production-grade excellence.

📋 Contents

  1. Real-World Analogy: The Sculptor's Progression
  2. What is Iterative Refinement?
  3. The Three Pillar Feedback Loops
  4. Diagram: The Refinement Loop
  5. Key Refinement Techniques
  6. Iterative Refinement in Agent SDK
  7. Scenario walkthrough: From Prototype to Production
  8. Anti-Patterns to Avoid
  9. Exam Readiness & Key Takeaways

🏭 Real-World Analogy: The Sculptor's Progression

🩹 Analogy — From Block to Masterpiece

Imagine a sculptor working on a marble statue of a figure:

  • Phase 1 (Rough Cut): Using a heavy chisel to knock off the largest chunks of marble. You can see the general pose, but it lacks features.
  • Phase 2 (Defining Forms): Refining the limbs, the torso, and the head. The figure is recognizable but the surface is coarse.
  • Phase 3 (Detailing): Carving the eyes, the hair, and the fingers. Precision is high, but the overall harmony isn't perfect yet.
  • Phase 4 (Polishing & Consistency): Using fine tools and sandpaper to remove scratches and ensure all parts feel like they belong to the same work.

If the sculptor tried to carve the eyes first, they'd likely run out of space or get the proportions wrong. Iterative refinement follows this same logic: solve the big problems first, then the specific details, then the edge cases, then the stylistic consistency.

💡 What is Iterative Refinement?

Iterative refinement is the process of improving an AI output through repeated cycles of Review → Feedback → Modification. In a Claude Code session, this means recognizing that "Claude's first attempt is a high-quality draft, but rarely the final solution."

It shifts the developer's role from a "Prompt Writer" to a "Collaborator and Auditor." Instead of writing a 1,000-word prompt to ensure everything is perfect, you write a clear starting prompt, let Claude build the foundation, and then guide it through the complex parts.

🔄 The Three Pillar Feedback Loops

Successful iterative refinement relies on three distinct ways to feed information back to Claude to trigger the next refinement cycle:

1
The Machine Loop (Tests & Linting): This is the strongest signal. Use `npm test`, `pytest`, or `eslint` to find objective failures. Feed the error output directly back to Claude. "I ran the tests and these 3 failed; here is the output. Please fix the logic in handlers.ts."
2
The Expert Loop (Review & Critique): This uses your domain knowledge. You read the code and spot architectural issues, anti-patterns, or missed requirements. "This works, but we shouldn't be using a singleton here. Refactor the DB connection to use a Dependency Injection pattern."
3
The Clarification Loop (Self-Questioning): This is Claude "interviewing" the user. In high-complexity tasks, Claude may ask: "Should I handle the edge case where the user token is expired, or assumes the middleware handles that?" Your answer triggers the refined implementation.

🕐 Diagram: The Refinement Loop

Figure 1 — Progressive Improvement Cycle
Initial Request Draft Proposed Evaluation (Verify) Refinement Steering Production Layering & Continuous Signal

🔧 Key Refinement Techniques

1. Layering (The "Inside-Out" Approach)

Instead of doing the entire task, ask Claude to implement just the core logic first. Once verified, refinement cycles add logging, edge-case handling, and finally documentation. This ensures that the foundational logic is solid before the noise of boilerplate is added.

2. TDR (Test-Driven Refinement)

Ask Claude to write the tests before the implementation (or use existing ones). If the first implementation fails the tests, Claude has an objective signal to refine. This is the gold standard for iterative development.

3. The "Critique First" Prompt

Instead of asking Claude to "fix" the code, ask it to "Critique the current implementation against PSR-12 standards and thread-safety requirements. Identify 3 flaws." Then, after the critique, say "Refine the code based on your critique." This triggers a much deeper refinement than a simple "improve this."

💡 Efficiency — Don't be afraid to start over

If the refinement path is getting messy or Claude is "trapped" in a loop of fixing its own fix, don't keep iterating. It is often faster to reset the context (start a new session or `/clear`) and provide the best parts of the previous iteration as the new starting point.

🤖 Iterative Refinement in Agent SDK

In the Agent SDK context, iterative refinement is often automated between the Coordinator and Subagents. This is called "Autonomous Synthesis."

Logic Flow — Multi-Agent Refinement
# 1. Coordinator delegates to ResearchSubagent
results = await subagent.execute("Find security risks in this file")

# 2. Coordinator evaluates the output internally
if (!isValid(results)) {
  # 3. Coordinator triggers the refinement loop
  refinedResults = await subagent.execute({
    task: "The previous results lacked detail on SQL Injection. Please re-run.",
    context: results
  })
}

On the exam, knowing that the Coordinator should act as the quality gate for subagents is a key architectural concept.

Anti-Patterns to Avoid

⛔ The "Big Bang" Prompt

Trying to specify every detail of a 200-line function in a single message. Paradoxically, the more detail you give in one shot, the more likely Claude is to miss something or misinterpret a constraint.

⛔ Ignoring Console Fatigue

Accepting a proposed fix for a bug that Claude says "should work now," without verifying it. This leads to "Phantom Progress"—where the session continues based on a flawed foundation.

⛔ Vague Negative Feedback

Saying "This is wrong" or "I don't like it" without context. Refinement requires signal. Instead, say: "This is wrong because the function should return a Promise, but it's returning a boolean."

⛔ Perfect-Output Trap

Refining a perfectly functional (but slightly ugly) utility function for 5 turns when a higher-priority task is waiting. Know when the "Definition of Done" has been met.

Exam Readiness & Key Takeaways

🎯 Exam Focus — Scenario Decision

Scenario: You are using Claude to refactor a complex authentication logic. The first output is logically correct but violates the company's naming conventions and lacks error handling. What is the best next step?

  • A) Write a new 500-word prompt starting from scratch.
  • B) Ask Claude to fix only the naming conventions, then ask for error handling in a subsequent turn. ← Correct (Iterative/Layered)
  • C) Manually fix the naming conventions and then ask Claude to add error handling.
  • D) Accept the output as-is to save tokens.

Reasoning: Layered refinement allows for focused validation at each step. By fixing naming first, you verify style, then you verify safety. This produces cleaner history and higher reliability.

1
Output the draft, refine the detail: Expecting 100% correctness on the first turn of a complex task is a mistake. Focus on getting the foundation right first.
2
Signals over Prose: Machine signals (tests, lints) are the highest quality feedback. Use them to trigger the next refinement turn.
3
Layered implementation: Break complex tasks into verifiable layers (Core Logic → Edge Cases → Style/Docs).
4
Coordinator as Gatekeeper: In multi-agent systems, the coordinator must actively refine subagent outputs if they fail quality checks.
5
Definition of Done: Always evaluate refined output against your explicitly stated success criteria.