liveBook · Manning

Chapter 2: Prompt design: Structural elements

What you will learn in chapter 2 of Prompt Engineering in Practice

The introduction explains how separating a prompt into structural elements clarifies each part’s role and makes prompts easier to reuse and diagnose.

After this chapter you will be able to

What it builds on

Section by section

Introduction

The introduction explains how separating a prompt into structural elements clarifies each part’s role and makes prompts easier to reuse and diagnose.

Key terms: instructions, constraints, context, input parameters, output format, delimiters, structural elements, separates concerns

2.1 Overview of structural elements

Introduces six prompt elements and shows how their distinct roles combine into a structured interface for more reliable model behavior.

Key terms: instructions, constraints, context, input parameters, output format, delimiters, unified template, structured interface, clarity, control

2.2 Instructions

This section explains what instructions do in a prompt and how to write them so the task is clear.

Key terms: instructions, structural element, instruction logic, primary action, audience, technical context, task boundary, ordered directives

2.2.1 Practical example 1: Explaining HTTP 429 errors

A worked HTTP 429 example shows how a specific instruction guides a response without further direction.

Key terms: instruction, audience, register

2.2.2 Practical example 2: Generating code review feedback

A code review example shows how an instruction can focus feedback on particular concerns and adapt it to its intended reader.

Key terms: instruction, domain, correctness, security, audience, constraints

2.3 Constraints

This section defines constraints as testable restrictions on model output, distinguishes them from instructions and output format, and explains how to use them without treating them as guarantees.

Key terms: constraints, instructions, output format, task scope, testable, measurable, unambiguous, length constraint, task objective, main instruction

2.3.1 Practical example: Writing secure logging guidelines

A secure-logging example shows how instructions define a prompt’s task while specific constraints make its output requirements checkable.

Key terms: Instructions, Constraints, directive layer, correlation ID

2.4 Context

This section defines prompt context as task-specific background and shows a simple way to separate it from instructions.

Key terms: context, context window, task-specific background information, Additional Context, Instructions, ADR summary

2.4.1 Practical example 1: Generating an architecture decision record summary

This example shows how system context and an ADR-specific instruction produce a concise summary that preserves the reasons for an architecture decision.

Key terms: Additional Context, ADR summary, decision context, tradeoffs, expected operational effect

2.4.2 Practical example 2: Generating an incident handoff conversation

A payment-outage handoff example shows how incident context and a concise instruction produce a short, operationally clear dialogue.

2.5 Input parameters

This section explains how input parameters turn a prompt template into a complete prompt before it is sent to a language model.

Key terms: input parameters, prompt template, placeholders, runtime variable injection, fully resolved prompt

2.5.1 Practical example 1: Analyzing error logs

A worked error-log example shows how filling input parameters turns a reusable prompt template into an incident-specific prompt.

Key terms: prompt template, input parameters, {service_name}, {environment}, {error_log}

2.5.2 Practical example 2: Generating release notes

A release-notes example shows how filling a reusable prompt template with release-specific inputs produces a concrete prompt, then gives practical rules for choosing and formatting input parameters.

Key terms: prompt template, input parameters, template variables, release-specific context, input variables, input format, f-strings, Jinja2, output format

2.6 Output format

This section explains why every prompt needs an output format and how specifying it makes responses predictable.

Key terms: output format, structural element

2.6.1 Practical example 1: Generating a deployment checklist

A payment-service deployment checklist example shows how explicit output-format instructions make a response consistent and suitable for automatic processing.

Key terms: output format, numbered list, Predeployment checks, Deployment steps, Postdeployment verification

2.6.2 Practical example 2: Generating an API endpoint summary

This example specifies a consistent key-value format for an API endpoint summary and explains why that format is useful.

Key terms: key-value pairs, Output Format, Endpoint, Method, Authentication, Request Body

2.7 Delimiters

This section explains how delimiters separate contextual content from instructions and recommends triple-backtick code fences for that purpose.

Key terms: delimiters, context blocks, input parameters, Markdown-style triple-backtick code fences, de facto standard

2.7.1 Practical example 1: Summarizing an incident report

The section uses an incident-report summary to show how delimiters separate source material from instructions, then explains how to choose and test delimiters.

Key terms: triple backticks, delimiter, Additional Context, Instructions, alternative delimiters, instruction-context separation, evaluations

2.7.2 Practical example 2: Answering questions from a runbook

This example shows how an XML tag separates a runbook containing shell commands from a question that must be answered using the runbook.

Key terms: XML tags, <runbook> tag, backticks, runbook

2.7.3 Defensive prompting tip

This section explains how to delimit embedded text to reduce instruction-mixing risk, while emphasizing that delimiters alone are not enough.

Key terms: delimited context block, instruction-mixing risk, instruction boundaries, input hygiene, delimiters, context, instructions, input variables

2.8 Combining structural elements

This section gives a rule for combining prompt elements according to the task, including when to use input parameters.

Key terms: instructions, output format, constraints, context, input parameters, delimiters, static, reusable prompt template

2.8.1 Practical example 1: Generating incident status updates

The example combines structural prompt elements to turn checkout incident notes into a consistent, stakeholder-facing status update.

Key terms: Additional Context, Input parameters, Delimiters, Instructions, Constraints, Output Format, incident notes, Root Cause (Known/Unknown), Mitigation in Progress, Next Update ETA

2.8.2 Practical example 2: Generating a deployment GO/NO-GO brief

A worked deployment example shows how to combine prompt elements to produce an evidence-based, actionable GO/NO-GO brief.

Key terms: Context, Delimiters, Instructions, Constraints, Output Format, Input parameters, GO or NO-GO, deployment signals, runbook excerpt, rollback threshold

2.8.3 Hands-on practice

This hands-on section asks readers to design prompts for software delivery tasks using structural elements deliberately, then connects that approach to systematic prompt engineering.

Key terms: instructions, output format, context, input parameters, constraints, delimiters, structural elements, systematic engineering practice, reusable, testable

2.9 Summary

This section summarizes what each structural prompt element does and how to choose elements when assembling a prompt.

Where this is used later

Concepts explained in this chapter

← Chapter 1: Prompt engineering: The blueprint Chapter 3: Prompt design: Linguistic elements →

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.