Prompt Engineering Tutorial 0/120 lessons ~6 min read Lesson 7

    Prompt Anatomy

    A production prompt is a structured document — not a sentence.

    Course progress0%
    Focus
    7 guided sections
    Practice signal
    Examples included
    Career prep
    Foundation builder

    Introduction

    A production prompt is a structured document — not a sentence. Knowing its parts lets you debug a bad output the way a doctor reads an X-ray: section by section.

    Beginner analogy: A prompt is a sandwich. Bread = role + format. Filling = instructions + examples + context. Sauce = constraints. Skip a layer and the whole thing tastes off.

    Understanding the topic

    Core concepts to understand:

    • Role — who the model is ("You are a senior security auditor").
    • Task — what to do ("Review this code for OWASP issues").
    • Context — background, docs, RAG chunks, prior data.
    • Examples — 1–5 input/output pairs that anchor behaviour.
    • Constraints — length, tone, what to skip, what to refuse.
    • Format — JSON schema, markdown, bullets, table.
    • Trigger — "Begin." or the user's actual question.

    Syntax reference

    Visual workflow / architecture:

    bash
    ┌──── ROLE ─────────────────────────────┐
    │ You are a senior security auditor. │
    ├──── TASK ─────────────────────────────┤
    │ Review the code for OWASP Top 10. │
    ├──── CONTEXT ──────────────────────────┤
    <code snippet>
    ├──── EXAMPLES ─────────────────────────┤
    │ Issue: ... Fix: ... │
    ├──── CONSTRAINTS ──────────────────────┤
    │ Max 5 issues. No marketing language. │
    ├──── FORMAT ───────────────────────────┤
    │ Return JSON: [{issue, severity, fix}]
    └───────────────────────────────────────┘

    Real-world use

    Anthropic's official Claude prompting guide is literally this anatomy — role, task, context, examples, format. Every great prompt at every AI company follows the same skeleton.

    Best practices

    • Always include role + task + format, even for one-off prompts.
    • Add examples only when zero-shot fails — they're expensive in tokens.
    • Use XML or markdown delimiters to make each section unambiguous.

    Common mistakes

    • Mixing instructions with examples — model copies the examples literally.
    • Skipping the format section and then complaining about messy output.

    Hands-on exercise

    Interview preparation — practice these questions:

    • Q1. List the parts of a production prompt.
    • Q2. Which part is the most under-used by beginners?
    • Q3. Where would you put RAG context — top, middle or bottom?
    • Q4. How do you debug a prompt that returns wrong format?
    Ready to mark this lesson complete?Track your journey across the entire course.