Chapter 1: Prompt engineering: The blueprint
The introduction argues that prompts used in software products should be treated as engineered interfaces rather than adjusted by intuition.
After this chapter you will be able to
- Prompts as engineering artifacts. Distinguish casual prompting from prompt engineering, and explain why shared prompts need the care given to other software components.
- Production variability as a defect. Explain why inconsistent prompt output becomes an engineering defect in a product, using the support-ticket routing example.
- Prompt interface and its parts. Explain why a prompt is an engineered interface rather than just a message, and describe the jobs of instructions, context, constraints, and inputs, including how the response is judged.
- Iterative prompt engineering lifecycle. Describe the design, test, iterate, and manage phases, what each produces, and why the phases need not occur in a fixed sequence.
- Deliberate prompt engineering practice. Explain prompt engineering as deliberately composing prompts with structure, evaluating outputs against defined criteria, and refining prompts systematically to make outputs reliable and predictable.
- Casual prompting tradeoff. Explain why reactive, undocumented prompting may suffice for personal tasks but creates problems when prompts are used in shared software work.
- Pull request prompt contrast. Trace how the designed pull-request summary prompt changes the review focus, separates instructions from source material, and specifies the response shape. Explain why the resulting difference is attributed to the prompt rather than a different model or additional source facts.
- Prompts as engineering specifications. Explain why prompts are a first-class engineering concern and how a prompt functions as a specification for model behavior.
- Prompt review and maintenance. Describe how established software engineering practices apply to prompts and what those practices make possible.
- Prompts as designed artifacts. Distinguish a prompt from an ordinary message and explain why prompt design is an engineering task.
- Component roles and failure modes. Explain the distinct jobs of the parts in the incident-summary prompt and how weakening them affects the result.
- Structured prompt design. Describe how Priya designs the bug-severity prompt before testing it: she defines the task and severity criteria, limits the evidence, specifies the response shape, and separates the variable report from reusable prompt text.
- Evidence from prompt testing. Explain how Priya tests the prompt against bug reports with known labels and uses the results to identify a recurring error.
- Evidence led prompt revision. Trace how Priya turns the database-timeout failure into an explicit criterion and reruns the test set to check the change.
- Documented prompt maintenance. Explain what Priya records when managing the final prompt and how that record helps a later engineer change it safely.
- Three prompt debugging questions. Apply the section’s diagnostic checklist by asking what contract the prompt specified, what context it omitted, and where it left too much room for variability.
- Prompts as software specifications. Explain how treating a prompt as a specification changes what goes into it: a clear task, relevant inputs, constraints, and criteria for a good result. Contrast that approach with a vague request such as asking what the model thinks of a feature proposal.
- Request-bound model context. Explain that a model can use only content supplied with the current request, including any conversation history the application sends, so the information needed for a correct output must be included.
- Prompt underspecification and variance. Explain why inconsistent output can signal an underspecified prompt and how making the prompt more specific can reduce that variance.
Section by section
Introduction
The introduction argues that prompts used in software products should be treated as engineered interfaces rather than adjusted by intuition.
- Prompts as engineering artifacts: Distinguish casual prompting from prompt engineering, and explain why shared prompts need the care given to other software components.
Why it matters: A prompt used by a team or product needs more than a wording change that happens to look good once. - Production variability as a defect: Explain why inconsistent prompt output becomes an engineering defect in a product, using the support-ticket routing example.
Why it matters: Small prompt error rates can affect many real users when a product runs the prompt repeatedly. - Enduring need for prompt discipline: Explain why the introduction argues that better models will not eliminate the need for prompt engineering.
Why it matters: The engineering habit is useful beyond any particular model or current prompting technique.
Key terms: casual prompting, prompt engineering, engineering artifacts, engineered interfaces, inconsistent output, interpretive room, specification, support-ticket routing, defining tasks precisely, constraining outputs
1.1 The prompt engineering mental model
This section frames prompts as engineered interfaces with distinct parts, an iterative lifecycle, and reusable patterns analogous to software design patterns.
- Prompt interface and its parts: Explain why a prompt is an engineered interface rather than just a message, and describe the jobs of instructions, context, constraints, and inputs, including how the response is judged.
Why it matters: Treating the prompt as an interface makes its parts and the standard for its output explicit. - Iterative prompt engineering lifecycle: Describe the design, test, iterate, and manage phases, what each produces, and why the phases need not occur in a fixed sequence.
Why it matters: The lifecycle gives prompt work deliverables and a way to respond to test results or maintenance needs. - Prompt patterns as shared vocabulary: Explain the analogy between prompt patterns and software design patterns without naming particular prompt patterns.
Why it matters: Pattern names can help a team discuss why a prompt uses a particular structure and what it costs.
Key terms: engineered interface, instructions, context, constraints, inputs, expected output, design, test, iterate, manage
1.2 From casual prompting to prompt engineering
The section contrasts casual prompting with deliberate prompt engineering and uses a pull-request summary to show how prompt design can improve output without changing the model or source information.
- Deliberate prompt engineering practice: Explain prompt engineering as deliberately composing prompts with structure, evaluating outputs against defined criteria, and refining prompts systematically to make outputs reliable and predictable.
Why it matters: It gives you a way to improve prompts that is more repeatable than changing words by feel. - Prompt design interface boundary: Distinguish prompt engineering from model fine-tuning by describing what it changes and what it leaves untouched.
Why it matters: You can improve a prompt without retraining or modifying the underlying model. - Casual prompting tradeoff: Explain why reactive, undocumented prompting may suffice for personal tasks but creates problems when prompts are used in shared software work.
Why it matters: Once other people depend on a prompt, they need to be able to inspect and maintain it. - Pull request prompt contrast: Trace how the designed pull-request summary prompt changes the review focus, separates instructions from source material, and specifies the response shape. Explain why the resulting difference is attributed to the prompt rather than a different model or additional source facts.
Why it matters: Before changing models or adding information, you can often improve an output by making the task and expected answer clearer.
Key terms: prompt engineering, acceptance criteria, reliable and predictable, model fine-tuning, interface level, model’s weights, casual prompting, shared engineering artifacts, review focus, input boundary
1.3 Why prompt engineering matters for software engineers
This section argues that prompts in software systems deserve the same specification, review, testing, and maintenance discipline as code and APIs.
- Prompts as engineering specifications: Explain why prompts are a first-class engineering concern and how a prompt functions as a specification for model behavior.
Why it matters: Treating a prompt as a specification gives you a way to reason about its reliability rather than guessing at wording. - Prompt review and maintenance: Describe how established software engineering practices apply to prompts and what those practices make possible.
Why it matters: A recorded, testable prompt can be reviewed and debugged before or after it causes a failure. - Teamwide prompt debt: Explain how informal, individual prompt practices create problems for a team over time.
Why it matters: Shared practices prevent a useful prompt from becoming a collection of incompatible personal experiments.
Key terms: first-class engineering concern, specification, constraints, inputs, output format, maintainable artifact, reviewable interface, version controlled, representative inputs, audit trail
1.4 Prompts as designed artifacts
This section treats prompts as designed artifacts whose parts shape the output and whose specific failures can be diagnosed.
- Prompts as designed artifacts: Distinguish a prompt from an ordinary message and explain why prompt design is an engineering task.
Why it matters: Treating a prompt as an artifact encourages deliberate choices instead of relying on wording alone. - Component roles and failure modes: Explain the distinct jobs of the parts in the incident-summary prompt and how weakening them affects the result.
Why it matters: Knowing what each part does helps you diagnose a weak output by inspecting the prompt. - Stable template and changing input: Describe why the incident-summary example is a prompt template.
Why it matters: This distinction lets the same designed prompt be used with different incident reports.
Key terms: message, prompt, designed artifact, instructions, incident report, components, failure modes, prompt template, {{incident_report_text}}, placeholder
1.5 The prompt engineering lifecycle
A bug-report classification example shows how prompt engineering moves through design, test, iterate, and manage, with each phase producing a concrete engineering deliverable.
- Structured prompt design: Describe how Priya designs the bug-severity prompt before testing it: she defines the task and severity criteria, limits the evidence, specifies the response shape, and separates the variable report from reusable prompt text.
Why it matters: Design makes the prompt a specification rather than an improvised request. - Evidence from prompt testing: Explain how Priya tests the prompt against bug reports with known labels and uses the results to identify a recurring error.
Why it matters: A measured failure gives Priya something specific to fix. - Evidence led prompt revision: Trace how Priya turns the database-timeout failure into an explicit criterion and reruns the test set to check the change.
Why it matters: Targeting a measured failure makes a prompt change explainable and testable. - Documented prompt maintenance: Explain what Priya records when managing the final prompt and how that record helps a later engineer change it safely.
Why it matters: Documentation helps the next engineer update the prompt without accidentally removing a justified rule.
Key terms: Design, classification criteria, variable input, response shape, Test, known label, failure mode, Iterate, explicit criterion, targeted prompt surgery
1.6 Three diagnostic lenses
Introduces a three-question checklist for diagnosing prompts that fail or produce plausible but unsuitable output.
- Three prompt debugging questions: Apply the section’s diagnostic checklist by asking what contract the prompt specified, what context it omitted, and where it left too much room for variability.
Why it matters: These questions give you a starting point for debugging a prompt rather than guessing at a fix.
Key terms: diagnostic checklist, contract, context, variability
1.6.1 Prompts as specifications
This section reframes prompts as software specifications so engineers can write and review them for specificity rather than treating them as casual messages.
- Prompts as software specifications: Explain how treating a prompt as a specification changes what goes into it: a clear task, relevant inputs, constraints, and criteria for a good result. Contrast that approach with a vague request such as asking what the model thinks of a feature proposal.
Why it matters: Specification thinking helps you make the model’s output match the decision your team actually needs to make. - Specification based prompt review: Describe how to review a prompt using specification questions about ambiguity, output constraints, and testable acceptance criteria rather than judging only how its wording sounds.
Why it matters: These questions give a team concrete grounds for discussing a prompt in a pull request.
Key terms: software specification, constraints, acceptance criteria, specificity, review vocabulary, underspecified, ambiguous interpretation
1.6.2 Prompts must be self-contained
This section explains why a prompt must include the context needed for the model to produce the intended output.
- Request-bound model context: Explain that a model can use only content supplied with the current request, including any conversation history the application sends, so the information needed for a correct output must be included.
Why it matters: It gives you a practical test for whether the model has the information your task requires. - Implicit team knowledge: Explain why an incident-postmortem prompt must explicitly supply the team's severity taxonomy and ordering convention, and why adding that context is the first fix for a generic result.
Why it matters: It helps you diagnose missing context before blaming the model for an output that misses local requirements.
Key terms: request, conversation context, message history, self-contained, implicit knowledge, severity taxonomy, customer effect statement, context
1.6.3 Inspecting the prompt first when output varies
This section teaches readers to inspect an inconsistent prompt for underspecification before blaming the model or API.
- Prompt underspecification and variance: Explain why inconsistent output can signal an underspecified prompt and how making the prompt more specific can reduce that variance.
Why it matters: It gives you a concrete first debugging step when a prompt works on some runs but not others. - Ticket taxonomy mapping gap: Describe how the customer-support ticket example illustrates a prompt-level cause of inconsistent classification.
Why it matters: The example shows what an actionable prompt fix looks like, rather than treating variable results as a mysterious model failure.
Key terms: underspecification, output schema, constraint, worked example, variance, internal taxonomy, reference list, interpretive gap
1.7 Summary
The chapter summary recaps prompt engineering as deliberate design of prompts as software artifacts, with explicit task requirements and a repeatable lifecycle.
Where this is used later
- Overview of structural elements (chapter 2) · Provides the mental model for examining prompt structural elements.
- Understanding prompt patterns (chapter 4) · Develops the idea of prompt patterns introduced by this analogy.
- The prompt lifecycle (chapter 11) · Expands the versioning, testing, and change practices introduced here into a prompt lifecycle.
- Why prompt management matters (chapter 11) · Returns to why teams need prompt management rather than isolated prompt work.
- (chapter intro) (chapter 2) · Treating prompts as designed artifacts.
- Prompt templates as reusable frameworks (chapter 5) · Introduces the stable-framework idea used in prompt templates.
- Combining structural elements (chapter 2) · Combines prompt elements into a deliberate structure.
- Test (chapter 11) · Develops testing as a phase of the prompt lifecycle.
Concepts explained in this chapter
- prompt engineeringThe deliberate construction of a prompt's instructions, context, constraints, and output requirements.
- specificationA precise statement of the required behavior, constraints, and expected results of a system component.
- promptA prompt is an instruction and context artifact supplied to a model to specify a task, constraints, and expected output.
- casual promptingAn informal prompting approach based on ad hoc wording changes and subjective judgment rather than systematic specification and evaluation.
- output varianceOutput variability is the degree to which generated outputs differ across generations for the same task.
- prompt engineering lifecycleThe sequence of managed stages through which a prompt progresses from drafting and testing to deployment, observation, improvement, and retirement.
- diagnostic lensA recurring analytical perspective for identifying why a prompt produces unreliable or unsuitable results.
- prompt libraryA centralized storage structure that holds prompt records and supports their retrieval and management.
- testThe systematic evaluation of a component against defined cases and expected results to detect defects or variation.
- failure modeA failure mode is a distinct way in which a system, artifact, or process can produce an incorrect or undesired result.
- prompt templateA reusable structure for supplying changing user-specific content to a model.
- acceptance criteriaDefined conditions that a result must satisfy to be considered acceptable.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.
