Lesson 03 Prompt Engineering Basics
Theme:
Lesson 03 · Slide 1

Prompt Engineering Basics

The difference between a mediocre and an excellent LLM output is almost always the quality of the prompt, not the model. Learn to write prompts that consistently deliver.

Learning Objectives

Lesson 03 · Slide 2

The RTCF Framework

Every effective prompt has four components. Miss one and quality drops noticeably.

R — Role

Who should Claude be? "You are a senior Python engineer reviewing code for production safety."

T — Task

What exactly must be done? Use an action verb. "Identify all potential security vulnerabilities in the following code snippet."

C — Context

What does Claude need to know? Audience, constraints, background. "The code runs in a multi-tenant SaaS environment. Users are untrusted."

F — Format

How should the output look? "Respond with a numbered list. For each issue include: severity (High/Med/Low), line reference, and suggested fix."

Notes: Build the example prompt piece by piece — show the output after adding each component so students see the quality jump at each step.
Lesson 03 · Slide 3

Specificity: The #1 Lever

Vague prompts force the model to guess your intent. Every guess is a place things can go wrong.

Vague (bad)

"Write something about machine learning for my blog."

  • Length undefined — could be 50 or 2000 words
  • Audience unknown — too basic or too advanced
  • Topic unfocused — model picks whatever
  • Tone unspecified — formal, casual, academic?

Specific (good)

"Write a 400-word introductory blog post about gradient descent for software engineers with no ML background. Use a hiking-downhill analogy. End with three bullet-point takeaways."

  • Length: 400 words
  • Audience: SW engineers, no ML background
  • Technique: hiking analogy required
  • Structure: body + 3 bullets
Notes: Ask students to count the number of decisions the model must make in the vague prompt — typically 5–8. Each decision is a failure point.
Lesson 03 · Slide 4

Output Format Control

Explicitly specifying format saves post-processing code and makes outputs directly usable.

Length

Summarise this document in exactly 3 sentences.
Write no more than 150 words.
Provide a comprehensive analysis (aim for 800–1000 words).

Structure

Respond ONLY with valid JSON matching this schema:
{"sentiment": "positive|neutral|negative", "confidence": 0.0–1.0, "reason": "string"}

Format your response as a Markdown table with columns: Term | Definition | Example.

Use numbered headings. Each section must include at least one code example.

Tone

Write in a friendly, conversational tone suitable for a 12-year-old.
Be terse and technical — the audience are experienced engineers.
Match the formal register of an academic paper.
Lesson 03 · Slide 5

Common Failure Modes

FailureExampleFix
Ambiguous task "Improve this email." Specify the dimension: "Make the subject line more compelling" or "Shorten to under 100 words"
Missing constraints "List pros and cons." Add: "List exactly 3 pros and 3 cons. Each point max 20 words."
Implicit audience "Explain neural networks." Add audience: "Explain for a business executive with no technical background"
No output format "Tell me about the competitors." Add: "Respond with a Markdown table: Company | Strength | Weakness"
Notes: Show each failure live — run the bad prompt, get a mediocre result, apply the fix, show the improvement. The contrast is always striking.
Lesson 03 · Slide 6

Before → After Makeovers

Before: "Summarise this article."

After: "Summarise this article in 3 bullet points. Each bullet should be one sentence (max 25 words). Focus only on findings relevant to small-business owners."

Before: "Write a function that parses JSON."

After: "Write a Python function parse_user(raw: str) -> dict that parses a JSON string into a User dict. Handle json.JSONDecodeError by returning an empty dict. Include type hints and a docstring."

Before: "What should I do about my slow database?"

After: "I have a PostgreSQL table with 10M rows. The query SELECT * FROM orders WHERE status='pending' ORDER BY created_at takes 8 seconds. What are the top 3 indexing strategies I should try first? For each, explain the trade-off."

Notes: Open terminal, run 3 versions of the same prompt (vague, medium, specific), show output differences live.
Lesson 03 · Slide 7

Demo

Live comparison of prompt quality using the terminal.

Demo Steps

  1. Pick a single task: "write a product description for noise-cancelling headphones"
  2. Run Version 1 — the bare prompt above; note generic, unfocused output
  3. Run Version 2 — add role + audience; note shift in tone and vocabulary
  4. Run Version 3 — add format constraints (word count, specific benefits, CTA); observe sharply focused output
  5. Show the token counts — well-specified prompts use slightly more input tokens but dramatically fewer output tokens
Notes: Open terminal, run 3 versions of same prompt, show output differences. Ask students: which output would you actually use without editing?
Lesson 03 · Slide 8

Lab & Homework

Lab Exercises

  1. RTCF Builder — take 3 real tasks from your own work and construct a full RTCF prompt for each; compare outputs before and after applying the framework
  2. Format Variety — take one prompt and produce the same content in 3 formats (JSON, Markdown table, prose paragraph); note which is easiest to consume downstream
  3. Failure Mode Hunt — find a "bad" prompt, diagnose which failure mode(s) it has, and rewrite it using the fixes from this lesson

Homework Tasks

  1. Build a personal prompt template library: 5 templates for tasks you do regularly (summarise, classify, draft, extract, explain). Each template should have placeholders for the variable parts.
  2. Run a controlled experiment: choose one prompt, vary only the role instruction across 5 different roles (teacher, lawyer, comedian, etc.) and document how output changes.
  3. Read Anthropic's Prompt Engineering Guide (docs.anthropic.com). List 3 recommendations you hadn't considered and plan how to incorporate them.
1 / ?