Skip to main content

Module 03: Prompt Engineering

Prompt engineering is the discipline of designing inputs that reliably elicit desired outputs from large language models. It sounds simple. It isn't.

A poorly designed prompt produces inconsistent, hallucinated, or completely wrong outputs - even from a state-of-the-art model. A well-designed prompt transforms the same model into a reliable, precise tool for production workloads. The difference between the two is what this module teaches.

This module covers the full spectrum: from understanding why zero-shot instructions work at all, through the mechanics of chain-of-thought reasoning, to building production-grade systems with structured outputs and automated optimization. By the end, you'll have a principled toolkit - not just a bag of tricks.

What You'll Learn

  • Why instruction-following works and how to exploit it systematically
  • How to engineer prompts that produce consistent, parseable output
  • The reasoning techniques (CoT, ToT, ReAct) that make models solve hard problems
  • Security: how prompt injection attacks work and how to defend against them
  • How to automate the prompt engineering process itself with DSPy

Module Progression

Lessons

#LessonWhat You'll Learn
01Zero-Shot PromptingInstruction anatomy, role personas, format control, when zero-shot fails
02Few-Shot PromptingIn-context learning, example selection, label calibration, ordering effects
03Chain-of-ThoughtStep-by-step reasoning, self-consistency, least-to-most prompting
04Tree-of-ThoughtMulti-path exploration, BFS/DFS search, thought evaluation
05ReAct PatternReasoning + Acting, tool calling, the foundation of LLM agents
06System Prompts & Context DesignConversation roles, token budget, history compression, dynamic context
07Prompt Injection & SecurityAttack taxonomy, jailbreaks, defense strategies, threat modeling
08Structured Output & JSON ModeJSON mode, Pydantic, constrained decoding, schema design
09Prompt Optimization & DSPyAPE, OPRO, DSPy signatures, compiling, evaluation-driven engineering

Prerequisites

  • Familiarity with how LLMs work (Module 01: Foundations)
  • Basic Python and API usage
  • Understanding of tokenization (Module 02: Tokenization & Embeddings)

Key Concepts

  • In-context learning: Models learn from examples in the prompt without weight updates
  • Emergent capabilities: Some techniques (CoT) only work above certain model scales
  • Instruction following: The result of RLHF/instruction tuning - models trained to follow explicit directions
  • Context window: The finite memory of a model - everything must fit in tokens
  • Prompt injection: The security vulnerability unique to LLM systems
  • Constrained decoding: Guaranteeing output format at the generation level
  • DSPy: Treating prompts as learnable parameters in an optimizable pipeline

:::tip Start Here If you're new to prompt engineering, start with Lesson 01 (Zero-Shot) and work through in order. If you already know the basics and want production techniques, jump to Lesson 06 (System Prompts) or Lesson 08 (Structured Output). :::

© 2026 EngineersOfAI. All rights reserved.