chapter two

2 Prompt design: Structural elements

 

This chapter covers

  • The core structural elements: instructions, constraints, context, input parameters, output format, and delimiters
  • Writing falsifiable constraints that bound the solution space
  • Using input parameters to inject dynamic context and enable reuse
  • Specifying output structure for consistent, predictable responses
  • Combining these elements into reliable, task-specific prompts

Most prompts start as a single block of text: the task, the background, the variable inputs, and the expected output shape, all in one place with no clear boundaries. The model has to infer what is an instruction, what is context, what is content to act on, and what the output should look like. When the output is wrong, there is no obvious place to look.

Structural elements give each concern a defined place. Instructions define the task, and constraints place explicit, verifiable limits on what the output must not violate, forming the directive layer of the prompt. Context provides the background the model needs to interpret the instructions and constraints, while input parameters separate variable inputs from stable instruction logic so the same template works across different runs. Output format specifies what the response must look like, and delimiters mark the boundaries around embedded content so it cannot be misread as instructions.

2.1 Overview of structural elements

2.2 Instructions

2.2.1 Practical example 1: Explaining HTTP 429 errors

2.2.2 Practical example 2: Generating code review feedback

2.3 Constraints

2.3.1 Practical example: Writing secure logging guidelines

2.4 Context

2.4.1 Practical example 1: Generating an architecture decision record summary

2.4.2 Practical example 2: Generating an incident handoff conversation

2.5 Input parameters

2.5.1 Practical example 1: Analyzing error logs

2.5.2 Practical example 2: Generating release notes

2.6 Output format

2.6.1 Practical example 1: Generating a deployment checklist

2.6.2 Practical example 2: Generating an API endpoint summary

2.7 Delimiters

2.7.1 Practical example 1: Summarizing an incident report

2.7.3 Defensive prompting tip