Back to Library
Iterative DebuggingAdvanced

Iterate on Prompts, Not Outputs

When Claude's output is wrong, most people re-run or rephrase the same prompt. Instead, diagnose WHY it failed and add a targeted constraint.

iterationdebugging-promptsrefinement

The Strategy

Vague re-runs produce random variation. Diagnosing exactly what went wrong and adding a precise negative constraint gives you deterministic improvement, not a slot machine.

prompt.txt
// Bad iteration (repeating yourself):
"Try again but make it better"

// Good iteration (targeted fix):

// Observation: Claude added unnecessary comments
// Targeted constraint added:
<constraints>
<add>Do NOT include any inline comments or JSDoc</add>
</constraints>

// Observation: Claude used a class instead of a function
// Targeted constraint added:
<constraints>
<add>Use only arrow function expressions—no class keyword permitted</add>
</constraints>

You might also need