Why can the same language model give two completely different answers to almost the same question? Why does adding one example sometimes improve the result—and sometimes quietly teach the wrong lesson? Why can a fluent answer still be false, malformed, or unsafe to use?
Many books teach prompt engineering as a collection of templates and magic phrases. This book begins with a simpler idea:
LLM(input) → output
The model produces an output from an input. We usually cannot change the model itself, but we can shape the instructions, context, examples, constraints, and conversation history that enter its input. Prompt engineering begins there: not with clever wording, but with the deliberate design of what the model receives.
Starting from this mental model, the book develops zero-shot and few-shot prompting, prompt structure, system and user messages, role prompting, multi-turn context, chain-of-thought reasoning, structured output, and hallucination control. It then follows prompt engineering across the boundary into software engineering, where generated answers must be validated, evaluated, and prevented from becoming unsafe actions. Planned chapters will extend this foundation into prompt evaluation and defenses against prompt injection.
This is not an encyclopedia of prompting techniques. It is for readers who want to understand why the techniques work, where they fail, and how they fit together. It uses concrete examples and memorable mental models before introducing technical precision.
The goal is for you to finish each chapter thinking:
I finally get it.
This book is a work in progress. Existing chapters will continue to be revised, and new chapters will be added as the manuscript develops.