Course එකට ආපසු

Iterative Prompting

20 මිනිත්තු📖Lecture

🎯 Lesson Objectives

By the end of this lesson, you will:

  • Understand that first prompts rarely give perfect results
  • Master the iteration loop for refining AI output
  • Know effective follow-up phrases that improve results
  • Avoid common iteration anti-patterns

📖 The Reality of Prompting

Here's a truth that might be comforting:

Prompting Reality

Your first prompt will rarely give you exactly what you want.

And that's completely okay! Professional prompt engineers expect to iterate.

Why First Prompts Often Miss:

  • You might not know exactly what you want until you see it
  • AI might interpret your words differently than intended
  • Complex requirements are hard to fully capture upfront
  • You'll discover new requirements as you go

The Goal:

Not to write the perfect first prompt, but to refine efficiently through conversation.


🔄 The Iteration Loop

Think of prompting as a conversation, not a single command:

┌─────────────────┐ │ 1. PROMPT │ ← Your initial request └────────┬────────┘ ↓ ┌─────────────────┐ │ 2. REVIEW │ ← Look at AI's response └────────┬────────┘ ↓ ┌─────────────────┐ │ 3. IDENTIFY │ ← What's missing or wrong? └────────┬────────┘ ↓ ┌─────────────────┐ │ 4. REFINE │ ← Ask for specific changes └────────┬────────┘ │ ↓ (repeat until satisfied) ┌─────────────────┐ │ 5. DONE │ ← Result matches your needs └─────────────────┘

🔘 A Quick Example: Button Iteration

StepYour ActionResult
Initial"Create a button"Basic gray button
Review"Hmm, I wanted blue and bigger"-
Refine"Make it blue with white text and 20px padding"Blue button, better
Review"Nice, but needs hover effect"-
Refine"Add hover effect that darkens slightly"Blue button with hover
Done!3 prompts, 2 minutesExactly what you wanted

💬 Powerful Follow-Up Phrases

Here are proven phrases that guide AI to better results:

For Simplification:

Text
"Make it simpler"
"Reduce complexity"
"Write a more basic version"
"Can you simplify this?"

For Addition:

Text
"Add [feature]"
"Include [element]"
"Also make it [quality]"
"Can you add validation for..."

For Removal:

Text
"Remove [element]"
"Don't include [feature]"
"Simpler, without [thing]"
"Take out the [component]"

For Clarification:

Text
"Explain why you did [thing]"
"What does this part do?"
"Walk me through the logic"
"Why this approach?"

For Alternatives:

Text
"What's another way to do this?"
"Show me a different approach"
"What if we used [alternative]?"
"Any other options?"

For Style:

Text
"Make it look more [adjective]"
"Use [color/style] instead"
"Match this design: [description]"
"Make it mobile-friendly"

🎮 Full Example: Building a Countdown Timer

Let's see a complete iteration session:

Prompt 1 (Initial):

Create a countdown timer

AI Creates: Basic countdown in Python (console-based) Problem: I wanted web-based!


Prompt 2 (Refine):

Make it a web-based countdown timer using HTML, CSS, and JavaScript

AI Creates: Web countdown with basic styling Problem: No way to set the time!


Prompt 3 (Add Feature):

Add an input field where users can enter minutes to count down

AI Creates: Timer with input field Problem: Looks plain


Prompt 4 (Style):

Make the design modern with dark background, large numbers, nice start button

AI Creates: Styled timer with dark theme Problem: Should make sound when done!


Prompt 5 (Edge Case):

Add a beep sound and visual flash when timer reaches zero

AI Creates: Timer with audio alert Review: Perfect! ✅


Total: 5 prompts → Polished, fully-featured timer!


❌ Anti-Patterns to Avoid

These common mistakes slow down iteration:

Anti-Pattern 1: Starting Over for Every Change

❌ Wrong Way
✅ Right Way
'Create timer' → 'Create timer with input' → 'Create timer with input and dark theme'
'Create timer' → 'Add input field' → 'Make it dark themed'
Each time you start fresh, losing context
Build on previous responses

Fix: Keep the conversation going. AI remembers context.


Anti-Pattern 2: Accepting First Result Without Review

❌ Wrong
✅ Right
AI output → Immediately use → Find problems later
AI output → Review carefully → Refine → Confident

Fix: Always spend 30 seconds reviewing before accepting.


Anti-Pattern 3: Vague Feedback

❌ Vague
✅ Specific
'Make it better'
'Make the button larger and add more padding'
'This isn't right'
'The calculation should subtract, not add'
'Fix it'
'Fix the hover state — it should turn blue'

Fix: Be specific about what's wrong and what you want instead.


Anti-Pattern 4: Changing Too Many Things at Once

❌ Too Much
✅ Manageable
'Make it bigger, change color, add animation, fix spacing, add shadow, change font, make responsive'
'Make it bigger and add dark mode' → Then: 'Add animation and fix spacing' → Then: 'Make responsive'

Fix: Change 1-3 things at a time. Easier to verify each change worked.


🌳 Iteration Decision Tree

Use this when deciding your next step:

Does the output match what you wanted? │ ├── YES → ✅ Done! Accept the result │ └── NO → What's the main issue? │ ├── Wrong technology → "Use [correct tech] instead" │ ├── Missing feature → "Add [feature]" │ ├── Unwanted elements → "Remove [element]" │ ├── Wrong style → "Make it [description]" │ ├── Doesn't work → "This gives error: [error]. Fix it" │ └── Don't understand → "Explain [confusing part]"

🧪 Practice Exercise

Try this iteration exercise:

Start with:

Start Here
Create a simple card component
ChatGPTClaude

Then iterate to add (one or two at a time):

  1. An image at the top
  2. A title below the image
  3. A short description
  4. A "Learn More" button
  5. A shadow effect
  6. Rounded corners
  7. A hover animation

Challenge: Achieve this in as few prompts as possible!


📋 The Iteration Checklist

Before accepting any AI output:

0/6

✅ Lesson Summary

Key Takeaways

  1. First prompts rarely perfect — Expect to iterate
  2. Keep the conversation going — Build on previous responses
  3. Be specific in feedback — Tell AI exactly what to change
  4. One to three changes at a time — Easier to verify

The Iteration Loop:

Prompt → Review → Identify Issues → Refine → Repeat

📝 Mini Quiz

📝 Check Your Understanding

1/3

How many prompts should you expect for a complex task?