liveBook · Manning

Chapter 4: Patterns

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

The introduction positions prompt patterns as repeatable strategies that extend prompt structure and wording to address common interaction problems.

After this chapter you will be able to

What it builds on

Section by section

Introduction

The introduction positions prompt patterns as repeatable strategies that extend prompt structure and wording to address common interaction problems.

Key terms: prompt patterns, structural elements, linguistic elements

4.1 Understanding prompt patterns

This section defines prompt patterns as reusable task strategies and introduces three categories based on what those strategies do.

Key terms: prompt patterns, structural and linguistic elements, transferability, structural patterns, contextual patterns, transformational patterns

4.2 Role assignment pattern

This section introduces role assignment as a low-overhead prompt pattern that shapes the model’s approach to a task and is especially useful when expertise, audience fit, or professional credibility matters.

Key terms: role assignment pattern, persona, expertise, voice, specialized knowledge, specific audience targeting, professional credibility

4.2.1 Practical example: Pull request description generation

This section compares two PR descriptions for the same refactor to show how a specific, credible role assignment can make the output more useful to reviewers.

Key terms: role assignment, PR description, How to Review, service boundaries, profession or expertise, contextual background, measurable outcomes, domain-aware judgment

4.3 Delimiter pattern

The section presents delimiters as a repeatable way to organize complex prompt templates, explains how to mark their boundaries, and gives a check for delimiter conflicts.

Key terms: delimiter pattern, variable content, instructions, prompt template, headings, separators, fenced code blocks, user-generated content, delimiter types, multiple data sources

4.3.1 Practical example: Multisource bug analysis

This section uses a multisource bug-analysis prompt to show how delimiters separate inputs and make a reusable template easier to maintain.

Key terms: delimiter pattern, headings, separators, fenced blocks, prompt templates, input sources, variables, delimiter discipline

4.4 Template pattern

This section explains how the template pattern makes repeated outputs predictable by defining their structure, and when that consistency is useful.

Key terms: template pattern, fixed schema, output structure, delimiter pattern, consistent formatting, automated systems, one-off creative tasks

4.4.1 Practical example: Incident postmortem summaries

This example shows how an explicit output template makes incident postmortem summaries consistent and easier to use.

Key terms: template pattern, output contract, fields, Incident, Effect, Root cause, Resolution, Action item, concrete placeholders

4.5 Repetition pattern

This section explains how repeating a full prompt can improve accuracy and why the pattern is easy to add to an existing workflow.

Key terms: repetition pattern, full prompt, second pass, input, output format, existing workflows

4.5.1 When to use the repetition pattern

This section explains when repetition is worth using and when its token and latency costs make it a poor choice.

Key terms: repetition pattern, nonreasoning configurations, context window, input tokens, output tokens, latency, token efficiency

4.5.2 Practical example: Selecting a logging approach

This example shows how repeating an identical logging-selection prompt can produce a more grounded comparison, while weighing the extra token cost.

Key terms: repetition pattern, grounded explanation, request-path overhead, asynchronous logging, critical path, enqueue operation, batching, backpressure, repeated prompt, token efficiency

4.6 Self-reflection pattern

Introduces self-reflection as an immediate critique of a model’s output and explains when the extra step is worthwhile.

Key terms: self-reflection pattern, refinement, evaluation-then-improvement workflow, complex analysis, strategic recommendations, high-stakes outputs, simple factual queries, urgent work

4.6.1 Practical example: Technical onboarding plan

A technical onboarding example shows how self-reflection can preserve a plan’s strengths while revealing important omissions.

Key terms: self-reflection, onboarding plan, collaboration practices, delivery tooling, domain context, inversion, internal critique, external challenge

4.7 Inversion pattern

This section explains how inversion turns existing content into questions that reveal blind spots, when to use it, and how its questions can feed later refinement.

Key terms: inversion pattern, Content > Interrogation, blind spots, role assignment, inversion, domain perspective, external perspective, knowledge gaps, FAQ entries, multistep workflows

4.7.1 Practical example: Architecture proposal review

This example uses an inversion prompt to test a microservices migration proposal from stakeholder perspectives and expose risks the proposal leaves unanswered.

Key terms: inversion, architecture proposal, external perspectives, blind spots, transactional integrity, cascading failures, cognitive load

4.8 Refinement pattern

This section explains refinement as the improvement step in a multistep workflow and when that step is useful.

Key terms: refinement pattern, self-reflection, inversion, evaluation-to-improvement loop, specific, actionable feedback, initial output, requirements

4.8.1 Practical example: API documentation improvement

This example shows how to turn a critique of sparse API documentation into a concise, more usable endpoint reference.

Key terms: self-reflection, refinement pattern, feedback, request structure, bearer authentication, response behavior, developer-focused tone

4.9 Comment-driven generation

This section introduces comment-driven generation as a way to batch passage-specific feedback into targeted improvements to code or documentation.

Key terms: comment-driven generation, anchored, selected passage, inversion pattern, refinement pattern, resolution recommendations, targeted improvements, structured review workflow, specific comments

4.9.1 Practical example: Technical Request for Comments review

This example shows how to turn comments tied to specific RFC passages into targeted revision guidance rather than generic feedback.

Key terms: comment-driven generation, selected text, targeted revision guidance, observable evidence, technical approach, implementation scope

4.9.2 Hands-on practice

This hands-on section asks readers to combine prompt patterns in practical workflows, compare the results with a baseline, and recognize how patterns can complement one another.

Key terms: baseline prompt, first output, quality, reliability, effort, self-reflection, refinement, inversion, comment-driven generation, blind spots

4.10 Summary

The section summarizes how prompt patterns make outputs more consistent and help teams find and fix weaknesses before they cause costly revisions.

Where this is used later

Concepts explained in this chapter

← Chapter 3: Prompt design: Linguistic elements Chapter 5: Templates →

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.