Skip to main content

Prompt Framework

Β· 4 min read
Hieu Doan
Software Engineer

πŸ“š Table of Contents​

🧠✨ Introduction​

🧠 Prompting is quickly becoming a core skill for developers, designers, and knowledge workers.

⏳ A good prompt can save hours of work, while a vague one can lead to confusing or unusable results.

🧩 Think of prompts as interfaces for thinking β€” the clearer your interface, the better the output.

πŸš€ This post introduces a simple, reusable Prompt Framework that helps you to:

  • πŸ—£οΈ communicate intent clearly
  • 🎯 get more consistent results
  • πŸ” reuse prompts across tools and projects

🧩 5W1H​

🧠 One of the easiest ways to structure a strong prompt is by borrowing the classic 5W1H framework.

πŸ‘€ Who​

πŸ‘€ Who is the AI supposed to be?

  • A senior engineer
  • A product manager
  • A teacher explaining to beginners

β€œAct as a senior backend engineer…”


πŸ“Œ What​

πŸ“Œ What exactly do you want?

  • Generate code
  • Review text
  • Explain a concept

β€œExplain how Kafka consumer groups work…”


🎯 Why​

🎯 Why are you asking?

  • Learning
  • Production use
  • Decision making

🧠 This helps the model choose the right depth and tone.

β€œβ€¦so I can explain it to junior developers.”


⏱️ When (optional)​

⏱️ When are time or context constraints relevant?

  • Current trends
  • Backward compatibility
  • Version-specific behavior

β€œUsing Kafka 3.x…”


🌍 Where (optional)​

🌍 Where will this be used?

  • Web
  • Mobile
  • Backend
  • React, Spring Boot, FastAPI

β€œβ€¦in a Spring Boot application.”


βš™οΈ How​

βš™οΈ How should the output look?

  • Bullet points
  • Code only
  • Step-by-step explanation

β€œUse simple examples and diagrams in text.”


βœ… Good Prompt vs ❌ Bad Prompt​

❌ Bad Prompt​

β€œExplain Kafka”

🚨 Problems:

  • πŸ‘€ No role
  • 🎯 No goal
  • 🌍 No context
  • βš™οΈ No format
  • ❌ No example

πŸ€” The AI must guess everything, which often leads to generic or unfocused answers.


βœ… Good Prompt​

β€œAct as a senior backend engineer.
Explain Kafka consumer groups in simple terms for junior developers, using Kafka 3.x and a Spring Boot context.
Use bullet points and a short example, similar to explaining how HTTP load balancing works.”

βœ… Why this works:

  • πŸ‘€ Clear role
  • 🎯 Clear goal
  • 🌍 Clear context
  • πŸ“ Clear format
  • 🧩 Clear example

🧠 Examples act as anchors β€” they show the AI what β€œgood” looks like, not just what to do.


πŸ”— Combination​

πŸ”— The real power comes from combining frameworks.

🧠 Prompt Formula​

Role + Task + Context + Constraints + Output Format + (Optional) Example

πŸ” Reusable Prompt Template​

Act as [ROLE].

Your task is to [WHAT].
This is for [WHY].
Context: [WHERE / WHEN].

Output requirements:

- Format: [FORMAT]
- Style: [STYLE]
- Length: [LENGTH]
- Example (optional): [REFERENCE OR SAMPLE]

πŸ” You can store these templates and reuse them across:

  • ChatGPT
  • Claude
  • GitHub Copilot
  • Internal AI tools

4️⃣ Why This Works​

🧠 This framework works because it separates structure from intent.

  • 🧩 Who + How β†’ quality control (template-owned)
    πŸŽ›οΈ These define how the AI should think and respond.
    πŸ“ˆ They improve output quality regardless of topic.

  • 🎯 What + Why β†’ intent (user-owned)
    🧠 These define what matters.
    πŸ™‹ Only the user knows the real task and success criteria.

  • 🌍 Where / When β†’ relevance (user-owned, optional)
    🧭 These ground the response in a real-world context, when needed.

🧩 Examples sit at the boundary:

  • Optional
  • User-provided
  • Extremely powerful when clarity or style matters

βš–οΈ By keeping:

  • πŸ—οΈ structure in the template
  • ✍️ meaning in the user’s hands

πŸš€ you avoid over-constraining prompts while still getting consistent, high-quality results.

✨ Template sets clarity. User sets purpose. Examples set direction.


Final Thoughts πŸš€β€‹

🧠 Prompting is not about β€œtalking nicely to AI”.
🎯 It’s about thinking clearly and expressing intent.

βœ… A good prompt:

  • ❄️ reduces ambiguity
  • πŸ“ˆ improves output quality
  • ⏳ saves time

πŸš€ Start simple. Use 5W1H.
πŸ” Then combine and refine as you go.

✨ Clear thinking β†’ Clear prompts β†’ Better results

πŸ˜„ Happy prompting!