Iterating on prompts
Prompting is a conversation, not a one-shot request — learn the strategies for diagnosing and fixing output that misses the mark.
- Recognise when AI output has missed the mark and diagnose the root cause
- Apply at least four specific strategies for redirecting a conversation mid-stream
- Distinguish between fixing a symptom and fixing the underlying prompt problem
- Use the AI's own output as material for a more focused follow-up
The first response you get from an AI is a draft, not a deliverable. Even with a well-structured prompt, the output often needs adjustment: the wrong level of detail, a missed edge case, a solution that works but could be cleaner. The ability to iterate — to recognise what's wrong and know how to fix it — separates someone who uses AI occasionally from someone who uses it reliably.
This lesson is about prompting as a conversation rather than a one-shot transaction.
Why iteration is normal
A model generates a response based on everything in its context at that moment. Your first prompt rarely contains all the information needed to uniquely determine the output you want. Iteration is the process of adding that information progressively — through follow-ups, corrections, and redirections — until the model's context reflects the task well enough to produce good output.
This is not a failure of the AI or of your prompting. It is the expected shape of the interaction. Professional writers revise; professional developers iterate on code. The goal isn't to get it perfect on the first try — the goal is to converge efficiently.
Diagnosing before responding
When output misses the mark, resist the reflex to immediately send another message. Spend thirty seconds diagnosing. Which of these is the actual problem?
- Wrong task: The model did something adjacent to what you wanted, but not quite. Your Task component was ambiguous. Fix: restate the task more precisely.
- Missing context: The model made an assumption — about your audience, your stack, your constraints, the shape of your data — that you could have specified. Fix: add the missing information.
- Wrong format: The output is technically correct but in the wrong shape. Fix: state the format you need explicitly.
- Wrong constraint: The output satisfied your request but in a way you didn't want. Fix: add a constraint that excludes that approach.
Naming the problem takes ten seconds and saves you two rounds of unproductive re-prompting.
The single most common iteration mistake is sending a vaguer follow-up after a vague first prompt. "That's not what I meant" gives the model almost no signal to work with. "That explanation assumes knowledge of async/await — can you rewrite it for someone who only knows synchronous JavaScript?" is specific enough to work.
Strategies for mid-conversation correction
Ask for a different approach. The model's first solution is not necessarily its best one. If the approach has a fundamental problem, say so:
"That works, but it uses a nested loop which will be slow on large inputs. Can you try a different strategy that avoids the O(n²) complexity?"
This is more effective than asking generically for "a better solution" — you've named the specific problem with the current one.
Add a constraint you forgot. You can add constraints mid-conversation and ask for a revision:
"Can you rewrite that without using any libraries other than the standard library?" "Same thing, but it needs to handle the case where the input list is empty."
The model will incorporate the new constraint into a revised solution. You don't need to repeat everything from the original prompt — the conversation history is already in context.
Ask why. When a solution is correct but unfamiliar, asking for an explanation builds your understanding and sometimes surfaces a better alternative:
"Why did you use a dictionary here instead of two separate lists?"
The model's explanation might confirm that the choice was deliberate and good — or it might reveal that a simpler approach also works.
Request a critique. This is one of the most underused strategies. After getting a solution, ask the model to criticise it:
"What are the weaknesses of this approach? What would you do differently if you were starting from scratch?"
You are asking the model to review its own output from a different angle. It often surfaces edge cases, performance problems, or simpler alternatives that didn't appear in the original response.
Ask for alternatives. If you're not sure which approach to take:
"Give me three different ways to solve this problem and list the main trade-off of each."
This uses the model's breadth rather than its depth, and gives you options to evaluate rather than a single path to either accept or reject.
Using output as input
A powerful pattern: use the model's response as the starting material for a more targeted follow-up. Instead of describing what you want abstractly, point at the specific part that needs changing.
"In paragraph 2, the sentence starting with 'However' contradicts what you said in paragraph 1. Can you reconcile them?"
"The function on line 8 — can you extract that into a separate function with a clearer name?"
Specific references to specific output give the model precise anchor points. This is faster and more reliable than describing the problem in the abstract.
Context accumulates. A long conversation containing many revisions may produce a model that has lost track of early constraints. If the output drifts or starts contradicting earlier decisions, it is often better to start a fresh conversation with a single well-structured prompt that incorporates everything you've learned from the iteration so far.
The meta-skill: recognising the gap type
The real skill in iterating on prompts is accurately identifying the gap between what you got and what you needed. The four gap types — wrong task, missing context, wrong format, wrong constraint — are a reliable taxonomy. Every time you iterate, you're implicitly adding one of these to your prompt. Making that explicit speeds up convergence.
Over time, you'll get faster at anticipating gaps before you send the first prompt. The patterns repeat: the missing audience specification, the forgotten empty-input case, the format you always have to specify for this class of task. That accumulating intuition is what makes experienced AI users faster — not that they craft perfect first prompts, but that they have a shorter diagnostic loop when the first one is off.
Where to go next
You now have a complete toolkit for prompt structure and iteration. The final lesson in this module covers a constraint that sits beneath all of it: tokens and context windows — the physical limits on how much the model can see at once, and the practical implications for how you structure your work.
Knowledge check
- 1.A developer gets a code solution that technically works but uses a nested loop they know will be too slow. What is the most effective follow-up?
- 2.Which of the following are effective mid-conversation iteration strategies? Select all that apply.
- 3.When AI output misses the mark, the best approach is always to refine and continue the same conversation rather than starting fresh.
Chain-of-thought prompting
Ask the AI to reason step by step before answering — a technique that measurably improves accuracy on multi-step problems.
Tokens and context windows
Understand what tokens are, why context windows matter, and how to work within them efficiently rather than fighting their limits.