Prompt Engineering
ConceptBeginner 12 min· Prompt basics · 1 of 18

Anatomy of a good prompt

Most bad AI answers come from vague prompts. Learn the six parts of a strong prompt and turn a one-line request into one that gets a useful answer the first time.

An AI model only knows what is in your prompt (plus what it learned in training). It cannot see your syllabus, your codebase, your manager's expectations or the format you have in mind. When the answer is generic, it is usually because the prompt was generic.

A good prompt is like a good brief to a smart new colleague on their first day: they are capable, but they need context.

The six parts

What a strong prompt contains

PartWhat it doesExample
RoleSets the expertise and tone"You are a senior React developer who mentors freshers."
TaskThe one thing you want done, as a verb"Explain", "Write", "Review", "Compare"
ContextFacts the model can't know"I'm a 2nd-year B.Tech student; I know Java, not JavaScript."
ConstraintsLimits and must-haves"Under 200 words. No libraries. Use Indian examples."
FormatThe shape of the answer"A table with 3 columns", "numbered steps", "JSON"
ExamplesShow, don't tell (optional)One sample input and the output you want

You don't need all six every time. A quick question needs only a task. But when an answer disappoints you, check this list: the missing part is almost always context or format.

Before and after

Prompt · Weak prompt
Explain recursion.

What to expect: You'll get a correct but textbook answer pitched at nobody in particular, often with a factorial example you've already seen.

Prompt · Strong prompt
You are a patient programming tutor.

Explain recursion to me. Context: I'm a first-year student who knows Python loops but gets lost when a function calls itself. I have a lab exam next week.

Constraints:
- Use one everyday analogy and one Python example that is not factorial.
- Trace the example call by call, showing what is on the call stack at each step.
- Under 300 words.

Format: analogy, then code, then the trace as a numbered list, then one practice question for me (no answer).

What to expect: The answer is pitched at your level, uses a fresh example, shows the call stack (the part that actually confuses beginners) and ends with practice.

Put instructions first, data last

When you paste a long text (an article, an error log, a resume), write your instructions first, then the text, clearly marked, for example between lines of --- or inside tags like <resume> ... </resume>. The model then knows what is instruction and what is material to work on.

Why this works

A language model predicts the most likely continuation of your text. A vague prompt matches millions of possible situations, so you get an average answer. Every piece of context removes situations that don't apply to you, so the most likely answer becomes the one that fits you.

Roles work the same way: "You are a senior code reviewer" makes the vocabulary, priorities and level of detail of code reviews more likely. A role does not give the model knowledge it doesn't have.

A good prompt doesn't make the answer true

Clear prompts make answers more relevant, not more accurate. Models can still invent facts, APIs and citations. Check anything that matters (exam facts, code, numbers, legal or medical information) against a reliable source.

A reusable skeleton

Prompt · Prompt skeleton (fill in the brackets)
You are [role].

Task: [what you want, starting with a verb].

Context:
- [who you are / who it's for]
- [what you already know or have tried]
- [why you need it]

Constraints:
- [length]
- [must include / must avoid]

Format: [table / steps / JSON / email / code with comments].

If anything important is unclear, ask me up to 3 questions before answering.

What to expect: The last line is powerful: instead of guessing, the model asks about what's missing.

Try it: Upgrade three prompts

Rewrite each weak prompt using at least four of the six parts, run both versions in a free tool such as Gemini or ChatGPT, and compare the answers.

1. "Write my resume summary." 2. "Give me a study plan for DBMS." 3. "Why is my code not working?"

Before you press Enter

  1. Did I say exactly what I want, with a verb?
  2. Did I give the context the model can't know?
  3. Did I set length and must-haves?
  4. Did I say what shape the answer should take?
  5. Did I separate my instructions from pasted material?

Key takeaways

  1. A strong prompt has a role, task, context, constraints, format and, optionally, examples.
  2. Missing context and missing format cause most disappointing answers.
  3. Instructions first, pasted material last and clearly marked.
  4. Asking the model to ask you questions first is an easy way to fill gaps.
  5. Better prompts give more relevant answers, not guaranteed-true ones; verify what matters.

Check yourself

Finishing the quiz marks the lesson as done.

1. Your AI answer is correct but too generic for your situation. What is most likely missing from your prompt?

2. You paste a 3-page article and want a summary. Where should your instructions go?

3. What does adding "You are a senior security engineer" to a prompt actually do?

4. Which line most reduces guessing when your request is under-specified?

5. Which part of a prompt does "Reply as a table with columns: topic, hours, resources" set?

Saved on this device. Create a free account to keep it on every device.

Practise this with Sam

A real mock interview, out loud, with an honest scorecard. Free to start.

Start free