Skip to content

Learn AI · Foundations

Prompt Engineering Basics

The actual techniques that move the needle — role priming, structured output, few-shot examples, and why specificity always wins.

9 min readPublished Mar 2025Updated May 2026
Prompt EngineeringBest PracticesPrompting
Edited by The AIKnowHub team · Editorial team

Key takeaways

  • 1Specificity is the single biggest lever — vague prompts get vague outputs.
  • 2Few-shot examples beat lengthy instructions for format and style.
  • 3Always specify the output format (JSON schema, markdown structure, etc.).
  • 4Negative instructions ('do not invent statistics') are surprisingly effective.
  • 5Prompt engineering is empirical — keep an eval set, iterate against it.

Mental model

A prompt is a contract. You're telling the model:

  1. Who you want it to act as.
  2. What you want it to do.
  3. With what input.
  4. In what shape the output should come back.
  5. Avoiding what failure modes.

The clearer the contract, the better the output.

Technique 1 — Be specific

Bad: "Write a marketing email."

Better: "Write a 120-word marketing email to existing customers announcing our new annual plan (20% discount, locked-in pricing for 2 years). Tone: friendly but direct. CTA: 'Switch to Annual'. End with one PS line about cancellation policy."

Specificity isn't a stylistic choice. It's the single biggest lever you have.

Technique 2 — Show, don't tell (few-shot)

When you want a specific format or style, give 2–3 examples:

Convert these support tickets into bug reports.

Example 1:
Ticket: "App crashes when I tap settings"
Bug:
  Title: Crash on Settings tap
  Steps: 1. Open app 2. Tap Settings
  Expected: Settings screen loads
  Actual: App crashes

Example 2: ...

Now convert:
Ticket: "{user_input}"

This is more reliable than any amount of instruction.

Technique 3 — Structured output

If you need JSON, ask for JSON and describe the schema:

Return your answer as JSON matching this schema:
{
  "summary": string (max 80 chars),
  "sentiment": "positive" | "neutral" | "negative",
  "action_items": string[]
}
Do not include any text outside the JSON object.

Even better: use the model's native structured output mode (OpenAI response_format, Anthropic tool use, Gemini schema parameter) when available.

Technique 4 — Chain of thought (when it helps)

Asking the model to think step by step before answering improves performance on reasoning tasks. But:

  • Modern reasoning models (o3, Claude with extended thinking) do this internally.
  • For simple tasks, CoT is wasted tokens.
  • Use it when answers are wrong, not as a default.

Technique 5 — Negative examples

Tell the model what not to do:

Do not include speculation. Do not invent statistics. If you don't know, say "Unknown."

These instructions are surprisingly effective at preventing common failure modes.

Technique 6 — Position matters

Models pay strongest attention to the beginning and end of the prompt. Put the most important instructions there. For long context, restate the question at the end:

{long context}

---

Question (repeated for clarity): {actual question}

What doesn't matter as much as you think

  • "You are an expert..." preambles — minor effect at best.
  • All caps EMPHASIS — sometimes helps, often noise.
  • Long elaborate persona descriptions — they pad the context for little gain.

The iteration loop

  1. Write the simplest prompt that should work.
  2. Run it on 5–10 real inputs.
  3. Find the failure mode that bites you most.
  4. Add one specific instruction or example targeting it.
  5. Repeat.

Prompt engineering is empirical. Trust your eval set over your intuition.

Common misconceptions

The wrong-but-common takes worth correcting.

Myth

There are magic phrases that unlock the model.

Reality

'You are an expert' adds maybe 1–3% on average. Specific instructions and good examples move quality far more.

Myth

Longer prompts are better prompts.

Reality

Every extra sentence is more tokens for the model to weigh. Trim ruthlessly — concise instructions are usually clearer.

Myth

Reasoning models don't need prompt engineering.

Reality

They need *less* prompt engineering for reasoning steps, but format specs, output schemas, and examples still matter.

Real-world use cases

Frequently asked questions

There's no universal best, but XML tags (Claude) or numbered sections (GPT) consistently outperform free-form paragraphs. Use clear, parsable structure.

Watch

Hand-picked videos from official + trusted channels. Opens in a new tab.