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
PromptingBeginner
Use Negative Constraints
Tell Claude what NOT to do. "Do not add comments", "Do not use any external libraries" — negative constraints are just as powerful as positive ones.
constraintsguardrailsfocused-output
View snippet
Iterative DebuggingBeginner
The Error → Fix → Verify Loop
Structure debugging sessions as a tight loop: paste the error, get a fix, verify with the exact command, repeat.
debuggingerrorsloop
View snippet